ba2e0f6bdbe3193f3149cbae2373a46ca38e4305
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Formhandler / FalMetadataInheritanceCest.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
20 use TYPO3\TestingFramework\Core\Acceptance\Support\Page\PageTree;
21
22 /**
23 * Tests for inline 1n
24 */
25 class FalMetadataInheritanceCest
26 {
27 public function _before(Admin $I, PageTree $pageTree)
28 {
29 $I->useExistingSession();
30 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
31 $I->switchToIFrame('list_frame');
32 $I->waitForText('Web Content Management System');
33
34 $this->goToPageModule($I, $pageTree);
35 }
36
37 /**
38 * This scenario tests whether updated sys_file_metadata fields are propagated to sys_file_reference
39 * attached to tt_content
40 * - creates tt_content
41 * - attaches an image with empty metadata
42 * - modifies image metadata
43 * - checks if metadata is propagated to tt_content
44 *
45 * @param Admin $I
46 * @param PageTree $pageTree
47 * @throws \Exception
48 */
49 public function checkIfUpdatedFileMetadataIsUpdatedInContent(Admin $I, PageTree $pageTree)
50 {
51 $I->amGoingTo('Create new CE with image');
52 $I->click('.t3js-page-new-ce a');
53 $I->switchToIFrame();
54 $I->waitForElement('.t3js-modal.in');
55 $I->wait(3);
56 $I->waitForElementNotVisible('div#nprogess');
57 $I->click('Text & Images');
58 $I->switchToIFrame('list_frame');
59 $I->waitForText('Create new Page Content on page');
60 $I->fillField('//input[contains(@data-formengine-input-name, "data[tt_content]") and contains(@data-formengine-input-name, "[header]")]', 'tt_content with image');
61
62 $I->click('Images');
63 $I->click('Add image');
64 $I->switchToWindow();
65 $I->switchToIFrame('modal_frame');
66 $I->click('.list-tree-control-closed');
67 $I->click('styleguide');
68 $I->click('bus_lane.jpg');
69 $I->switchToWindow();
70 $I->switchToIFrame('list_frame');
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->switchToIFrame();
87 $I->click('Filelist');
88 $I->switchToIFrame('typo3-navigationContainerIframe');
89 $I->waitForText('fileadmin/ (auto-created)');
90 $I->click('styleguide');
91
92 $I->switchToWindow();
93 $I->switchToIFrame('list_frame');
94 $I->click('bus_lane.jpg');
95 $I->waitForText('Edit File Metadata "bus_lane.jpg" on root level');
96 $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[title]")]', 'Test title');
97 $I->fillField('//textarea[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[description]")]', 'Test description');
98 $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[alternative]")]', 'Test alternative');
99
100 $I->click('button[name="_savedok"]');
101 $I->wait(3);
102 $I->click('a[title="Close"]');
103
104 $I->amGoingTo('Check metadata of sys_file_reference displayed in tt_content');
105 $this->goToPageModule($I, $pageTree);
106 $I->switchToWindow();
107 $I->switchToIFrame('list_frame');
108 $I->click('tt_content with image');
109 $I->waitForElementNotVisible('#t3js-ui-block');
110 $I->waitForText('Edit Page Content "tt_content with image" on page "styleguide TCA demo"');
111 $I->click('Images');
112 $I->click('.form-irre-header');
113
114 $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
115 $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
116 $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
117
118 $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => 'Test title', 'value' => '']);
119 $I->seeElementInDOM('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => 'Test alternative', 'value' => '']);
120 $I->seeElementInDOM('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', ['placeholder' => 'Test description']);
121 //textarea value is not in the attribute, so we need to check it separately
122 $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
123 }
124
125 /**
126 * This scenario tests whether sys_file_metadata fields are propagated to sys_file_reference
127 * attached to tt_content
128 *
129 * - given a image with filled metadata (created in checkIfUpdatedFileMetadataIsUpdatedInContent test)
130 * - creates a new tt_content
131 * - attaches an image to tt_content
132 * - checks if metadata is propagated to tt_content
133 * - checks if checkboxes are unchecked and inputs are disabled
134 *
135 * test for https://forge.typo3.org/issues/81235
136 *
137 * @param Admin $I
138 * @param PageTree $pageTree
139 * @throws \Exception
140 * @depends checkIfUpdatedFileMetadataIsUpdatedInContent
141 */
142 public function checkIfFileMetadataIsInheritedInContent(Admin $I)
143 {
144 $I->amGoingTo('Create new CE with image with filled metadata');
145 $I->click('.t3js-page-new-ce a');
146 $I->switchToIFrame();
147 $I->waitForElement('.t3js-modal.in');
148 $I->wait(3);
149 $I->waitForElementNotVisible('div#nprogess');
150 $I->click('Text & Images');
151 $I->switchToIFrame('list_frame');
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();
158 $I->switchToIFrame('modal_frame');
159 $I->click('.list-tree-control-closed');
160 $I->click('styleguide');
161 $I->click('bus_lane.jpg');
162 $I->switchToWindow();
163 $I->switchToIFrame('list_frame');
164 $I->waitForText('bus_lane.jpg');
165
166 $I->waitForText('Image Metadata');
167
168 $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', '');
169 $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', '');
170 $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
171
172 $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
173 $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
174 $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
175
176 $I->amGoingTo('assert checkboxes are not checked');
177 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[title]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
178 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[alternative]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
179 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[description]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
180
181 $I->amGoingTo('Assert hidden control field value (default value which is used when checkbox is not checked');
182 $I->seeInField('//input[contains(@name, "[title]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
183 $I->seeInField('//input[contains(@name, "[alternative]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
184 $I->seeInField('//input[contains(@name, "[description]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
185
186 //when checkbox is unchecked the disabled input is shown
187 //<input type="text" class="form-control" disabled="disabled" value="Test title">
188 $I->seeInField('input.form-control:disabled', 'Test title');
189 $I->seeInField('input.form-control:disabled', 'Test alternative');
190 $I->seeInField('textarea.form-control:disabled', 'Test description');
191 }
192
193 /**
194 * @param Admin $I
195 * @param PageTree $pageTree
196 * @throws \Exception
197 */
198 protected function goToPageModule(Admin $I, PageTree $pageTree)
199 {
200 $I->switchToIFrame();
201 $I->click('Page');
202 $I->waitForElement('svg .nodes .node');
203 $pageTree->openPath(['styleguide TCA demo']);
204 $I->switchToIFrame('list_frame');
205 $I->waitForText('styleguide TCA demo');
206 }
207 }