SiteModuleCest.php 14.8 KB
Newer Older
1
<?php
2

3
declare(strict_types=1);
4
5
6
7
8
9
10
11
12
13
14
15
16
17

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

18
namespace TYPO3\CMS\Core\Tests\Acceptance\Application\Site;
19

20
use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
21
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
22
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree;
23
24
25
26
27
28

/**
 * Tests concerning Sites Module
 */
class SiteModuleCest
{
29
    public function _before(ApplicationTester $I): void
30
31
32
33
    {
        $I->useExistingSession('admin');
    }

34
    public function editExistingRecord(ApplicationTester $I, ModalDialog $modalDialog): void
35
    {
36
37
38
        $acceptanceUrl = $I->grabModuleConfig('WebDriver', 'url');
        $acceptanceUrlWithTrailingSlash = rtrim($acceptanceUrl, '/') . '/';

39
        $I->amGoingTo('Access the site module');
40
41
42
43
        $I->click('Sites');
        $I->switchToContentFrame();
        $I->canSee('Site Configuration', 'h1');

44
45
46
        $I->amGoingTo('edit an automatically created site configuration');
        $I->click('Edit');
        $I->waitForElementNotVisible('#t3js-ui-block');
47
        $I->canSee('Edit Site Configuration', 'h1');
48
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[identifier]")]', 'autogenerated-1-c4ca4238a0');
49
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[base]")]', $acceptanceUrlWithTrailingSlash);
50
51

        $I->amGoingTo('Edit the default site language');
52
        $I->click('Languages');
53
54
55
56
        $I->canSee('English [0] (en_US.UTF-8)');
        $I->click('div[data-table-unique-original-value=site_language_0] > div:nth-child(1) > div:nth-child(1)');
        $I->waitForElementVisible('div[data-table-unique-original-value=site_language_0] > div.panel-collapse');
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[title]")]', 'English Edit');
57
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[base]")]', $acceptanceUrlWithTrailingSlash);
58
59
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[locale]")]', 'en_US.UTF-8');

60
61
62
63
64
65
66
67
68
69
70
        $I->amGoingTo('Delete a site language');
        $I->canSee('styleguide demo language danish [1] (da_DK.UTF-8)');
        $I->click('div[data-table-unique-original-value=site_language_1] > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) button');
        $modalDialog->canSeeDialog();
        $I->click('button[name="yes"]', ModalDialog::$openedModalButtonContainerSelector);
        $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
        $I->switchToContentFrame();
        $I->dontSee('styleguide demo language danish [1] (da_DK.UTF-8)');
        $I->canSee('styleguide demo language danish [1]', 'option');

        $I->amGoingTo('Save the site configuration');
71
72
73
74
75
        $saveButtonLink = '//*/button[@name="_savedok"][1]';
        $I->waitForElement($saveButtonLink, 30);
        $I->click($saveButtonLink);
        $I->waitForElementNotVisible('#t3js-ui-block');

76
77
78
79
80
81
82
83
84
85
86
87
88
        $I->amGoingTo('Verify default site language has changed and danish is deleted');
        $I->canSee('English Edit [0] (en_US.UTF-8)');
        $I->dontSee('styleguide demo language danish [1] (da_DK.UTF-8)');

        $I->amGoingTo('Create a completely new site language');
        $I->click('Create new language');
        $I->waitForElementVisible('div.inlineIsNewRecord');
        $I->scrollTo('div.inlineIsNewRecord');
        $I->canSee('[New language]');
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[title]")]', 'New Language');
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[base]")]', '/new-language/');
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[locale]")]', 'C');
        $I->selectOption('//select[contains(@name, "[site_language]") and contains(@name, "[iso-639-1]")]', 'hr');
89

90
91
92
93
94
95
        $I->amGoingTo('Save the site configuration');
        $I->waitForElement($saveButtonLink, 30);
        $I->click($saveButtonLink);
        $I->waitForElementNotVisible('#t3js-ui-block');

        $I->amGoingTo('Verify new site configuration has been added with the next available language ID)');
96
        $I->canSee('New Language [9] (C)');
97
98
99

        $I->amGoingTo('Close the site configuration form');
        $I->click('Close');
100
101
        $I->waitForElementVisible('table.table-striped');
        $I->canSee('Site Configuration', 'h1');
102
        $I->canSee('autogenerated-1-c4ca4238a0', 'code');
103

104
105
106
107
108
        $I->amGoingTo('Ensure the previously added language is available and the default is prefilled in a new site configuration');
        $I->click('Add new site configuration for this site');
        $I->waitForElementNotVisible('#t3js-ui-block');
        $I->canSee('Create new Site Configuration', 'h1');
        $I->click('Languages');
109
        $I->canSee('New Language [9]', 'option');
110
111
112
113
        $I->canSee('English Edit [0] (en_US.UTF-8)');
        $title = $I->grabValueFrom('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[title]")]');
        $I->assertEquals('English Edit', $title);
        $I->click('div.inlineIsNewRecord:nth-child(1) > div:nth-child(1) > div:nth-child(1)');
114

115
        $I->amGoingTo('Verify new language can be added from selector box and deleted afterwards');
116
        $I->selectOption('.t3js-create-new-selector', '9');
117
118
        $I->waitForElementVisible('div.inlineIsNewRecord:nth-child(2)');
        $I->scrollTo('div.inlineIsNewRecord:nth-child(2)');
119
        $I->canSee('New Language [9] (C)');
120
121
122
123
124
125
        $I->click('div.inlineIsNewRecord:nth-child(2) > div:nth-child(1) > div:nth-child(1)');
        $I->canSee('/hr/');
        $I->click('div.inlineIsNewRecord:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) button');
        $modalDialog->canSeeDialog();
        $I->click('button[name="yes"]', ModalDialog::$openedModalButtonContainerSelector);
        $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
126
        $I->switchToContentFrame();
127
        $I->see('New Language [9]', 'option');
128

129
130
        $I->amGoingTo('Undo the generation of the new site configuration');
        $I->click('Close');
131
        $modalDialog->canSeeDialog();
132
133
        $I->click('button[name="yes"]', ModalDialog::$openedModalButtonContainerSelector);
        $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
134
        $I->switchToContentFrame();
135
        $I->canSee('Add new site configuration for this site', 'a');
136
137
138
139
140
    }

