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