[TASK] Make failing acceptance tests after image update run again
[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 Facebook\WebDriver\Exception\NoSuchWindowException;
20 use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
21 use TYPO3\TestingFramework\Core\Acceptance\Support\Page\PageTree;
22
23 /**
24 * Tests for inline 1n
25 */
26 class FalMetadataInheritanceCest
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
35 $this->goToPageModule($I, $pageTree);
36 }
37
38 /**
39 * This scenario tests whether updated sys_file_metadata fields are propagated to sys_file_reference
40 * attached to tt_content
41 * - creates tt_content
42 * - attaches an image with empty metadata
43 * - modifies image metadata
44 * - checks if metadata is propagated to tt_content
45 *
46 * @param Admin $I
47 * @param PageTree $pageTree
48 * @throws \Exception
49 */
50 public function checkIfUpdatedFileMetadataIsUpdatedInContent(Admin $I, PageTree $pageTree)
51 {
52 $I->amGoingTo('Create new CE with image');
53 $I->click('.t3js-page-new-ce a');
54 $I->waitForElementNotVisible('div#nprogess');
55 $I->click('Text & Images');
56 $I->waitForText('Create new Page Content on page');
57 $I->fillField('//input[contains(@data-formengine-input-name, "data[tt_content]") and contains(@data-formengine-input-name, "[header]")]', 'tt_content with image');
58
59 $I->click('Images');
60 $I->click('Add image');
61
62 $I->switchToWindow('Typo3WinBrowser');
63 try {
64 $I->click('.list-tree-control-closed');
65 $I->click('styleguide');
66 $I->click('bus_lane.jpg');
67 } catch (NoSuchWindowException $e) {
68 // missing focus by auto close window
69 }
70
71 $I->switchToWindow();
72 $I->switchToIFrame('list_frame');
73 $I->waitForText('bus_lane.jpg');
74
75 $I->see('Set element specific value (No default)', '.t3js-form-field-eval-null-placeholder-checkbox');
76
77 $I->seeElement('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => '', 'value' => '']);
78 $I->seeElement('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => '', 'value' => '']);
79 $I->seeElement('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', ['placeholder' => '']);
80 //textarea value is not in the attribute, so we need to check it separately
81 $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
82
83 $I->click('button[name="_savedok"]');
84 $I->wait(3);
85 $I->click('a[title="Close"]');
86
87 $I->amGoingTo('Change default metadata');
88 $I->switchToIFrame();
89 $I->click('Filelist');
90 $I->switchToIFrame('typo3-navigationContainerIframe');
91 $I->waitForText('fileadmin/ (auto-created)');
92 $I->click('styleguide');
93
94 $I->switchToWindow();
95 $I->switchToIFrame('list_frame');
96 $I->click('bus_lane.jpg');
97 $I->waitForText('Edit File Metadata "bus_lane.jpg" on root level');
98 $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[title]")]', 'Test title');
99 $I->fillField('//textarea[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[description]")]', 'Test description');
100 $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_file_metadata]") and contains(@data-formengine-input-name, "[alternative]")]', 'Test alternative');
101
102 $I->click('button[name="_savedok"]');
103 $I->wait(3);
104 $I->click('a[title="Close"]');
105
106 $I->amGoingTo('Check metadata of sys_file_reference displayed in tt_content');
107 $this->goToPageModule($I, $pageTree);
108 $I->switchToWindow();
109 $I->switchToIFrame('list_frame');
110 $I->click('tt_content with image');
111 $I->waitForElementNotVisible('#t3js-ui-block');
112 $I->waitForText('Edit Page Content "tt_content with image" on page "styleguide TCA demo"');
113 $I->click('Images');
114 $I->click('.form-irre-header');
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->seeElement('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => 'Test title', 'value' => '']);
121 $I->seeElement('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => 'Test alternative', 'value' => '']);
122 $I->seeElement('//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
127 /**
128 * This scenario tests whether sys_file_metadata fields are propagated to sys_file_reference
129 * attached to tt_content
130 *
131 * - given a image with filled metadata (created in checkIfUpdatedFileMetadataIsUpdatedInContent test)
132 * - creates a new tt_content
133 * - attaches an image to tt_content
134 * - checks if metadata is propagated to tt_content
135 * - checks if checkboxes are unchecked and inputs are disabled
136 *
137 * test for https://forge.typo3.org/issues/81235
138 *
139 * @param Admin $I
140 * @param PageTree $pageTree
141 * @throws \Exception
142 * @depends checkIfUpdatedFileMetadataIsUpdatedInContent
143 */
144 public function checkIfFileMetadataIsInheritedInContent(Admin $I)
145 {
146 $I->amGoingTo('Create new CE with image with filled metadata');
147 $I->click('.t3js-page-new-ce a');
148 $I->waitForElementNotVisible('div#nprogess');
149 $I->click('Text & Images');
150 $I->waitForText('Create new Page Content on page');
151 $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');
152
153 $I->click('Images');
154 $I->click('Add image');
155
156 $I->switchToWindow('Typo3WinBrowser');
157 try {
158 $I->click('.list-tree-control-closed');
159 $I->click('styleguide');
160 $I->click('bus_lane.jpg');
161 } catch (NoSuchWindowException $e) {
162 // missing focus by auto close window
163 }
164
165 $I->switchToWindow();
166 $I->switchToIFrame('list_frame');
167 $I->waitForText('bus_lane.jpg');
168
169 $I->waitForText('Image Metadata');
170
171 $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', '');
172 $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', '');
173 $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
174
175 $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
176 $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
177 $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
178
179 $I->amGoingTo('assert checkboxes are not checked');
180 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[title]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
181 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[alternative]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
182 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[description]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
183
184 $I->amGoingTo('Assert hidden control field value (default value which is used when checkbox is not checked');
185 $I->seeInField('//input[contains(@name, "[title]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
186 $I->seeInField('//input[contains(@name, "[alternative]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
187 $I->seeInField('//input[contains(@name, "[description]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
188
189 //when checkbox is unchecked the disabled input is shown
190 //<input type="text" class="form-control" disabled="disabled" value="Test title">
191 $I->seeInField('input.form-control:disabled', 'Test title');
192 $I->seeInField('input.form-control:disabled', 'Test alternative');
193 $I->seeInField('textarea.form-control:disabled', 'Test description');
194 }
195
196 /**
197 * @param Admin $I
198 * @param PageTree $pageTree
199 * @throws \Exception
200 */
201 protected function goToPageModule(Admin $I, PageTree $pageTree)
202 {
203 $I->switchToIFrame();
204 $I->click('Page');
205 $pageTree->openPath(['styleguide TCA demo']);
206 $I->switchToIFrame('list_frame');
207 $I->waitForText('styleguide TCA demo');
208 }
209 }