‪TYPO3CMS  11.5
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(‪ApplicationTester $I, ‪PageTree $pageTree): void
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[aria-label="Edit record"]';
48  $I->click($editRecordLinkCssPath);
49  $I->waitForText('Edit Form', 3, 'h1');
50  }
51 
53  {
54  $I->wantTo('Expands the inline Element');
55  $I->click('div[data-bs-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
56  $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]');
57  $I->wantTo('check is the value in input');
58  $I->seeInField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]', 'lipsum');
59  $I->wantTo('Collapse the inline Element');
60  $I->click('div[data-bs-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
61  $I->waitForElementNotVisible('[data-field-name^="[tx_styleguide_inline_1n_child]["] .panel');
62  }
63 
65  {
66  $I->wantTo('Can hide an Inline Element');
67  $I->click('button span[data-identifier="actions-edit-hide"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
68  $I->waitForElement('[data-field-name^="[tx_styleguide_inline_1n_child]["].t3-form-field-container-inline-hidden');
69  $I->waitForElement('[data-field-name^="[tx_styleguide_inline_1n_child]["] button span[data-identifier="actions-edit-unhide"]');
70  $I->wantTo('Can unhide an Inline Element');
71  $I->click('button span[data-identifier="actions-edit-unhide"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
72  $I->waitForElementNotVisible('[data-field-name^="[tx_styleguide_inline_1n_child]["].t3-form-field-container-inline-hidden', 2);
73  }
74 
76  {
77  $I->click('span[data-identifier="actions-add"]', 'div.typo3-newRecordLink');
78 
79  $fieldLabel = 'input_1';
80  $testValue = 'Fo Bar';
81  $I->wait(2);
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"] .icon-actions-view-list-collapse\').click();');
91  $I->wait(1);
92  $I->executeJS('$(\'a[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-collapse\').click();');
93  $I->wait(1);
94 
95  $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(3) > a');
96  $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(3) > a');
97 
98  $I->executeJS('$(\'a[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-expand\').click();');
99  $I->wait(1);
100  $I->executeJS('$(\'a[data-table="pages"] .icon-actions-view-list-expand\').click();');
101  $I->wait(1);
102  }
103 
108  {
109  $I->wantTo('Can sort an Inline Element');
110  $I->click('button span[data-identifier="actions-move-down"]', '[data-field-name^="[tx_styleguide_inline_1n_child]["]');
111  $I->click('button[name="_savedok"]');
112  $I->wait(3);
113  $I->click('a[title="Close"]');
114  $I->wait(3);
115 
116  $I->executeJS('$(\'a[data-table="pages"] .icon-actions-view-list-collapse\').click();');
117  $I->wait(1);
118  $I->executeJS('$(\'a[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-collapse\').click();');
119  $I->wait(1);
120 
121  $I->wantTo('Check new sorting');
122  $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(3) > a');
123  $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(3) > a');
124 
125  $I->executeJS('$(\'a[data-table="tx_styleguide_inline_1n"] .icon-actions-view-list-expand\').click();');
126  $I->wait(1);
127  $I->executeJS('$(\'a[data-table="pages"] .icon-actions-view-list-expand\').click();');
128  $I->wait(1);
129  }
130 
132  {
133  $I->click('div[data-bs-toggle="formengine-inline"]', '[data-field-name^="[tx_styleguide_inline_1n_child][1"]');
134  $I->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]');
135  $I->fillField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]', 'hello world');
136  $I->click('button[name="_savedok"]');
137  $I->wait(3);
138  $I->click('a[title="Close"]');
139  $I->wait(3);
140  $I->see('hello world');
141  }
142 
144  {
145  $inlineElementToDelete = '[data-field-name^="[tx_styleguide_inline_1n_child][1"]';
146  $I->wantTo('Cancel the delete dialog');
147  $I->click('button span[data-identifier="actions-edit-delete"]', $inlineElementToDelete);
148  $modalDialog->‪clickButtonInDialog('button[name="no"]');
149  // switch form Dialogbox back to IFrame
150  $I->switchToContentFrame();
151  $I->seeElement($inlineElementToDelete);
152 
153  $I->wantTo('Accept the delete dialog');
154  $I->click('button span[data-identifier="actions-edit-delete"]', $inlineElementToDelete);
155 
156  // don't use $modalDialog->clickButtonInDialog due to too low timeout
157  $modalDialog->‪canSeeDialog();
158  $I->click('button[name="yes"]', ‪ModalDialog::$openedModalButtonContainerSelector);
159  $I->waitForElementNotVisible(‪ModalDialog::$openedModalSelector, 30);
160  // switch form Dialogbox back to IFrame
161  $I->switchToContentFrame();
162  $I->waitForElementNotVisible($inlineElementToDelete);
163  }
164 
165  protected function ‪fillFieldByLabel(‪ApplicationTester $I, $fieldLabel, $testValue): void
166  {
167  $fieldContext = $I->executeInSelenium(static function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
168  $fieldLabel
169  ) {
170  return $webdriver->findElement(
171  \Facebook\WebDriver\WebDriverBy::xpath('(//label[contains(text(),"' . $fieldLabel . '")])[1]/ancestor::fieldset[@class="form-section"][1]')
172  );
173  });
174 
175  $visibleFieldXpath = './/*/input[@data-formengine-input-name]';
176  $clearButtonXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/button[@class="close"]';
177  $initializedInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@data-formengine-input-name][@data-formengine-input-initialized]';
178  $I->waitForElement($initializedInputFieldXpath, 30);
179  $inputField = $fieldContext->findElement(\Facebook\WebDriver\WebDriverBy::xpath($visibleFieldXpath));
180  $internalInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]';
181 
182  $I->waitForElement($internalInputFieldXpath, 30);
183  $I->waitForElement($clearButtonXpath, 30);
184 
185  $I->fillField($inputField, $testValue);
186  $inputField->sendKeys(WebDriverKeys::TAB);
187  $fieldContext->click();
188  $I->comment('Test value of "visible" field');
189  $I->canSeeInField($inputField, $testValue);
190  }
191 }
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\$openedModalSelector
‪static string $openedModalSelector
Definition: ModalDialog.php:33
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\checkIfExpandsAndCollapseShowInput
‪checkIfExpandsAndCollapseShowInput(ApplicationTester $I)
Definition: Inline1nCest.php:52
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine
Definition: AbstractElementsBasicCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\$openedModalButtonContainerSelector
‪static string $openedModalButtonContainerSelector
Definition: ModalDialog.php:40
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest
Definition: Inline1nCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\openPath
‪openPath(array $path)
Definition: PageTree.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\deleteInline1nInlineElement
‪deleteInline1nInlineElement(ApplicationTester $I, ModalDialog $modalDialog)
Definition: Inline1nCest.php:143
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\canSeeDialog
‪canSeeDialog()
Definition: ModalDialog.php:73
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\createInline1nInlineElement
‪createInline1nInlineElement(ApplicationTester $I)
Definition: Inline1nCest.php:75
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\checkIfCanSortingInlineElement
‪checkIfCanSortingInlineElement(ApplicationTester $I)
Definition: Inline1nCest.php:107
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\clickButtonInDialog
‪clickButtonInDialog(string $buttonLinkLocator)
Definition: ModalDialog.php:62
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\fillFieldByLabel
‪fillFieldByLabel(ApplicationTester $I, $fieldLabel, $testValue)
Definition: Inline1nCest.php:165
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\changeInline1nInlineInput
‪changeInline1nInlineInput(ApplicationTester $I)
Definition: Inline1nCest.php:131
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\hideAndUnhideInline1nInlineElement
‪hideAndUnhideInline1nInlineElement(ApplicationTester $I)
Definition: Inline1nCest.php:64
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\Inline1nCest\_before
‪_before(ApplicationTester $I, PageTree $pageTree)
Definition: Inline1nCest.php:37