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