‪TYPO3CMS  11.5
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 
23 
28 {
35  public function ‪_before(‪ApplicationTester $I, ‪PageTree $pageTree): void
36  {
37  $I->useExistingSession('admin');
38  $this->‪goToPageModule($I, $pageTree);
39  }
40 
55  {
56  $I->amGoingTo('Create new CE with image');
57  $I->wait(1);
58  $I->click('.t3js-page-new-ce button');
59  $I->wait(1);
60  $I->switchToMainFrame();
61  $I->waitForElement('.t3js-modal.show');
62  $I->wait(3);
63  $I->waitForElementNotVisible('div#nprogess');
64  $I->click('Text & Images');
65  $I->switchToContentFrame();
66  $I->waitForText('Create new Page Content on page');
67  $I->fillField('//input[contains(@data-formengine-input-name, "data[tt_content]") and contains(@data-formengine-input-name, "[header]")]', 'tt_content with image');
68 
69  $I->click('Images');
70  $I->click('Add image');
71  $I->switchToWindow();
72  $I->wait(2);
73  $I->switchToIFrame('modal_frame');
74  $I->waitForElement('.svg-tree-wrapper .nodes .node', 5);
75  $I->click('.node[title="styleguide"]');
76  $I->waitForText('fileadmin: /styleguide/', 5);
77  $I->click('bus_lane.jpg');
78  $I->switchToWindow();
79  $I->switchToContentFrame();
80  $I->waitForText('bus_lane.jpg');
81 
82  $I->see('Set element specific value (No default)', '.t3js-form-field-eval-null-placeholder-checkbox');
83 
84  $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => '', 'value' => '']);
85  $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => '', 'value' => '']);
86  $I->seeElementInDOM('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', ['placeholder' => '']);
87  //textarea value is not in the attribute, so we need to check it separately
88  $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
89 
90  $I->click('button[name="_savedok"]');
91  $I->wait(3);
92  $I->click('a[title="Close"]');
93 
94  $I->amGoingTo('Change default metadata');
95  $I->switchToMainFrame();
96  $I->click('Filelist');
97  $I->waitForText('fileadmin');
98  $fileTree->openPath(['styleguide']);
99 
100  $I->switchToContentFrame();
101  $I->see('styleguide', 'h1');
102  $I->click('bus_lane.jpg');
103  $I->waitForText('Edit File Metadata "bus_lane.jpg" on root level');
104  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[title]")]', 'Test title');
105  $I->fillField('//textarea[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[description]")]', 'Test description');
106  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[alternative]")]', 'Test alternative');
107 
108  $I->click('button[name="_savedok"]');
109  $I->wait(3);
110  $I->click('a[title="Close"]');
111 
112  $I->amGoingTo('Check metadata of sys_file_reference displayed in tt_content');
113  $this->‪goToPageModule($I, $pageTree);
114  $I->switchToWindow();
115  $I->switchToContentFrame();
116  $I->click('tt_content with image');
117  $I->waitForElementNotVisible('#t3js-ui-block');
118  $I->waitForText('Edit Page Content "tt_content with image" on page "styleguide TCA demo"');
119  $I->click('Images');
120  if (count($I->grabMultiple('.panel-collapsed .form-irre-header')) > 0) {
121  $I->click('.panel-collapsed .form-irre-header');
122  }
123  $I->waitForElement('.t3js-form-field-eval-null-placeholder-checkbox');
124 
125  $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
126  $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
127  $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
128 
129  $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => 'Test title', 'value' => '']);
130  $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => 'Test alternative', 'value' => '']);
131  $I->seeElementInDOM('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', ['placeholder' => 'Test description']);
132  //textarea value is not in the attribute, so we need to check it separately
133  $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
134  }
135 
153  {
154  $I->amGoingTo('Create new CE with image with filled metadata');
155  $I->wait(1);
156  $I->click('.t3js-page-new-ce button');
157  $I->switchToMainFrame();
158  $I->waitForElement('.t3js-modal.show');
159  $I->wait(3);
160  $I->waitForElementNotVisible('div#nprogess');
161  $I->click('Text & Images');
162  $I->switchToContentFrame();
163  $I->waitForText('Create new Page Content on page');
164  $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');
165 
166  $I->click('Images');
167  $I->click('Add image');
168  $I->switchToWindow();
169  $I->wait(2);
170  $I->switchToIFrame('modal_frame');
171  $I->waitForElement('.svg-tree-wrapper .nodes .node', 5);
172  $I->click('.node[title="styleguide"]');
173  $I->waitForText('fileadmin: /styleguide/', 5);
174  $I->click('bus_lane.jpg');
175  $I->switchToWindow();
176  $I->switchToContentFrame();
177  $I->waitForText('bus_lane.jpg');
178 
179  $I->waitForText('Image Metadata');
180 
181  $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', '');
182  $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', '');
183  $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
184 
185  $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
186  $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
187  $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
188 
189  $I->amGoingTo('assert checkboxes are not checked');
190  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[title]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
191  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[alternative]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
192  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[description]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
193 
194  $I->amGoingTo('Assert hidden control field value (default value which is used when checkbox is not checked)');
195  $I->seeInField('//input[contains(@name, "[title]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', '0');
196  $I->seeInField('//input[contains(@name, "[alternative]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', '0');
197  $I->seeInField('//input[contains(@name, "[description]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', '0');
198 
199  //when checkbox is unchecked the disabled input is shown
200  //<input type="text" class="form-control" disabled="disabled" value="Test title">
201  $I->seeInField('input.form-control:disabled', 'Test title');
202  $I->seeInField('input.form-control:disabled', 'Test alternative');
203  $I->seeInField('textarea.form-control:disabled', 'Test description');
204  }
205 
215  {
216  $I->amGoingTo('Check if deactivating null checkboxes focuses text fields');
217  $this->‪goToPageModule($I, $pageTree);
218  $I->switchToWindow();
219  $I->switchToContentFrame();
220  $I->click('tt_content with image');
221  $I->waitForElementNotVisible('#t3js-ui-block');
222  $I->waitForText('Edit Page Content "tt_content with image" on page "styleguide TCA demo"');
223  $I->click('Images');
224  if (count($I->grabMultiple('.panel-collapsed .form-irre-header')) > 0) {
225  $I->click('.panel-collapsed .form-irre-header');
226  }
227  $I->waitForElement('.t3js-form-field-eval-null-placeholder-checkbox');
228 
229  $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
230  $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
231  $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
232 
233  $I->amGoingTo('assert checkboxes are not checked');
234  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[title]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
235  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[alternative]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
236  $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[description]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
237 
238  $I->seeInField('input.form-control:disabled', 'Test title');
239  $I->seeInField('input.form-control:disabled', 'Test alternative');
240  $I->seeInField('textarea.form-control:disabled', 'Test description');
241 
242  $I->amGoingTo('enable checkboxes and see whether fields are focused');
243  foreach (['title', 'alternative', 'description'] as $fieldName) {
244  $I->checkOption('//input[contains(@name, "[' . $fieldName . ']") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
245  $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\')');
246  $I->assertEquals(true, $focus);
247 
248  // Remove focus from field, otherwise codeception can't find other checkboxes
249  $I->click('.form-irre-object .form-section');
250  }
251  }
252 
259  private function ‪goToPageModule(‪ApplicationTester $I, ‪PageTree $pageTree): void
260  {
261  $I->switchToMainFrame();
262  $I->click('Page');
263  $I->waitForElement('svg .nodes .node');
264  $pageTree->‪openPath(['styleguide TCA demo']);
265  $I->switchToContentFrame();
266  $I->waitForText('styleguide TCA demo');
267  }
268 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\FalMetadataCest\checkIfUpdatedFileMetadataIsUpdatedInContent
‪checkIfUpdatedFileMetadataIsUpdatedInContent(ApplicationTester $I, PageTree $pageTree, FileTree $fileTree)
Definition: FalMetadataCest.php:54
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\FalMetadataCest
Definition: FalMetadataCest.php:28
‪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\PageTree\openPath
‪openPath(array $path)
Definition: PageTree.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\FileTree
Definition: FileTree.php:24
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\FalMetadataCest\_before
‪_before(ApplicationTester $I, PageTree $pageTree)
Definition: FalMetadataCest.php:35
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\FalMetadataCest\goToPageModule
‪goToPageModule(ApplicationTester $I, PageTree $pageTree)
Definition: FalMetadataCest.php:259
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\FalMetadataCest\checkIfFileMetadataIsInheritedInContent
‪checkIfFileMetadataIsInheritedInContent(ApplicationTester $I)
Definition: FalMetadataCest.php:152
‪TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine\FalMetadataCest\checkIfDeactivatingNullCheckboxesFocusesTextFields
‪checkIfDeactivatingNullCheckboxesFocusesTextFields(ApplicationTester $I, PageTree $pageTree)
Definition: FalMetadataCest.php:214
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31