[TASK] Stabilize acceptance tests
[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 $I->see('Scheduler', '#system_txschedulerM1');
32 $I->click('Scheduler', '#system_txschedulerM1');
33 $I->switchToContentFrame();
34 }
35
36 /**
37 * @param Admin $I
38 */
39 public function createASchedulerTask(Admin $I)
40 {
41 $I->see('No tasks defined yet');
42 $I->click('//a[contains(@title, "Add task")]', '.module-docheader');
43 $I->waitForElementNotVisible('#task_SystemStatusUpdateNotificationEmail');
44 $I->selectOption('#task_class', 'System Status Update');
45 $I->seeElement('#task_SystemStatusUpdateNotificationEmail');
46 $I->selectOption('#task_type', 'Single');
47 $I->fillField('#task_SystemStatusUpdateNotificationEmail', 'test@local.typo3.org');
48 $I->click('button.dropdown-toggle', '.module-docheader');
49 $I->wantTo('Click "Save and close"');
50 $I->click("//a[contains(@data-value,'saveclose')]");
51 $I->waitForText('The task was added successfully.');
52 }
53
54 /**
55 * @depends createASchedulerTask
56 * @param Admin $I
57 */
58 public function canRunTask(Admin $I)
59 {
60 // run the task
61 $I->click('a[data-original-title="Run task"]');
62 $I->waitForText('Executed: System Status Update');
63 $I->seeElement('.tx_scheduler_mod1 .disabled');
64 $I->see('disabled');
65 }
66
67 /**
68 * @depends createASchedulerTask
69 * @param Admin $I
70 */
71 public function canEditTask(Admin $I)
72 {
73 $I->click('//a[contains(@data-original-title, "Edit")]');
74 $I->waitForText('Edit task');
75 $I->seeInField('#task_SystemStatusUpdateNotificationEmail', 'test@local.typo3.org');
76 $I->fillField('#task_SystemStatusUpdateNotificationEmail', 'foo@local.typo3.org');
77 $I->click('button.dropdown-toggle', '.module-docheader');
78 $I->wantTo('Click "Save and close"');
79 $I->click("//a[contains(@data-value,'saveclose')]");
80 $I->waitForText('The task was updated successfully.');
81 }
82
83 /**
84 * @depends canRunTask
85 * @param Admin $I
86 */
87 public function canEnableAndDisableTask(Admin $I)
88 {
89 $I->wantTo('See a enable button for a task');
90 $I->click('//a[contains(@data-original-title, "Enable")]', '#tx_scheduler_form');
91 $I->dontSeeElement('.tx_scheduler_mod1 .disabled');
92 $I->dontSee('disabled');
93 $I->wantTo('See a disable button for a task');
94 $I->click('//a[contains(@data-original-title, "Disable")]');
95 $I->waitForElementVisible('div.tx_scheduler_mod1');
96 $I->seeElement('.tx_scheduler_mod1 .disabled');
97 $I->see('disabled');
98 }
99
100 /**
101 * @depends createASchedulerTask
102 * @param Admin $I
103 * @param ModalDialog $modalDialog
104 */
105 public function canDeleteTask(Admin $I, ModalDialog $modalDialog)
106 {
107 $I->wantTo('See a delete button for a task');
108 $I->seeElement('//a[contains(@data-original-title, "Delete")]');
109 $I->click('//a[contains(@data-original-title, "Delete")]');
110 $I->wantTo('Cancel the delete dialog');
111
112 // don't use $modalDialog->clickButtonInDialog due to too low timeout
113 $modalDialog->canSeeDialog();
114 $I->click('Cancel', ModalDialog::$openedModalButtonContainerSelector);
115 $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
116
117 $I->switchToContentFrame();
118 $I->wantTo('Still see and can click the Delete button as the deletion has been canceled');
119 $I->click('//a[contains(@data-original-title, "Delete")]');
120 $modalDialog->clickButtonInDialog('OK');
121 $I->switchToContentFrame();
122 $I->see('The task was successfully deleted.');
123 $I->see('No tasks defined yet');
124 }
125
126 /**
127 * @param Admin $I
128 */
129 public function canSwitchToSetupCheck(Admin $I)
130 {
131 $I->selectOption('select[name=SchedulerJumpMenu]', 'Setup check');
132 $I->waitForElementVisible('div.tx_scheduler_mod1');
133 $I->see('Setup check');
134 $I->see('This screen checks if the requisites for running the Scheduler as a cron job are fulfilled');
135 }
136
137 /**
138 * @param Admin $I
139 */
140 public function canSwitchToInformation(Admin $I)
141 {
142 $I->selectOption('select[name=SchedulerJumpMenu]', 'Information');
143 $I->waitForElementVisible('div.tx_scheduler_mod1');
144 $I->see('Information');
145 $I->canSeeNumberOfElements('.tx_scheduler_mod1 table tbody tr', [1, 10000]);
146 }
147
148 /**
149 * @param Admin $I
150 */
151 public function canCreateNewTaskGroupFromEditForm(Admin $I)
152 {
153 $I->amGoingTo('create a task when none exists yet');
154 $I->canSee('Scheduled tasks', 'h1');
155 $this->createASchedulerTask($I);
156
157 $I->amGoingTo('test the new task group button on task edit view');
158 $I->click('#DataTables_Table_0 > tbody > tr > td.nowrap > span > div:nth-child(1) > a:nth-child(1)');
159 $I->waitForElementNotVisible('#t3js-ui-block');
160 $I->canSee('Edit task', 'h2');
161 $I->click('#task_group_row > div > div > div > div > a');
162 $I->waitForElementNotVisible('#t3js-ui-block');
163 $I->canSee('Create new Scheduler task group on root level', 'h1');
164
165 $I->fillField('//input[contains(@data-formengine-input-name, "data[tx_scheduler_task_group]") and contains(@data-formengine-input-name, "[groupName]")]', 'new task group');
166 $I->click('button[name="_savedok"]');
167 $I->wait(0.2);
168 $I->waitForElementNotVisible('#t3js-ui-block');
169 $I->click('a[title="Close"]');
170 $I->waitForElementVisible('#tx_scheduler_form');
171
172 $I->selectOption('select#task_class', 'new task group');
173 $I->click('button[value="save"]');
174 $I->waitForElementNotVisible('#t3js-ui-block');
175 $I->click('a[title="Cancel"]');
176 $I->waitForElementVisible('div.tx_scheduler_mod1');
177
178 $I->canSee('new task group', 'tr.taskGroup');
179 }
180 }