[TASK] Make failing acceptance tests after image update run again
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Formhandler / Inline1nCest.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 Facebook\WebDriver\WebDriverKeys;
18 use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
19 use TYPO3\TestingFramework\Core\Acceptance\Support\Helper\ModalDialog;
20 use TYPO3\TestingFramework\Core\Acceptance\Support\Page\PageTree;
21
22 /**
23 * Tests for inline 1n
24 */
25 class Inline1nCest
26 {
27 public function _before(Admin $I, PageTree $pageTree)
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->click('List');
36 $pageTree->openPath(['styleguide TCA demo', 'inline 1n']);
37 $I->switchToIFrame('list_frame');
38
39 $I->waitForText('inline 1n', 20);
40 $editRecordLinkCssPath = '#recordlist-tx_styleguide_inline_1n a[data-original-title="Edit record"]';
41 $I->click($editRecordLinkCssPath);
42 $I->waitForText('Edit Form', 3, 'h1');
43 }
44
45 /**
46 * @param Admin $I
47 */
48 public function checkIfExpandsAndCollapseShowInput(Admin $I)
49 {
50 $I->wantTo('Expands the inline Element');
51 $I->click('div[data-toggle="formengine-inline"]', '#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_div');
52 $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]');
53 $I->wantTo('check is the value in input');
54 $I->seeInField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]', 'lipsum');
55 $I->wantTo('Collapse the inline Element');
56 $I->click('div[data-toggle="formengine-inline"]', '#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_div');
57 $I->waitForElementNotVisible('#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_fields.panel-collapse');
58 }
59
60 /**
61 * @param Admin $I
62 */
63 public function hideAndUnhideInline1nInlineElement(Admin $I)
64 {
65 $I->wantTo('Can hide a Inline Element');
66 $I->click('a span[data-identifier="actions-edit-hide"]', '#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_div');
67 $I->waitForElement('#data-12-tx_styleguide_inline_1n-1-inline_1_records .t3-form-field-container-inline-hidden');
68 $I->wantTo('Can unhide a Inline Element');
69 $I->click('a span[data-identifier="actions-edit-unhide"]', '#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_div');
70 $I->waitForElementNotVisible('#data-12-tx_styleguide_inline_1n-1-inline_1_records .t3-form-field-container-inline-hidden', 2);
71 }
72
73 /**
74 * @param Admin $I
75 */
76 public function createInline1nInlineElement(Admin $I)
77 {
78 $I->click('span[data-identifier="actions-document-new"]', 'div.typo3-newRecordLink');
79
80 $fieldLabel = 'input_1';
81 $testValue = 'Fo Bar';
82
83 $this->fillFieldByLabel($I, $fieldLabel, $testValue);
84
85 $I->click('button[name="_savedok"]');
86 $I->wait(3);
87 $I->click('a[title="Close"]');
88 $I->wait(3);
89
90 $I->executeJS('$(\'a[data-table="pages_language_overlay"] .icon-actions-view-list-collapse\').click();');
91 $I->wait(1);
92
93 $I->see('lipsum', '#recordlist-tx_styleguide_inline_1n_child > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(2) > a');
94 $I->see('Fo Bar', '#recordlist-tx_styleguide_inline_1n_child > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(2) > a');
95 }
96
97 /**
98 * @depends createInline1nInlineElement
99 * @param Admin $I
100 */
101 public function checkIfCanSortingInlineElement(Admin $I)
102 {
103 $I->wantTo('Can sort an Inline Element');
104 $I->click('a span[data-identifier="actions-move-down"]', '#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_div');
105 $I->click('button[name="_savedok"]');
106 $I->wait(3);
107 $I->click('a[title="Close"]');
108 $I->wait(3);
109
110 $I->executeJS('$(\'a[data-table="pages_language_overlay"] .icon-actions-view-list-collapse\').click();');
111 $I->wait(1);
112
113 $I->wantTo('Check new sorting');
114 $I->see('Fo Bar', '#recordlist-tx_styleguide_inline_1n_child > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(2) > a');
115 $I->see('lipsum', '#recordlist-tx_styleguide_inline_1n_child > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(2) > a');
116 }
117
118 /**
119 * @param Admin $I
120 */
121 public function changeInline1nInlineInput(Admin $I)
122 {
123 $I->click('div[data-toggle="formengine-inline"]', '#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_div');
124 $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]');
125 $I->fillField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]', 'hello world');
126 $I->click('button[name="_savedok"]');
127 $I->wait(3);
128 $I->click('a[title="Close"]');
129 $I->wait(3);
130 $I->see('hello world');
131 }
132
133 /**
134 * @param Admin $I
135 * @param ModalDialog $modalDialog
136 */
137 public function deleteInline1nInlineElement(Admin $I, ModalDialog $modalDialog)
138 {
139 $inlineElementToDelete = '#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_div';
140 $I->wantTo('Cancel the delete dialog');
141 $I->click('a span[data-identifier="actions-edit-delete"]', $inlineElementToDelete);
142 $modalDialog->clickButtonInDialog('button[name="no"]');
143 // switch form Dialogbox back to IFrame
144 $I->switchToIFrame('list_frame');
145 $I->seeElement($inlineElementToDelete);
146
147 $I->wantTo('Accept the delete dialog');
148 $I->click('a span[data-identifier="actions-edit-delete"]', $inlineElementToDelete);
149
150 // don't use $modalDialog->clickButtonInDialog due to too low timeout
151 $modalDialog->canSeeDialog();
152 $I->click('button[name="yes"]', ModalDialog::$openedModalButtonContainerSelector);
153 $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
154 // switch form Dialogbox back to IFrame
155 $I->switchToIFrame('list_frame');
156 $I->waitForElementNotVisible($inlineElementToDelete);
157 }
158
159 /**
160 * @param Admin $I
161 * @param $fieldLabel
162 * @param $testValue
163 */
164 protected function fillFieldByLabel(Admin $I, $fieldLabel, $testValue)
165 {
166 $fieldContext = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
167 $fieldLabel
168 ) {
169 return $webdriver->findElement(
170 \Facebook\WebDriver\WebDriverBy::xpath('(//label[contains(text(),"' . $fieldLabel . '")])[1]/ancestor::fieldset[@class="form-section"][1]')
171 );
172 });
173
174 $visibleFieldXpath = './/*/input[@data-formengine-input-name]';
175 $clearButtonXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/button[@class="close"]';
176 $initializedInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@data-formengine-input-name][@data-formengine-input-initialized]';
177 $I->waitForElement($initializedInputFieldXpath, 30);
178 $inputField = $fieldContext->findElement(\WebDriverBy::xpath($visibleFieldXpath));
179 $internalInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]';
180
181 $I->waitForElement($internalInputFieldXpath, 30);
182 $I->waitForElement($clearButtonXpath, 30);
183
184 $I->fillField($inputField, $testValue);
185 $inputField->sendKeys(WebDriverKeys::TAB);
186 $fieldContext->click();
187 $I->comment('Test value of "visible" field');
188 $I->canSeeInField($inputField, $testValue);
189 }
190 }