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