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