TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Inline1nCest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
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;
22 
27 {
28  public function _before(Admin $I, PageTree $pageTree)
29  {
30  $I->useExistingSession();
31  // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
32  $I->switchToIFrame('list_frame');
33  $I->waitForText('Web Content Management System');
34  $I->switchToIFrame();
35 
36  $I->click('List');
37  $pageTree->openPath(['styleguide TCA demo', 'inline 1n']);
38  $I->switchToIFrame('list_frame');
39 
40  $editRecordLinkCssPath = '#recordlist-tx_styleguide_inline_1n a[data-original-title="Edit record"]';
41  $I->waitForElement($editRecordLinkCssPath, 30);
42  $I->click($editRecordLinkCssPath);
43  $I->waitForText('Edit Form', 3, 'h1');
44  }
45 
50  {
51  $I->wantTo('Expands the inline Elemnet');
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->waitForElement('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]');
54  $I->wantTo('check is the value in input');
55  $I->seeInField('input[data-formengine-input-name="data[tx_styleguide_inline_1n_child][1][input_1]"]', 'lipsum');
56  $I->wantTo('Collapse the inline Elemnet');
57  $I->click('div[data-toggle="formengine-inline"]', '#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_div');
58  $I->waitForElementNotVisible('#data-12-tx_styleguide_inline_1n-1-inline_1-tx_styleguide_inline_1n_child-1_fields.panel-collapse');
59  }
60 
65  {
66  $I->wantTo('Can hide a Inline Element');
67  $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');
68  $I->waitForElement('#data-12-tx_styleguide_inline_1n-1-inline_1_records .t3-form-field-container-inline-hidden');
69  $I->wantTo('Can unhide a Inline Element');
70  $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');
71  $I->waitForElementNotVisible('#data-12-tx_styleguide_inline_1n-1-inline_1_records .t3-form-field-container-inline-hidden', 2);
72  }
73 
78  public function createInline1nInlineElement(Admin $I, Formhandler $formhandler)
79  {
80  $I->click('span[data-identifier="actions-document-new"]', 'div.typo3-newRecordLink');
81 
82  $fieldLabel = 'input_1';
83  $testValue = 'Fo Bar';
84 
85  $this->fillFieldByLable($I, $fieldLabel, $testValue);
86 
87  $I->click('button[name="_savedok"]');
88  $I->wait(3);
89  $I->click('a[title="Close"]');
90  $I->wait(3);
91 
92  $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');
93  $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');
94  }
95 
101  {
102  $I->wantTo('Can sort an Inline Element');
103  $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');
104  $I->click('button[name="_savedok"]');
105  $I->wait(3);
106  $I->click('a[title="Close"]');
107  $I->wait(3);
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 
117  public function changeInline1nInlineInput(Admin $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 
133  public function deleteInline1nInlineElement(Admin $I, ModalDialog $modalDialog)
134  {
135  $inlineElmentToDelete = '#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"]', $inlineElmentToDelete);
138  $modalDialog->clickButtonInDialog('button[name="no"]');
139  // switch form Dialogbox back to IFrame
140  $I->switchToIFrame('list_frame');
141  $I->seeElement($inlineElmentToDelete);
142 
143  $I->wantTo('Accept the delete dialog');
144  $I->click('a span[data-identifier="actions-edit-delete"]', $inlineElmentToDelete);
145  $modalDialog->clickButtonInDialog('button[name="yes"]');
146  // switch form Dialogbox back to IFrame
147  $I->switchToIFrame('list_frame');
148  $I->waitForElementNotVisible($inlineElmentToDelete);
149  }
150 
156  protected function fillFieldByLable(Admin $I, $fieldLabel, $testValue)
157  {
158  $fieldContext = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
159  $fieldLabel
160  ) {
161  return $webdriver->findElement(
162  \Facebook\WebDriver\WebDriverBy::xpath('(//label[contains(text(),"' . $fieldLabel . '")])[1]/ancestor::fieldset[@class="form-section"][1]')
163  );
164  });
165 
166  $visibleFieldXpath = './/*/input[@data-formengine-input-name]';
167  $clearButtonXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/button[@class="close"]';
168  $initializedInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@data-formengine-input-name][@data-formengine-input-initialized]';
169  $I->waitForElement($initializedInputFieldXpath, 30);
170  $inputField = $fieldContext->findElement(\WebDriverBy::xpath($visibleFieldXpath));
171  $internalInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]';
172 
173  $I->waitForElement($internalInputFieldXpath, 30);
174  $I->waitForElement($clearButtonXpath, 30);
175 
176  $I->fillField($inputField, $testValue);
177  $inputField->sendKeys(WebDriverKeys::TAB);
178  $fieldContext->click();
179  $I->comment('Test value of "visible" field');
180  $I->canSeeInField($inputField, $testValue);
181  }
182 }
createInline1nInlineElement(Admin $I, Formhandler $formhandler)
deleteInline1nInlineElement(Admin $I, ModalDialog $modalDialog)