    /**
     * Add a default FE ts snipped to the existing site config and verify FE is rendered
     *
141
     * @depends editExistingRecord
142
     */
143
    public function defaultFrontendRendering(ApplicationTester $I, PageTree $pageTree, ModalDialog $modalDialog): void
144
    {
145
        $I->amGoingTo('Create a default FE typoscript for the created site configuration');
146

147
148
        // Select the root page
        $I->switchToMainFrame();
149
        $I->amGoingTo('Access template module');
150
        $I->click('Template');
151
152
153
        // click on PID=0
        $I->waitForElement('svg .nodes .node');
        $I->clickWithLeftButton('#identifier-0_0 text.node-name');
154
155
156
157
        $I->switchToContentFrame();
        $I->waitForElementVisible('#ts-overview');
        $I->see('Template tools');

158
        $I->amGoingTo('Select the root page and switch back to content frame');
159
160
        $I->switchToMainFrame();
        $I->click('Template');
161
        $pageTree->openPath(['styleguide TCA demo']);
162
        $I->switchToContentFrame();
163
        $I->selectOption('div.module-docheader select.t3-js-jumpMenuBox', 'Info/Modify');
164
165
        $I->waitForText('Create new website');

166
        $I->amGoingTo('Create a new template for the root page');
167
168
        $I->click("//input[@name='newWebsite']");
        $I->selectOption('.t3-js-jumpMenuBox', 'Info/Modify');
169
170
        $I->see('NEW SITE', 'h3');
        $I->waitForElement('table.table.table-striped');
171
172
        $I->see('Title');

173
        $I->amGoingTo('Add the PAGE object');
174
175
        $I->click('Edit the whole template record');
        $I->waitForElement('#EditDocumentController');
176
        $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_template]") and contains(@data-formengine-input-name, "[title]")]', 'Default Title');
177
178
179
180
181
182
183
184
185
186
187
        $I->click("//button[@name='_savedok']");
        $I->waitForElementNotVisible('#t3js-ui-block', 30);
        $I->waitForElement('#EditDocumentController');
        $I->waitForElementNotVisible('#t3js-ui-block');

        // watch out for new line after each instruction. Anything else doesn't work.
        $config = 'page = PAGE
page.shortcutIcon = fileadmin/styleguide/bus_lane.jpg
page.10 = TEXT
page.10.value = This is a default text for default rendering without dynamic content creation
';
188
        $I->fillField('//textarea[contains(@data-formengine-input-name, "data[sys_template]") and contains(@data-formengine-input-name, "[config]")]', $config);
189
190
191
        $I->click('//button[@name="_savedok"]');
        $I->waitForElementNotVisible('#t3js-ui-block');

192
        $I->amGoingTo('Call FE and verify it is properly rendered');
193
194
        $I->amOnPage('/');
        $I->canSee('This is a default text for default rendering without dynamic content creation');
195
196
197
198

