[BUGFIX] Wait some seconds before click in modal content
[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->click('Text & Images');
57 $I->switchToIFrame('list_frame');
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();
64 $I->switchToIFrame('modal_frame');
65 $I->click('.list-tree-control-closed');
66 $I->click('styleguide');
67 $I->click('bus_lane.jpg');
68 $I->switchToWindow();
69 $I->switchToIFrame('list_frame');
70 $I->waitForText('bus_lane.jpg');
71
72 $I->see('Set element specific value (No default)', '.t3js-form-field-eval-null-placeholder-checkbox');
73
74 $I->seeElement('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => '', 'value' => '']);
75 $I->seeElement('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => '', 'value' => '']);
76 $I->seeElement('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', ['placeholder' => '']);
77 //textarea value is not in the attribute, so we need to check it separately
78 $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
79
80 $I->click('button[name="_savedok"]');
81 $I->wait(3);
82 $I->click('a[title="Close"]');
83
84 $I->amGoingTo('Change default metadata');
85 $I->switchToIFrame();
86 $I->click('Filelist');
87 $I->switchToIFrame('typo3-navigationContainerIframe');
88 $I->waitForText('fileadmin/ (auto-created)');
89 $I->click('styleguide');
90
91 $I->switchToWindow();
92 $I->switchToIFrame('list_frame');
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();
106 $I->switchToIFrame('list_frame');
107 $I->click('tt_content with image');
108 $I->waitForText('Edit Page Content "tt_content with image" on page "styleguide TCA demo"');
109 $I->click('Images');
110 $I->click('.form-irre-header');
111
112 $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
113 $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
114 $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
115
116 $I->seeElement('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', ['placeholder' => 'Test title', 'value' => '']);
117 $I->seeElement('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', ['placeholder' => 'Test alternative', 'value' => '']);
118 $I->seeElement('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', ['placeholder' => 'Test description']);
119 //textarea value is not in the attribute, so we need to check it separately
120 $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
121 }
122
123 /**
124 * This scenario tests whether sys_file_metadata fields are propagated to sys_file_reference
125 * attached to tt_content
126 *
127 * - given a image with filled metadata (created in checkIfUpdatedFileMetadataIsUpdatedInContent test)
128 * - creates a new tt_content
129 * - attaches an image to tt_content
130 * - checks if metadata is propagated to tt_content
131 * - checks if checkboxes are unchecked and inputs are disabled
132 *
133 * test for https://forge.typo3.org/issues/81235
134 *
135 * @param Admin $I
136 * @param PageTree $pageTree
137 * @throws \Exception
138 * @depends checkIfUpdatedFileMetadataIsUpdatedInContent
139 */
140 public function checkIfFileMetadataIsInheritedInContent(Admin $I)
141 {
142 $I->amGoingTo('Create new CE with image with filled metadata');
143 $I->click('.t3js-page-new-ce a');
144 $I->switchToIFrame();
145 $I->waitForElement('.t3js-modal.in');
146 $I->wait(3);
147 $I->click('Text & Images');
148 $I->switchToIFrame('list_frame');
149 $I->waitForText('Create new Page Content on page');
150 $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');
151
152 $I->click('Images');
153 $I->click('Add image');
154 $I->switchToWindow();
155 $I->switchToIFrame('modal_frame');
156 $I->click('.list-tree-control-closed');
157 $I->click('styleguide');
158 $I->click('bus_lane.jpg');
159 $I->switchToWindow();
160 $I->switchToIFrame('list_frame');
161 $I->waitForText('bus_lane.jpg');
162
163 $I->waitForText('Image Metadata');
164
165 $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[title]")]', '');
166 $I->seeInField('//input[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[alternative]")]', '');
167 $I->seeInField('//textarea[contains(@data-formengine-input-name, "data[sys_file_reference]") and contains(@data-formengine-input-name, "[description]")]', '');
168
169 $I->see('(Default: "Test title")', '.t3js-form-field-eval-null-placeholder-checkbox');
170 $I->see('(Default: "Test alternative")', '.t3js-form-field-eval-null-placeholder-checkbox');
171 $I->see('(Default: "Test description")', '.t3js-form-field-eval-null-placeholder-checkbox');
172
173 $I->amGoingTo('assert checkboxes are not checked');
174 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[title]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
175 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[alternative]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
176 $I->dontSeeCheckboxIsChecked('//input[contains(@name, "[description]") and @type="checkbox" and contains(@name, "control[active][sys_file_reference]")]');
177
178 $I->amGoingTo('Assert hidden control field value (default value which is used when checkbox is not checked');
179 $I->seeInField('//input[contains(@name, "[title]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
180 $I->seeInField('//input[contains(@name, "[alternative]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
181 $I->seeInField('//input[contains(@name, "[description]") and @type="hidden" and contains(@name, "control[active][sys_file_reference]")]', 0);
182
183 //when checkbox is unchecked the disabled input is shown
184 //<input type="text" class="form-control" disabled="disabled" value="Test title">
185 $I->seeInField('input.form-control:disabled', 'Test title');
186 $I->seeInField('input.form-control:disabled', 'Test alternative');
187 $I->seeInField('textarea.form-control:disabled', 'Test description');
188 }
189
190 /**
191 * @param Admin $I
192 * @param PageTree $pageTree
193 * @throws \Exception
194 */
195 protected function goToPageModule(Admin $I, PageTree $pageTree)
196 {
197 $I->switchToIFrame();
198 $I->click('Page');
199 $I->waitForElement('svg .nodes .node');
200 $pageTree->openPath(['styleguide TCA demo']);
201 $I->switchToIFrame('list_frame');
202 $I->waitForText('styleguide TCA demo');
203 }
204 }