[TASK] Stabilize acceptance tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Formhandler / ElementsGroupCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
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\Page\PageTree;
19
20 /**
21 * Tests for ElementsGroupelement fields
22 */
23 class ElementsGroupCest
24 {
25 public function _before(Admin $I, PageTree $pageTree)
26 {
27 $I->useExistingSession();
28
29 $I->click('List');
30 $pageTree->openPath(['styleguide TCA demo', 'elements group']);
31 $I->switchToContentFrame();
32
33 $I->executeJS('window.name="TYPO3Main";');
34
35 $I->waitForText('elements group', 20);
36 $editRecordLinkCssPath = '#recordlist-tx_styleguide_elements_group a[data-original-title="Edit record"]';
37 $I->click($editRecordLinkCssPath);
38 $I->waitForText('Edit Form', 3, 'h1');
39 }
40
41 /**
42 * @param Admin $I
43 */
44 public function sortElementsInGroup(Admin $I)
45 {
46 $fieldset = 'div.typo3-TCEforms > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > fieldset:nth-of-type(1)';
47 $formWizardsWrap = $fieldset . ' > div:nth-of-type(1) div.t3js-formengine-field-item > div:nth-of-type(1)';
48 $select = $formWizardsWrap . ' > div:nth-of-type(2) > select';
49
50 $selectOption1 = 'styleguide demo user 1';
51 $multiselect = ['styleguide demo user 1', 'styleguide demo user 2'];
52
53 $I->amGoingTo('put "' . $selectOption1 . '" on first position');
54 $I->selectOption($select, $selectOption1);
55 $I->click($formWizardsWrap . ' div:nth-of-type(3) > div > a.t3js-btn-moveoption-top');
56 $I->see($selectOption1, $select . ' > option:nth-child(1)');
57
58 $I->amGoingTo('put "' . $selectOption1 . '" one position down / on the second position');
59 $I->selectOption($select, $selectOption1);
60 $I->click($formWizardsWrap . ' div:nth-of-type(3) > div > a.t3js-btn-moveoption-down');
61 $I->see($selectOption1, $select . ' > option:nth-child(2)');
62
63 $I->amGoingTo('put "' . $selectOption1 . '" on the last position');
64 $I->selectOption($select, $selectOption1);
65 $I->click($formWizardsWrap . ' div:nth-of-type(3) > div > a.t3js-btn-moveoption-bottom');
66 $I->see($selectOption1, $select . ' > option:nth-last-child(1)');
67
68 $I->amGoingTo('put "' . $selectOption1 . '" one position up / on second last position');
69 $I->selectOption($select, $selectOption1);
70 $I->click($formWizardsWrap . ' div:nth-of-type(3) > div > a.t3js-btn-moveoption-up');
71 $I->see($selectOption1, $select . ' > option:nth-last-child(2)');
72
73 $I->amGoingTo('put ' . print_r($multiselect, 1) . ' on first position');
74 $I->selectOption($select, $multiselect);
75 $I->click($formWizardsWrap . ' div:nth-of-type(3) > div > a.t3js-btn-moveoption-top');
76 $I->see($multiselect[0], $select . ' > option:nth-child(1)');
77 $I->see($multiselect[1], $select . ' > option:nth-child(2)');
78
79 $I->amGoingTo('put ' . print_r($multiselect, 1) . ' one position down');
80 $I->selectOption($select, $multiselect);
81 $I->click($formWizardsWrap . ' div:nth-of-type(3) > div > a.t3js-btn-moveoption-down');
82 $I->see($multiselect[0], $select . ' > option:nth-child(2)');
83 $I->see($multiselect[1], $select . ' > option:nth-child(3)');
84 }
85
86 /**
87 * @param Admin $I
88 */
89 public function addARecordWithRecordBrowserGroup(Admin $I)
90 {
91 $fieldset = 'div.typo3-TCEforms > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > fieldset:nth-of-type(1)';
92 $formWizardsWrap = $fieldset . ' > div:nth-of-type(1) div.t3js-formengine-field-item > div:nth-of-type(1)';
93
94 $I->seeNumberOfElements('select[data-formengine-input-name="data[tx_styleguide_elements_group][1][group_db_1]"] option', 4);
95 $I->click($formWizardsWrap . ' div:nth-of-type(4) > div > a:nth-of-type(1)');
96
97 $I->switchToWindow();
98 $I->switchToIFrame('modal_frame');
99
100 $I->amGoingTo('click + button to select record and close DB-Browser');
101 $I->click('#recordlist-be_users > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(2) > span:nth-child(1) > a:nth-child(1)');
102
103 $I->switchToWindow();
104 $I->switchToContentFrame();
105 $I->seeNumberOfElements('select[data-formengine-input-name="data[tx_styleguide_elements_group][1][group_db_1]"] option', 5);
106 }
107
108 /**
109 * @param Admin $I
110 */
111 public function addTwoRecordWithRecordBrowserGroup(Admin $I)
112 {
113 $fieldset = 'div.typo3-TCEforms > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > fieldset:nth-of-type(1)';
114 $formWizardsWrap = $fieldset . ' > div:nth-of-type(1) div.t3js-formengine-field-item > div:nth-of-type(1)';
115
116 $I->seeNumberOfElements('select[data-formengine-input-name="data[tx_styleguide_elements_group][1][group_db_1]"] option', 4);
117 $I->click($formWizardsWrap . ' div:nth-of-type(4) > div > a:nth-of-type(1)');
118
119 $I->switchToWindow();
120 $I->switchToIFrame('modal_frame');
121
122 $I->amGoingTo('click record + in DB-Browser');
123 $I->click('#recordlist-be_groups > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(2) > span:nth-child(1) > a:nth-child(1)');
124 $I->amGoingTo('click + button to select record and close DB-Browser');
125 $I->click('#recordlist-be_users > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(2) > span:nth-child(1) > a:nth-child(1)');
126
127 $I->switchToWindow();
128 $I->switchToContentFrame();
129 $I->seeNumberOfElements('select[data-formengine-input-name="data[tx_styleguide_elements_group][1][group_db_1]"] option', 6);
130 }
131
132 /**
133 * @param Admin $I
134 */
135 public function searchForARecordWithRecordBrowserGroup(Admin $I)
136 {
137 $fieldset = 'div.typo3-TCEforms > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > fieldset:nth-of-type(1)';
138 $formWizardsWrap = $fieldset . ' > div:nth-of-type(1) div.t3js-formengine-field-item > div:nth-of-type(1)';
139
140 $I->seeNumberOfElements('select[data-formengine-input-name="data[tx_styleguide_elements_group][1][group_db_1]"] option', 4);
141 $I->click($formWizardsWrap . ' div:nth-of-type(4) > div > a:nth-of-type(1)');
142
143 $I->switchToWindow();
144 $I->switchToIFrame('modal_frame');
145
146 $I->amGoingTo("search record '' and limit 1 in DB-Browser");
147 $I->fillField('#showLimit', 1);
148 $I->click('button[name="search"]');
149 $I->waitForElement('.recordlist');
150 $I->seeNumberOfElements('.recordlist #recordlist-be_groups table tbody tr', 1);
151
152 $I->amGoingTo('search record style and limit 1 in DB-Browser');
153 $I->fillField('#search_field', 'style');
154 $I->click('button[name="search"]');
155 $I->waitForElement('.recordlist');
156 $I->seeNumberOfElements('.recordlist #recordlist-be_groups table tbody tr', 1);
157
158 $I->amGoingTo('reset limit');
159 $I->fillField('#showLimit', '');
160 $I->amGoingTo('search record foo in DB-Browser');
161 $I->fillField('#search_field', 'foo');
162 $I->click('button[name="search"]');
163 $I->waitForElementNotVisible('.recordlist');
164
165 $I->amGoingTo('search record admin in DB-Browser');
166 $I->fillField('#search_field', 'admin');
167 $I->click('button[name="search"]');
168 $I->waitForElement('.recordlist');
169 $I->see('admin', '.recordlist');
170
171 $I->amGoingTo('click + button to select record and close DB-Browser');
172 $I->click('#recordlist-be_users > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(2) > span:nth-child(1) > a:nth-child(1)');
173 $I->switchToWindow();
174 $I->click('.t3js-modal-close');
175
176 $I->switchToContentFrame();
177 $I->see('admin', 'select[data-formengine-input-name="data[tx_styleguide_elements_group][1][group_db_1]"]');
178 $I->click('.btn-toolbar button.btn:nth-child(2)');
179 $I->click('button[name="_savedok"]');
180 }
181 }