‪TYPO3CMS  ‪main
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 
28 final class ‪Inline1nCest
29 {
33  public function ‪_before(‪ApplicationTester $I, ‪PageTree $pageTree): void
34  {
35  $I->useExistingSession('admin');
36 
37  $I->click('List');
38  $pageTree->‪openPath(['styleguide TCA demo', 'inline 1n']);
39  $I->switchToContentFrame();
40 
41  $I->waitForText('inline 1n', 20);
42  $editRecordLinkCssPath = '#recordlist-tx_styleguide_inline_1n a[aria-label="Edit record"]';
43  $I->click($editRecordLinkCssPath);
44  $I->waitForText('Edit Form', 3, 'h1');
45  }
46 
48  {
49  $I->wantTo('Expands the inline Element');
50  $I->click('div[data-bs-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["]');
51  $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_inline_1_child][1][input_1]"]');
52  $I->wantTo('check is the value in input');
53  $I->seeInField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_inline_1_child][1][input_1]"]', 'lipsum');
54  $I->wantTo('Collapse the inline Element');
55  $I->click('div[data-bs-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["]');
56  $I->waitForElementNotVisible('[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["] .panel');
57  }
58 
60  {
61  $I->wantTo('Can hide an Inline Element');
62  $I->click('button span[data-identifier="actions-edit-hide"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["]');
63  $I->waitForElement('[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["].t3-form-field-container-inline-hidden');
64  $I->waitForElement('[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["] button span[data-identifier="actions-edit-unhide"]');
65  $I->wantTo('Can unhide an Inline Element');
66  $I->click('button span[data-identifier="actions-edit-unhide"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["]');
67  $I->waitForElementNotVisible('[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["].t3-form-field-container-inline-hidden', 2);
68  }
69 
71  {
72  $I->click('span[data-identifier="actions-plus"]', 'div.typo3-newRecordLink');
73 
74  $fieldLabel = 'input_1';
75  $testValue = 'Fo Bar';
76  $I->wait(2);
77 
78  $this->‪fillFieldByLabel($I, $fieldLabel, $testValue);
79 
80  $I->click('button[name="_savedok"]');
81  $I->wait(3);
82  $I->click('a[title="Close"]');
83  $I->wait(3);
84 
85  $I->click('button[data-table="pages_translated"] .icon-actions-view-list-collapse');
86  $I->wait(1);
87  $I->click('button[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-collapse');
88  $I->wait(1);
89 
90  $I->see('lipsum', '#recordlist-tx_styleguide_inline_1n_inline_1_child > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3) > a');
91  $I->see('Fo Bar', '#recordlist-tx_styleguide_inline_1n_inline_1_child > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(4) > td:nth-child(3) > a');
92 
93  $I->click('button[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-expand');
94  $I->wait(1);
95  $I->click('button[data-table="pages_translated"] .icon-actions-view-list-expand');
96  $I->wait(1);
97  }
98 
103  {
104  $I->wantTo('Can sort an Inline Element');
105  $I->click('button span[data-identifier="actions-move-down"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_1_child]["]');
106  $I->click('button[name="_savedok"]');
107  $I->wait(3);
108  $I->click('a[title="Close"]');
109  $I->wait(3);
110 
111  $I->click('button[data-table="pages_translated"] .icon-actions-view-list-collapse');
112  $I->wait(1);
113  $I->click('button[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-collapse');
114  $I->wait(1);
115 
116  $I->wantTo('Check new sorting');
117  $I->see('Fo Bar', '#recordlist-tx_styleguide_inline_1n_inline_1_child > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3) > a');
118  $I->see('lipsum', '#recordlist-tx_styleguide_inline_1n_inline_1_child > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(3) > a');
119 
120  $I->click('button[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-expand');
121  $I->wait(1);
122  $I->click('button[data-table="pages_translated"] .icon-actions-view-list-expand');
123  $I->wait(1);
124  }
125 
127  {
128  $I->click('div[data-bs-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_1_child][1"]');
129  $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_inline_1_child][1][input_1]"]');
130  $I->fillField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_inline_1_child][1][input_1]"]', 'hello world');
131  $I->click('button[name="_savedok"]');
132  $I->wait(3);
133  $I->click('a[title="Close"]');
134  $I->wait(3);
135  $I->see('hello world');
136  }
137 
139  {
140  $inlineElementToDelete = '[data-field-name^="[tx_styleguide_inline_1n_inline_1_child][1"]';
141  $I->wantTo('Cancel the delete dialog');
142  $I->click('button span[data-identifier="actions-edit-delete"]', $inlineElementToDelete);
143  $modalDialog->‪clickButtonInDialog('button[name="no"]');
144  // switch form Dialogbox back to IFrame
145  $I->switchToContentFrame();
146  $I->seeElement($inlineElementToDelete);
147 
148  $I->wantTo('Accept the delete dialog');
149  $I->click('button span[data-identifier="actions-edit-delete"]', $inlineElementToDelete);
150 
151  // don't use $modalDialog->clickButtonInDialog due to too low timeout
152  $modalDialog->‪canSeeDialog();
153  $I->click('button[name="yes"]', ‪ModalDialog::$openedModalButtonContainerSelector);
154  $I->waitForElementNotVisible(‪ModalDialog::$openedModalSelector, 30);
155  // switch form Dialogbox back to IFrame
156  $I->switchToContentFrame();
157  $I->waitForElementNotVisible($inlineElementToDelete);
158  }
159 
161  {
162  $I->wantTo('Disable an Inline Element which has no checkbox for disabled state');
163 
164  // Switch to "inline_2" tab.
165  $I->click('inline_2');
166 
167  // Open the inline element.
168  $I->click('div[data-bs-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_2_child]["]');
169  $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_inline_2_child][1][input_1]"]');
170 
171  // Hide the inline element.
172  $I->click('button span[data-identifier="actions-edit-hide"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_2_child]["]');
173  $I->waitForElement('[data-field-name^="[tx_styleguide_inline_1n_inline_2_child]["].t3-form-field-container-inline-hidden');
174  $I->waitForElement('[data-field-name^="[tx_styleguide_inline_1n_inline_2_child]["] button span[data-identifier="actions-edit-unhide"]');
175 
176  // Save the inline element.
177  $I->click('button[name="_savedok"]');
178  $I->wait(3);
179 
180  // Unhide the previously hidden inline element.
181  $I->click('button span[data-identifier="actions-edit-unhide"]', '[data-field-name^="[tx_styleguide_inline_1n_inline_2_child]["]');
182  $I->waitForElementNotVisible('[data-field-name^="[tx_styleguide_inline_1n_inline_2_child]["].t3-form-field-container-inline-hidden', 2);
183  }
184 
185  private function ‪fillFieldByLabel(‪ApplicationTester $I, $fieldLabel, $testValue): void
186  {
187  $fieldContext = $I->executeInSelenium(static function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
188  $fieldLabel
189  ) {
190  return $webdriver->findElement(
191  \Facebook\WebDriver\WebDriverBy::xpath('(//label[contains(text(),"' . $fieldLabel . '")])[1]/ancestor::fieldset[@class="form-section"][1]')
192  );
193  });
194 
195  $visibleFieldXpath = './/*/input[@data-formengine-input-name]';
196  $clearButtonXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/button[@class="close"]';
197  $initializedInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@data-formengine-input-name][@data-formengine-input-initialized]';
198  $I->waitForElement($initializedInputFieldXpath, 30);
199  $inputField = $fieldContext->findElement(\Facebook\WebDriver\WebDriverBy::xpath($visibleFieldXpath));
200  $internalInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]';
201 
202  $I->waitForElement($internalInputFieldXpath, 30);
203  $I->waitForElement($clearButtonXpath, 30);
204 
205  $I->fillField($inputField, $testValue);
206  $inputField->sendKeys(WebDriverKeys::TAB);
207  $fieldContext->click();
208  $I->comment('Test value of "visible" field');
209  $I->canSeeInField($inputField, $testValue);
210  }
211 }
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\$openedModalSelector
‪static string $openedModalSelector
Definition: ModalDialog.php:30
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\checkIfExpandsAndCollapseShowInput
‪checkIfExpandsAndCollapseShowInput(ApplicationTester $I)
Definition: Inline1nCest.php:47
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine
Definition: AbstractElementsBasicCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\$openedModalButtonContainerSelector
‪static string $openedModalButtonContainerSelector
Definition: ModalDialog.php:37
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest
Definition: Inline1nCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\disableInline1nInlineElementWithoutRenderedDisableField
‪disableInline1nInlineElementWithoutRenderedDisableField(ApplicationTester $I)
Definition: Inline1nCest.php:160
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\AbstractTree\openPath
‪openPath(array $path)
Definition: AbstractTree.php:55
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\deleteInline1nInlineElement
‪deleteInline1nInlineElement(ApplicationTester $I, ModalDialog $modalDialog)
Definition: Inline1nCest.php:138
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\canSeeDialog
‪canSeeDialog()
Definition: ModalDialog.php:68
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\createInline1nInlineElement
‪createInline1nInlineElement(ApplicationTester $I)
Definition: Inline1nCest.php:70
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\checkIfCanSortingInlineElement
‪checkIfCanSortingInlineElement(ApplicationTester $I)
Definition: Inline1nCest.php:102
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\clickButtonInDialog
‪clickButtonInDialog(string $buttonLinkLocator)
Definition: ModalDialog.php:57
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\fillFieldByLabel
‪fillFieldByLabel(ApplicationTester $I, $fieldLabel, $testValue)
Definition: Inline1nCest.php:185
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\changeInline1nInlineInput
‪changeInline1nInlineInput(ApplicationTester $I)
Definition: Inline1nCest.php:126
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\hideAndUnhideInline1nInlineElement
‪hideAndUnhideInline1nInlineElement(ApplicationTester $I)
Definition: Inline1nCest.php:59
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:24
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\_before
‪_before(ApplicationTester $I, PageTree $pageTree)
Definition: Inline1nCest.php:33