‪TYPO3CMS  10.4
FalMetadataCest.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 
22 
27 {
34  public function ‪_before(‪BackendTester $I, ‪PageTree $pageTree)
35  {
36  $I->useExistingSession('admin');
37  $this->‪goToPageModule($I, $pageTree);
38  }
39 
53  {
54  $I->amGoingTo('Create new CE with image');
55  $I->click('.t3js-page-new-ce a');
56  $I->switchToMainFrame();
57  $I->waitForElement('.t3js-modal.in');
58  $I->wait(3);
59  $I->waitForElementNotVisible('div#nprogess');
60  $I->click('Text & Images');
61  $I->switchToContentFrame();
62  $I->waitForText('Create new Page Content on page');
63  $I->fillField('//input[contains(@data-formengine-input-name, "data[tt_content]") and contains(@data-formengine-input-name, "[header]")]', 'tt_content with image');
64 
65  $I->click('Images');
66  $I->click('Add image');
67  $I->switchToWindow();
68  $I->switchToIFrame('modal_frame');
69  $I->click('.list-tree-control-closed');
70  $I->click('styleguide');
71  $I->click('bus_lane.jpg');
72  $I->switchToWindow();
73  $I->switchToContentFrame();
74  $I->waitForText('bus_lane.jpg');
75 
76  $I->see('Set element specific value (No default)', '.t3js-form-field-eval-null-placeholder-checkbox');
77 
78  $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => '', 'value' => '']);
79  $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => '', 'value' => '']);
80  $I->seeElementInDOM('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', ['placeholder' => '']);
81  //textarea value is not in the attribute, so we need to check it separately
82  $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
83 
84  $I->click('button[name="_savedok"]');
85  $I->wait(3);
86  $I->click('a[title="Close"]');
87 
88  $I->amGoingTo('Change default metadata');
89  $I->switchToMainFrame();
90  $I->click('Filelist');
91  $I->switchToIFrame('nav_frame');
92  $I->waitForText('fileadmin/ (auto-created)');
93  $I->click('styleguide');
94 
95  $I->switchToWindow();
96  $I->switchToContentFrame();
97  $I->click('bus_lane.jpg');
98  $I->waitForText('Edit File Metadata "bus_lane.jpg" on root level');
99  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[title]")]', 'Test title');
100  $I->fillField('//textarea[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[description]")]', 'Test description');
101  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[alternative]")]', 'Test alternative');
102 
103  $I->click('button[name="_savedok"]');
104  $I->wait(3);
105  $I->click('a[title="Close"]');
106 
107  $I->amGoingTo('Check metadata of sys_file_reference displayed in tt_content');
108  $this->‪goToPageModule($I, $pageTree);
109  $I->switchToWindow();
110  $I->switchToContentFrame();
111  $I->click('tt_content with image');
112  $I->waitForElementNotVisible('#t3js-ui-block');
113  $I->waitForText('Edit Page Content "tt_content with image" on page "styleguide TCA demo"');
114  $I->click('Images');
115  $I->click('.form-irre-header');
116 
117  $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
118  $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
119  $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
120 
121  $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => 'Test title', 'value' => '']);
122  $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => 'Test alternative', 'value' => '']);
123  $I->seeElementInDOM('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', ['placeholder' => 'Test description']);
124  //textarea value is not in the attribute, so we need to check it separately
125  $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
126  }
127 
145  {
146  $I->amGoingTo('Create new CE with image with filled metadata');
147  $I->click('.t3js-page-new-ce a');
148  $I->switchToMainFrame();
149  $I->waitForElement('.t3js-modal.in');
150  $I->wait(3);
151  $I->waitForElementNotVisible('div#nprogess');
152  $I->click('Text & Images');
153  $I->switchToContentFrame();
154  $I->waitForText('Create new Page Content on page');
155  $I->fillField('//input[contains(@data-formengine-input-name, "data[tt_content]") and contains(@data-formengine-input-name, "[header]")]', 'tt_content with image with filled metadata');
156 
157  $I->click('Images');
158  $I->click('Add image');
159  $I->switchToWindow();
160  $I->switchToIFrame('modal_frame');
161  $I->click('.list-tree-control-closed');
162  $I->click('styleguide');
163  $I->click('bus_lane.jpg');
164  $I->switchToWindow();
165  $I->switchToContentFrame();
166  $I->waitForText('bus_lane.jpg');
167 
168  $I->waitForText('Image Metadata');
169 
170  $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', '');
171  $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', '');
172  $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
173 
174  $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
175  $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
176  $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
177 
178  $I->amGoingTo('assert checkboxes are not checked');
179  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[title]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
180  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[alternative]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
181  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[description]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
182 
183  $I->amGoingTo('Assert hidden control field value (default value which is used when checkbox is not checked)');
184  $I->seeInField('//input[contains(@name, "[title]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', '0');
185  $I->seeInField('//input[contains(@name, "[alternative]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', '0');
186  $I->seeInField('//input[contains(@name, "[description]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', '0');
187 
188  //when checkbox is unchecked the disabled input is shown
189  //<input type="text" class="form-control" disabled="disabled" value="Test title">
190  $I->seeInField('input.form-control:disabled', 'Test title');
191  $I->seeInField('input.form-control:disabled', 'Test alternative');
192  $I->seeInField('textarea.form-control:disabled', 'Test description');
193  }
194 
204  {
205  $I->amGoingTo('Check if deactivating null checkboxes focuses text fields');
206  $this->‪goToPageModule($I, $pageTree);
207  $I->switchToWindow();
208  $I->switchToContentFrame();
209  $I->click('tt_content with image');
210  $I->waitForElementNotVisible('#t3js-ui-block');
211  $I->waitForText('Edit Page Content "tt_content with image" on page "styleguide TCA demo"');
212  $I->click('Images');
213  $I->click('.form-irre-header');
214 
215  $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
216  $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
217  $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
218 
219  $I->amGoingTo('assert checkboxes are not checked');
220  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[title]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
221  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[alternative]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
222  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[description]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
223 
224  $I->seeInField('input.form-control:disabled', 'Test title');
225  $I->seeInField('input.form-control:disabled', 'Test alternative');
226  $I->seeInField('textarea.form-control:disabled', 'Test description');
227 
228  $I->amGoingTo('enable checkboxes and see whether fields are focused');
229  foreach (['title', 'alternative', 'description'] as $fieldName) {
230  $I->checkOption('//input[contains(@name, "[' . $fieldName . ']") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
231  $focus = $I->executeJS('let referenceUid = document.querySelector(\'[data-object-uid]\').dataset.objectUid; return document.querySelector(\'[data-formengine-input-name="data[sys_file_reference][\' + referenceUid + \'][' . $fieldName . ']"]\').matches(\':focus\')');
232  $I->assertEquals(true, $focus);
233 
234  // Remove focus from field, otherwise codeception can't find other checkboxes
235  $I->click('.form-irre-object .form-section');
236  }
237  }
238 
245  private function ‪goToPageModule(‪BackendTester $I, ‪PageTree $pageTree)
246  {
247  $I->switchToMainFrame();
248  $I->click('Page');
249  $I->waitForElement('svg .nodes .node');
250  $pageTree->openPath(['styleguide TCA demo']);
251  $I->switchToContentFrame();
252  $I->waitForText('styleguide TCA demo');
253  }
254 }
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\FalMetadataCest\_before
‪_before(BackendTester $I, PageTree $pageTree)
Definition: FalMetadataCest.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\FalMetadataCest\checkIfUpdatedFileMetadataIsUpdatedInContent
‪checkIfUpdatedFileMetadataIsUpdatedInContent(BackendTester $I, PageTree $pageTree)
Definition: FalMetadataCest.php:52
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\FalMetadataCest
Definition: FalMetadataCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\FalMetadataCest\goToPageModule
‪goToPageModule(BackendTester $I, PageTree $pageTree)
Definition: FalMetadataCest.php:245
‪TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester
Definition: BackendTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\FalMetadataCest\checkIfFileMetadataIsInheritedInContent
‪checkIfFileMetadataIsInheritedInContent(BackendTester $I)
Definition: FalMetadataCest.php:144
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine\FalMetadataCest\checkIfDeactivatingNullCheckboxesFocusesTextFields
‪checkIfDeactivatingNullCheckboxesFocusesTextFields(BackendTester $I, PageTree $pageTree)
Definition: FalMetadataCest.php:203
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine
Definition: AbstractElementsBasicCest.php:18