‪TYPO3CMS  10.4
Inline1nCest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Facebook\WebDriver\WebDriverKeys;
24 
29 {
37  public function ‪_before(‪BackendTester $I, ‪PageTree $pageTree)
38  {
39  $I->useExistingSession('admin');
40 
41  $I->click('List');
42  $I->waitForElement('svg .nodes .node');
43  $pageTree->openPath(['styleguide TCA demo', 'inline 1n']);
44  $I->switchToContentFrame();
45 
46  $I->waitForText('inline 1n', 20);
47  $editRecordLinkCssPath = '#recordlist-tx_styleguide_inline_1n a[data-original-title="Edit record"]';
48  $I->click($editRecordLinkCssPath);
49  $I->waitForText('Edit Form', 3, 'h1');
50  }
51 
56  {
57  $I->wantTo('Expands the inline Element');
58  $I->click('div[data-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
59  $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]');
60  $I->wantTo('check is the value in input');
61  $I->seeInField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]', 'lipsum');
62  $I->wantTo('Collapse the inline Element');
63  $I->click('div[data-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
64  $I->waitForElementNotVisible('[data-field-name^="[tx_styleguide_inline_1n_child]["] .panel-collapse');
65  }
66 
71  {
72  $I->wantTo('Can hide a Inline Element');
73  $I->click('button span[data-identifier="actions-edit-hide"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
74  $I->waitForElement('[data-field-name^="[tx_styleguide_inline_1n_child]["].t3-form-field-container-inline-hidden');
75  $I->waitForElement('[data-field-name^="[tx_styleguide_inline_1n_child]["] button span[data-identifier="actions-edit-unhide"]');
76  $I->wantTo('Can unhide a Inline Element');
77  $I->click('button span[data-identifier="actions-edit-unhide"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
78  $I->waitForElementNotVisible('[data-field-name^="[tx_styleguide_inline_1n_child]["].t3-form-field-container-inline-hidden', 2);
79  }
80 
85  {
86  $I->click('span[data-identifier="actions-add"]', 'div.typo3-newRecordLink');
87 
88  $fieldLabel = 'input_1';
89  $testValue = 'Fo Bar';
90  $I->wait(2);
91 
92  $this->‪fillFieldByLabel($I, $fieldLabel, $testValue);
93 
94  $I->click('button[name="_savedok"]');
95  $I->wait(3);
96  $I->click('a[title="Close"]');
97  $I->wait(3);
98 
99  $I->executeJS('$(\'a[data-table="pages"] .icon-actions-view-list-collapse\').click();');
100  $I->wait(1);
101  $I->executeJS('$(\'a[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-collapse\').click();');
102  $I->wait(1);
103 
104  $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');
105  $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(4) > td:nth-child(2) > a');
106  }
107 
113  {
114  $I->wantTo('Can sort an Inline Element');
115  $I->click('button span[data-identifier="actions-move-down"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
116  $I->click('button[name="_savedok"]');
117  $I->wait(3);
118  $I->click('a[title="Close"]');
119  $I->wait(3);
120 
121  $I->executeJS('$(\'a[data-table="pages"] .icon-actions-view-list-collapse\').click();');
122  $I->wait(1);
123  $I->executeJS('$(\'a[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-collapse\').click();');
124  $I->wait(1);
125 
126  $I->wantTo('Check new sorting');
127  $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');
128  $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');
129  }
130 
135  {
136  $I->click('div[data-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_child][1"]');
137  $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]');
138  $I->fillField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]', 'hello world');
139  $I->click('button[name="_savedok"]');
140  $I->wait(3);
141  $I->click('a[title="Close"]');
142  $I->wait(3);
143  $I->see('hello world');
144  }
145 
151  {
152  $inlineElementToDelete = '[data-field-name^="[tx_styleguide_inline_1n_child][1"]';
153  $I->wantTo('Cancel the delete dialog');
154  $I->click('button span[data-identifier="actions-edit-delete"]', $inlineElementToDelete);
155  $modalDialog->clickButtonInDialog('button[name="no"]');
156  // switch form Dialogbox back to IFrame
157  $I->switchToContentFrame();
158  $I->seeElement($inlineElementToDelete);
159 
160  $I->wantTo('Accept the delete dialog');
161  $I->click('button span[data-identifier="actions-edit-delete"]', $inlineElementToDelete);
162 
163  // don't use $modalDialog->clickButtonInDialog due to too low timeout
164  $modalDialog->canSeeDialog();
165  $I->click('button[name="yes"]', ModalDialog::$openedModalButtonContainerSelector);
166  $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
167  // switch form Dialogbox back to IFrame
168  $I->switchToContentFrame();
169  $I->waitForElementNotVisible($inlineElementToDelete);
170  }
171 
177  protected function ‪fillFieldByLabel(‪BackendTester $I, $fieldLabel, $testValue)
178  {
179  $fieldContext = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
180  $fieldLabel
181  ) {
182  return $webdriver->findElement(
183  \Facebook\WebDriver\WebDriverBy::xpath('(//label[contains(text(),"' . $fieldLabel . '")])[1]/ancestor::fieldset[@class="form-section"][1]')
184  );
185  });
186 
187  $visibleFieldXpath = './/*/input[@data-formengine-input-name]';
188  $clearButtonXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/button[@class="close"]';
189  $initializedInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@data-formengine-input-name][@data-formengine-input-initialized]';
190  $I->waitForElement($initializedInputFieldXpath, 30);
191  $inputField = $fieldContext->findElement(\Facebook\WebDriver\WebDriverBy::xpath($visibleFieldXpath));
192  $internalInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]';
193 
194  $I->waitForElement($internalInputFieldXpath, 30);
195  $I->waitForElement($clearButtonXpath, 30);
196 
197  $I->fillField($inputField, $testValue);
198  $inputField->sendKeys(WebDriverKeys::TAB);
199  $fieldContext->click();
200  $I->comment('Test value of "visible" field');
201  $I->canSeeInField($inputField, $testValue);
202  }
203 }
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest\createInline1nInlineElement
‪createInline1nInlineElement(BackendTester $I)
Definition: Inline1nCest.php:84
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest\checkIfExpandsAndCollapseShowInput
‪checkIfExpandsAndCollapseShowInput(BackendTester $I)
Definition: Inline1nCest.php:55
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest\checkIfCanSortingInlineElement
‪checkIfCanSortingInlineElement(BackendTester $I)
Definition: Inline1nCest.php:112
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest\changeInline1nInlineInput
‪changeInline1nInlineInput(BackendTester $I)
Definition: Inline1nCest.php:134
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest\fillFieldByLabel
‪fillFieldByLabel(BackendTester $I, $fieldLabel, $testValue)
Definition: Inline1nCest.php:177
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest\deleteInline1nInlineElement
‪deleteInline1nInlineElement(BackendTester $I, ModalDialog $modalDialog)
Definition: Inline1nCest.php:150
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest
Definition: Inline1nCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester
Definition: BackendTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest\hideAndUnhideInline1nInlineElement
‪hideAndUnhideInline1nInlineElement(BackendTester $I)
Definition: Inline1nCest.php:70
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\Inline1nCest\_before
‪_before(BackendTester $I, PageTree $pageTree)
Definition: Inline1nCest.php:37
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine
Definition: AbstractElementsBasicCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:27