7370f4b1c01cc2421ede255e79a4daf9e5a1a167
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Scheduler / TasksCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Scheduler;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
18 use TYPO3\TestingFramework\Core\Acceptance\Support\Helper\ModalDialog;
19
20 /**
21 * Scheduler task tests
22 */
23 class TasksCest
24 {
25 /**
26 * @param Admin $I
27 */
28 public function _before(Admin $I)
29 {
30 $I->useExistingSession();
31 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
32 $I->switchToIFrame('list_frame');
33 $I->waitForText('Web Content Management System');
34 $I->switchToIFrame();
35 $I->see('Scheduler', '#system_txschedulerM1');
36 $I->click('Scheduler', '#system_txschedulerM1');
37 // switch to content iframe
38 $I->switchToIFrame('list_frame');
39 }
40
41 /**
42 * @param Admin $I
43 */
44 public function createASchedulerTask(Admin $I)
45 {
46 $I->see('No tasks defined yet');
47 $I->click('//a[contains(@title, "Add task")]', '.module-docheader');
48 $I->waitForElementNotVisible('#task_SystemStatusUpdateNotificationEmail');
49 $I->selectOption('#task_class', 'System Status Update');
50 $I->seeElement('#task_SystemStatusUpdateNotificationEmail');
51 $I->selectOption('#task_type', 'Single');
52 $I->fillField('#task_SystemStatusUpdateNotificationEmail', 'test@local.typo3.org');
53 $I->click('button.dropdown-toggle', '.module-docheader');
54 $I->wantTo('Click "Save and close"');
55 $I->click("//a[contains(@data-value,'saveclose')]");
56 $I->waitForText('The task was added successfully.');
57 }
58
59 /**
60 * @depends createASchedulerTask
61 * @param Admin $I
62 */
63 public function canRunTask(Admin $I)
64 {
65 // run the task
66 $I->click('a[data-original-title="Run task"]');
67 $I->waitForText('Executed: System Status Update');
68 $I->seeElement('.tx_scheduler_mod1 .disabled');
69 $I->see('disabled');
70 }
71
72 /**
73 * @depends createASchedulerTask
74 * @param Admin $I
75 */
76 public function canEditTask(Admin $I)
77 {
78 $I->click('//a[contains(@data-original-title, "Edit")]');
79 $I->waitForText('Edit task');
80 $I->seeInField('#task_SystemStatusUpdateNotificationEmail', 'test@local.typo3.org');
81 $I->fillField('#task_SystemStatusUpdateNotificationEmail', 'foo@local.typo3.org');
82 $I->click('button.dropdown-toggle', '.module-docheader');
83 $I->wantTo('Click "Save and close"');
84 $I->click("//a[contains(@data-value,'saveclose')]");
85 $I->waitForText('The task was updated successfully.');
86 }
87
88 /**
89 * @depends canRunTask
90 * @param Admin $I
91 */
92 public function canEnableAndDisableTask(Admin $I)
93 {
94 $I->wantTo('See a enable button for a task');
95 $I->click('//a[contains(@data-original-title, "Enable")]', '#tx_scheduler_form');
96 $I->dontSeeElement('.tx_scheduler_mod1 .disabled');
97 $I->dontSee('disabled');
98 $I->wantTo('See a disable button for a task');
99 $I->click('//a[contains(@data-original-title, "Disable")]');
100 $I->waitForElementVisible('div.tx_scheduler_mod1');
101 $I->seeElement('.tx_scheduler_mod1 .disabled');
102 $I->see('disabled');
103 }
104
105 /**
106 * @depends createASchedulerTask
107 * @param Admin $I
108 * @param ModalDialog $modalDialog
109 */
110 public function canDeleteTask(Admin $I, ModalDialog $modalDialog)
111 {
112 $I->wantTo('See a delete button for a task');
113 $I->seeElement('//a[contains(@data-original-title, "Delete")]');
114 $I->click('//a[contains(@data-original-title, "Delete")]');
115 $I->wantTo('Cancel the delete dialog');
116
117 // don't use $modalDialog->clickButtonInDialog due to too low timeout
118 $modalDialog->canSeeDialog();
119 $I->click('Cancel', ModalDialog::$openedModalButtonContainerSelector);
120 $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
121
122 $I->switchToIFrame('list_frame');
123 $I->wantTo('Still see and can click the Delete button as the deletion has been canceled');
124 $I->click('//a[contains(@data-original-title, "Delete")]');
125 $modalDialog->clickButtonInDialog('OK');
126 $I->switchToIFrame('list_frame');
127 $I->see('The task was successfully deleted.');
128 $I->see('No tasks defined yet');
129 }
130
131 /**
132 * @param Admin $I
133 */
134 public function canSwitchToSetupCheck(Admin $I)
135 {
136 $I->selectOption('select[name=SchedulerJumpMenu]', 'Setup check');
137 $I->waitForElementVisible('div.tx_scheduler_mod1');
138 $I->see('Setup check');
139 $I->see('This screen checks if the requisites for running the Scheduler as a cron job are fulfilled');
140 }
141
142 /**
143 * @param Admin $I
144 */
145 public function canSwitchToInformation(Admin $I)
146 {
147 $I->selectOption('select[name=SchedulerJumpMenu]', 'Information');
148 $I->waitForElementVisible('div.tx_scheduler_mod1');
149 $I->see('Information');
150 $I->canSeeNumberOfElements('.tx_scheduler_mod1 table tbody tr', [1, 10000]);
151 }
152
153 /**
154 * @param Admin $I
155 */
156 public function canCreateNewTaskGroupFromEditForm(Admin $I)
157 {
158 $I->amGoingTo('create a task when none exists yet');
159 $I->canSee('Scheduled tasks', 'h1');
160 $this->createASchedulerTask($I);
161
162 $I->amGoingTo('test the new task group button on task edit view');
163 $I->click('#DataTables_Table_0 > tbody > tr > td.nowrap > span > div:nth-child(1) > a:nth-child(1)');
164 $I->waitForElementNotVisible('#t3js-ui-block');
165 $I->canSee('Edit task', 'h2');
166 $I->click('#task_group_row > div > div > div > div > a');
167 $I->waitForElementNotVisible('#t3js-ui-block');
168 $I->canSee('Create new Scheduler task group on root level', 'h1');
169
170 $I->fillField('//input[contains(@data-formengine-input-name, "data[tx_scheduler_task_group]") and contains(@data-formengine-input-name, "[groupName]")]', 'new task group');
171 $I->click('button[name="_savedok"]');
172 $I->wait(0.2);
173 $I->waitForElementNotVisible('#t3js-ui-block');
174 $I->click('a[title="Close"]');
175 $I->waitForElementVisible('#tx_scheduler_form');
176
177 $I->selectOption('select#task_class', 'new task group');
178 $I->click('button[value="save"]');
179 $I->waitForElementNotVisible('#t3js-ui-block');
180 $I->click('a[title="Cancel"]');
181 $I->waitForElementVisible('div.tx_scheduler_mod1');
182
183 $I->canSee('new task group', 'tr.taskGroup');
184 }
185 }