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