        $I->amGoingTo('Delete the site template record again');
        $I->amOnPage('/typo3/index.php');
        $I->click('Template');
199
200
201
        // click on PID=0
        $I->waitForElement('svg .nodes .node');
        $I->clickWithLeftButton('#identifier-0_0 text.node-name');
202
203
204
205
206
207
        $I->switchToContentFrame();
        $I->waitForElementVisible('#ts-overview');
        $I->switchToMainFrame();
        $pageTree->openPath(['styleguide TCA demo']);
        $I->wait(0.2);
        $I->switchToContentFrame();
208
209
        $I->selectOption('div.module-docheader select.t3-js-jumpMenuBox', 'Info/Modify');
        $I->waitForText('Edit the whole template record');
210
211
212
213
214
215
216
217
218
219
220
221
222
223
        $I->click('Edit the whole template record');
        $I->waitForElement('#EditDocumentController');
        $I->click('Delete');
        $modalDialog->canSeeDialog();
        $I->click('button[name="yes"]', ModalDialog::$openedModalButtonContainerSelector);
        $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
        $I->switchToContentFrame();
        $I->see('Create new website');
    }

    /**
     * @depends defaultFrontendRendering
     * @throws \Exception
     */
224
    public function createSiteConfigIfNoneExists(ApplicationTester $I, ModalDialog $modalDialog): void
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
    {
        $acceptanceUrl = $I->grabModuleConfig('WebDriver', 'url');
        $acceptanceUrlWithTrailingSlash = rtrim($acceptanceUrl, '/') . '/';

        $I->amGoingTo('Access the site module');
        $I->click('Sites');
        $I->switchToContentFrame();
        $I->canSee('Site Configuration', 'h1');

        $I->amGoingTo('delete the auto generated config in order to create one manually');
        $I->click('Delete site configuration');
        $modalDialog->canSeeDialog();
        $modalDialog->clickButtonInDialog('Delete');
        $I->switchToContentFrame();

        $I->amGoingTo('manually create a new site config for the existing root page');
        $I->click('Add new site configuration for this site');
        $I->waitForElementNotVisible('#t3js-ui-block');
        $I->canSee('Create new Site configuration');
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[identifier]")]', 'SitesTestIdentifier');
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[base]")]', $acceptanceUrlWithTrailingSlash);
        $I->click('Languages');

        $I->amGoingTo('Delete the automatically added default language and add it again from the selector afterwards');
        $I->click('div.inlineIsNewRecord > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) button');
        $modalDialog->canSeeDialog();
        $I->click('button[name="yes"]', ModalDialog::$openedModalButtonContainerSelector);
        $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
        $I->switchToContentFrame();
Jochen Roth's avatar
Jochen Roth committed
254
        $I->canSee('English [0]', 'option');
255
256
257
258
259
260
261
262
263
        $I->selectOption('.t3js-create-new-selector', '0');
        $I->waitForElementVisible('div.inlineIsNewRecord:nth-child(1)');
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[title]")]', 'Homepage');
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[base]")]', $acceptanceUrlWithTrailingSlash);
        $I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[locale]")]', 'en_US.UTF-8');
        $saveButtonLink = '//*/button[@name="_savedok"][1]';
        $I->waitForElement($saveButtonLink, 30);
        $I->click($saveButtonLink);

264
        $I->amGoingTo('Create and delete new site language. Verify "Placeholder" is not added to selector');
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
        $I->click('Languages');
        $I->click('Create new language');
        $I->waitForElementVisible('div.inlineIsNewRecord');
        $I->scrollTo('div.inlineIsNewRecord');
        $I->canSee('[New language]');
        $I->click('div.inlineIsNewRecord > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) button');
        $modalDialog->canSeeDialog();
        $I->click('button[name="yes"]', ModalDialog::$openedModalButtonContainerSelector);
        $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
        $I->switchToContentFrame();
        $I->dontSee('Placeholder');

        $I->amGoingTo('Close site configuration and verify that it got saved');
        $I->waitForElementNotVisible('#t3js-ui-block');
        $I->click('div.module-docheader .btn.t3js-editform-close');
        $modalDialog->canSeeDialog();
        $I->click('button[name="save"]', ModalDialog::$openedModalButtonContainerSelector);
        $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
        $I->switchToContentFrame();
        $I->waitForElementVisible('table.table-striped');
        $I->canSee('Site Configuration', 'h1');
        $I->canSee('SitesTestIdentifier');
287
288
    }
}