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