[TASK] Stabilize acceptance tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / BackendUser / ListUserCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
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
19 /**
20 * List User tests
21 */
22 class ListUserCest
23 {
24 /**
25 * @param Admin $I
26 */
27 public function _before(Admin $I)
28 {
29 $I->useExistingSession();
30
31 $I->see('Backend users');
32 $I->click('Backend users');
33
34 $I->switchToContentFrame();
35 }
36
37 /**
38 * @param Admin $I
39 */
40 public function showsHeadingAndListsBackendUsers(Admin $I)
41 {
42 $I->see('Backend User Listing');
43
44 $I->wantTo('See the table of users');
45 $I->waitForElementVisible('#typo3-backend-user-list');
46
47 // We expect exact four Backend Users created from the Fixtures
48 $this->checkCountOfUsers($I, 4);
49 }
50
51 /**
52 * @param Admin $I
53 */
54 public function filterUsersByUsername(Admin $I)
55 {
56 $I->wantTo('See the table of users');
57 $I->waitForElementVisible('#typo3-backend-user-list');
58 // We expect exact four Backend Users created from the Fixtures
59 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
60
61 $I->wantTo('Filter the list of user by valid username admin');
62 $I->fillField('#tx_Beuser_username', 'admin');
63 $I->click('Filter');
64 $I->waitForElementNotVisible('div#nprogess');
65 $I->waitForElementVisible('#typo3-backend-user-list');
66
67 // We expect exact one fitting Backend User created from the Fixtures
68 $this->checkCountOfUsers($I, 1);
69
70 $I->wantTo('Filter the list of user by valid username administrator');
71 $I->fillField('#tx_Beuser_username', 'administrator');
72 $I->click('Filter');
73 $I->waitForElementNotVisible('div#nprogess');
74 $I->waitForElementVisible('#typo3-backend-user-list');
75
76 // We expect exact no fitting Backend User created from the Fixtures
77 $this->checkCountOfUsers($I, 0);
78 }
79
80 /**
81 * @param Admin $I
82 */
83 public function filterUsersByAdmin(Admin $I)
84 {
85 $I->wantTo('See the table of users');
86 $I->waitForElementVisible('#typo3-backend-user-list');
87 // We expect exact four Backend Users created from the Fixtures
88 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
89
90 $I->wantToTest('Filter BackendUser and see only admins');
91 $I->selectOption('#tx_Beuser_usertype', 'Admin only');
92 $I->click('Filter');
93 $I->waitForElementNotVisible('div#nprogess');
94 $I->waitForElementVisible('#typo3-backend-user-list');
95
96 // We expect exact two fitting Backend Users created from the Fixtures
97 $this->checkCountOfUsers($I, 2);
98
99 $I->wantToTest('Filter BackendUser and see normal users');
100 $I->selectOption('#tx_Beuser_usertype', 'Normal users only');
101 $I->click('Filter');
102 $I->waitForElementNotVisible('div#nprogess');
103 $I->waitForElementVisible('#typo3-backend-user-list');
104
105 // We expect exact two fitting Backend Users created from the Fixtures
106 $this->checkCountOfUsers($I, 2);
107 }
108
109 /**
110 * @param Admin $I
111 */
112 public function filterUsersByStatus(Admin $I)
113 {
114 $I->wantTo('See the table of users');
115 $I->waitForElementVisible('#typo3-backend-user-list');
116 // We expect exact four Backend Users created from the Fixtures
117 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
118
119 $I->wantToTest('Filter BackendUser and see only active users');
120 $I->selectOption('#tx_Beuser_status', 'Active only');
121 $I->click('Filter');
122 $I->waitForElementNotVisible('div#nprogess');
123 $I->waitForElementVisible('#typo3-backend-user-list');
124
125 // We expect exact two fitting Backend Users created from the Fixtures
126 $this->checkCountOfUsers($I, 2);
127
128 $I->wantToTest('Filter BackendUser and see only inactive users');
129 $I->selectOption('#tx_Beuser_status', 'Inactive only');
130 $I->click('Filter');
131 $I->waitForElementNotVisible('div#nprogess');
132 $I->waitForElementVisible('#typo3-backend-user-list');
133
134 // We expect exact two fitting Backend Users created from the Fixtures
135 $this->checkCountOfUsers($I, 2);
136 }
137
138 /**
139 * @param Admin $I
140 */
141 public function filterUsersByLogin(Admin $I)
142 {
143 $I->wantTo('See the table of users');
144 $I->waitForElementVisible('#typo3-backend-user-list');
145 // We expect exact four Backend Users created from the Fixtures
146 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
147
148 $I->wantToTest('Filter BackendUser and see only users logged in before');
149 $I->selectOption('#tx_Beuser_logins', 'Logged in before');
150 $I->click('Filter');
151 $I->waitForElementNotVisible('div#nprogess');
152 $I->waitForElementVisible('#typo3-backend-user-list');
153
154 // We expect exact two fitting Backend Users created from the Fixtures
155 $this->checkCountOfUsers($I, 2);
156
157 $I->wantToTest('Filter BackendUser and see only users never logged in before');
158 $I->selectOption('#tx_Beuser_logins', 'Never logged in');
159 $I->click('Filter');
160 $I->waitForElementNotVisible('div#nprogess');
161 $I->waitForElementVisible('#typo3-backend-user-list');
162
163 // We expect exact two fitting Backend Users created from the Fixtures
164 $this->checkCountOfUsers($I, 2);
165 }
166
167 /**
168 * @param Admin $I
169 */
170 public function filterUsersByUserGroup(Admin $I)
171 {
172 $I->wantTo('See the table of users');
173 $I->waitForElementVisible('#typo3-backend-user-list');
174 // We expect exact four Backend Users created from the Fixtures
175 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
176
177 // We expect exact one Backend Users created from the Fixtures has the usergroup named 'editor-group'
178 $I->wantToTest('Filter BackendUser and see only users with given usergroup');
179 $I->selectOption('#tx_beuser_backendUserGroup', 'editor-group');
180 $I->click('Filter');
181 $I->waitForElementNotVisible('div#nprogess');
182 $I->waitForElementVisible('#typo3-backend-user-list');
183
184 // We expect exact one fitting Backend User created from the Fixtures
185 $this->checkCountOfUsers($I, 1);
186 }
187
188 /**
189 * @param Admin $I
190 * @param int $countOfUsers
191 */
192 protected function checkCountOfUsers(Admin $I, $countOfUsers)
193 {
194 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $countOfUsers);
195 $I->wantToTest('If a number of users is shown in the footer row');
196 $I->canSeeNumberOfElements('#typo3-backend-user-list tfoot tr', 1);
197 $I->see($countOfUsers . ' Users', '#typo3-backend-user-list tfoot tr');
198 }
199
200 /**
201 * @param Admin $I
202 */
203 public function canEditUsersFromIndexListView(Admin $I)
204 {
205 $I->canSee('Backend User Listing', 'h1');
206 $username = $I->grabTextFrom('#typo3-backend-user-list > tbody > tr:nth-child(1) > td.col-title > a:nth-child(1) > b');
207
208 $I->amGoingTo('test the edit button');
209 $I->click('#typo3-backend-user-list > tbody > tr:nth-child(1) > td.col-control > div:nth-child(1) > a');
210 $this->openAndCloseTheEditForm($I, $username);
211
212 $I->amGoingTo('test the edit link on username');
213 $I->click('#typo3-backend-user-list > tbody > tr:nth-child(1) > td.col-title > a:nth-child(1)');
214 $this->openAndCloseTheEditForm($I, $username);
215
216 $I->amGoingTo('test the edit link on real name');
217 $I->click('#typo3-backend-user-list > tbody > tr:nth-child(1) > td.col-title > a:nth-child(4)');
218 $this->openAndCloseTheEditForm($I, $username);
219 }
220
221 /**
222 * @param Admin $I
223 * @param string $username
224 *
225 * @throws \Exception
226 */
227 private function openAndCloseTheEditForm(Admin $I, string $username): void
228 {
229 $I->waitForElementNotVisible('#t3js-ui-block');
230 $I->canSee('Edit Backend user "' . $username . '" on root level');
231
232 $I->click('div.module-docheader .btn.t3js-editform-close');
233 $I->waitForElementVisible('table.table-striped');
234 $I->canSee('Backend User Listing', 'h1');
235 }
236 }