‪TYPO3CMS  11.5
TemplateCest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Codeception\Scenario;
23 
28 {
29  public function ‪_before(‪ApplicationTester $I): void
30  {
31  $I->useExistingSession('admin');
32 
33  $I->switchToMainFrame();
34  $I->see('Template');
35  $I->click('Template');
36  $I->waitForElement('svg .nodes .node');
37  $I->switchToContentFrame();
38  $I->waitForText('Template tools');
39  }
40 
42  {
43  $I->wantTo('show templates overview on root page (uid = 0)');
44  // Select the root page
45  $I->switchToMainFrame();
46  // click on PID=0
47  $I->clickWithLeftButton('#identifier-0_0 text.node-name');
48 
49  $I->switchToContentFrame();
50  $I->waitForElementVisible('#ts-overview');
51  $I->wait(2);
52  $I->see('This is an overview of the pages in the database containing one or more template records. Click a page title to go to the page.');
53 
54  $I->wantTo('show templates overview on website root page (uid = 1 and pid = 0)');
55  $I->switchToMainFrame();
56  $pageTree->‪closeSecondLevelPaths();
57  // click on website root page
58  $I->clickWithLeftButton('//*[text()=\'styleguide TCA demo\']');
59  $I->switchToContentFrame();
60  $I->wait(1);
61  $I->selectOption('.t3-js-jumpMenuBox', 'Constant Editor');
62  $I->wait(1);
63  $I->waitForText('No template');
64  $I->wait(2);
65  $I->see('There was no template on this page!');
66  $I->see('You need to create a template record below in order to edit your configuration.');
67 
68  // @todo These input fields should be changed to buttons. Should be changed to proper HTML.
69  $I->seeInFormFields(
70  '#TypoScriptTemplateModuleController',
71  [
72  'newWebsite' => 'Create template for a new site',
73  'createExtension' => 'Click here to create an extension template.',
74  ]
75  );
76  }
77 
78  public function ‪addANewSiteTemplate(‪ApplicationTester $I, ‪PageTree $pageTree, Scenario $scenario): void
79  {
80  $I->wantTo('create a new site template');
81  $I->switchToMainFrame();
82  $pageTree->‪openPath(['styleguide TCA demo']);
83  $I->switchToContentFrame();
84  $I->waitForText('Create new website');
85  $I->wait(2);
86  $I->click("//input[@name='newWebsite']");
87  $I->waitForText('Edit constants for template');
88 
89  $I->wantTo('change to Info/Modify and see the template overview table');
90  $I->selectOption('.t3-js-jumpMenuBox', 'Info/Modify');
91  $I->wait(3);
92  $I->waitForElement('.table-striped');
93  $I->see('Title');
94  $I->see('Description');
95  $I->see('Constants');
96  $I->see('Setup');
97  $I->see('Edit the whole template record');
98  $I->click('Edit the whole template record');
99 
100  $I->wantTo('change the title and save the template');
101  $I->waitForElement('#EditDocumentController');
102  // fill title input field
103  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_template]") and contains(@data-formengine-input-name, "[title]")]', 'Acceptance Test Site');
104  $I->click("//button[@name='_savedok']");
105  $I->waitForElementNotVisible('#t3js-ui-block', 30);
106  $I->waitForElement('#EditDocumentController');
107  $I->waitForElementNotVisible('#t3js-ui-block');
108 
109  $I->wantTo('change the setup, save the template and close the form');
110 
111  $isComposerMode = str_contains($scenario->current('env'), 'composer');
112  if ($isComposerMode) {
113  $codeMirrorSelector = 'typo3-t3editor-codemirror[name$="[config]"]';
114  $I->waitForElementVisible($codeMirrorSelector);
115  $I->executeJS("const codeMirror = document.querySelector('" . $codeMirrorSelector . "'); const config = codeMirror.getContent().replace('HELLO WORLD!', 'Hello Acceptance Test!'); codeMirror.setContent(config)");
116  } else {
117  // grab and fill setup textarea
118  $config = $I->grabTextFrom('//textarea[contains(@data-formengine-input-name, "data[sys_template]") and contains(@data-formengine-input-name, "[config]")]');
119  $config = str_replace('HELLO WORLD!', 'Hello Acceptance Test!', $config);
120  $I->fillField('//textarea[contains(@data-formengine-input-name, "data[sys_template]") and contains(@data-formengine-input-name, "[config]")]', $config);
121  }
122 
123  $I->click('//*/button[@name="_savedok"][1]');
124  $I->waitForElement('a.t3js-editform-close');
125  $I->click('a.t3js-editform-close');
126 
127  $I->wantTo('see the changed title');
128  $I->waitForElement('.table-striped');
129  $I->see('Acceptance Test Site');
130 
131  $I->wantTo('change the template within the TypoScript Object Browser');
132  $I->wait(1);
133  $I->selectOption('.t3-js-jumpMenuBox', 'TypoScript Object Browser');
134  $I->wait(1);
135  $I->selectOption('select[name="SET[ts_browser_type]"]', 'Constants');
136  $I->wait(1);
137  $I->waitForText('CONSTANTS ROOT');
138  $I->selectOption('//select[@name="SET[ts_browser_type]"]', 'Setup');
139  $I->waitForText('SETUP ROOT');
140  // find and open [page] in tree
141  $I->see('[page] = PAGE');
142  $I->click('//span[@class="list-tree-label"]/a[text()=\'page\']/../../a');
143  // find and open [page][10] in tree
144  $I->waitForText('[10] = TEXT');
145  $I->click('//span[@class="list-tree-label"]/a[text()=\'page\']/../../../ul//span[@class="list-tree-label"]/a[text()=\'10\']/../../a');
146  // find and edit [page][10][value] in tree
147  $I->waitForText('[value] = Hello Acceptance Test!');
148  $I->click('//span[@class="list-tree-label"]/a[text()=\'10\']/../../../ul//span[@class="list-tree-label"]/a[text()=\'value\']');
149  $I->waitForText('page.10.value =');
150  $I->fillField('//input[@name="data[page.10.value][value]"]', 'HELLO WORLD!');
151  $I->click('//input[@name="update_value"]');
152  $I->wait(2);
153  $I->waitForText('Value updated');
154  $I->see('page.10.value = HELLO WORLD!');
155  $I->see('[value] = HELLO WORLD!');
156  }
157 
159  {
160  $I->wantTo('click on the button to go to the closest page with a template');
161  $I->switchToMainFrame();
162  $pageTree->‪openPath(['styleguide frontend demo', 'menu_sitemap_pages']);
163  $I->switchToContentFrame();
164  $I->selectOption('.t3-js-jumpMenuBox', 'Constant Editor');
165  $I->wait(1);
166  $I->waitForText('No template');
167  $I->wait(2);
168  $I->see('There was no template on this page!');
169  $I->see('You need to create a template record below in order to edit your configuration.');
170  $I->seeLink('Click here to go.');
171  $I->clickWithLeftButton('//a[text()[normalize-space(.) = "Click here to go."]]');
172 
173  $I->wantTo('see that the page has a template');
174  $I->selectOption('.t3-js-jumpMenuBox', 'Info/Modify');
175  $I->waitForElement('.table-striped');
176  $I->see('Title');
177  $I->see('Description');
178  $I->see('Constants');
179  $I->see('Setup');
180  $I->see('Edit the whole template record');
181  $I->click('Edit the whole template record');
182  // Avoid race condition:
183  // SEVERE - http://web/typo3/sysext/backend/Resources/Public/JavaScript/code-editor/autocomplete/ts-ref.js?bust=[…]
184  // 12:613 Uncaught TypeError: Cannot convert undefined or null to object
185  $I->waitForElementNotVisible('#nprogress', 120);
186  }
187 
188  public function ‪createExtensionTemplate(‪ApplicationTester $I, ‪PageTree $pageTree): void
189  {
190  $I->wantTo('see the button to create a extension template');
191  $I->switchToMainFrame();
192  $pageTree->‪openPath(['styleguide frontend demo', 'menu_sitemap_pages']);
193  $I->switchToContentFrame();
194  $I->selectOption('.t3-js-jumpMenuBox', 'Constant Editor');
195  $I->wait(2);
196  $I->selectOption('.t3-js-jumpMenuBox', 'Info/Modify');
197  $I->wait(1);
198  $I->waitForText('No template');
199  $I->see('There was no template on this page!');
200  $I->see('You need to create a template record below in order to edit your configuration.');
201 
202  $I->seeInFormFields(
203  '#TypoScriptTemplateModuleController',
204  [
205  'createExtension' => 'Click here to create an extension template.',
206  ]
207  );
208 
209  $I->clickWithLeftButton('//input[@name=\'createExtension\']');
210 
211  $I->wantTo('see that the page has a template');
212  $I->selectOption('.t3-js-jumpMenuBox', 'Info/Modify');
213  $I->waitForElement('.table-striped');
214  $I->see('Title');
215  $I->see('Description');
216  $I->see('Constants');
217  $I->see('Setup');
218  $I->see('Edit the whole template record');
219  $I->click('Edit the whole template record');
220  }
221 
226  {
227  $I->wantTo('Open the TypoScript Object Browser and search a keyword.');
228  $I->switchToMainFrame();
229  $I->clickWithLeftButton('//*[text()=\'styleguide TCA demo\']');
230  $I->switchToContentFrame();
231  $I->wait(2);
232  $I->selectOption('.t3-js-jumpMenuBox', 'TypoScript Object Browser');
233  $I->wait(2);
234  $I->selectOption('//select[@name="SET[ts_browser_type]"]', 'Constants');
235  $I->waitForText('CONSTANTS ROOT');
236  $I->amGoingTo('type "styles" into the search field and submit.');
237  $I->fillField('#search_field', 'styles');
238  $I->click("//input[@name='search']");
239  $I->waitForText('CONSTANTS ROOT');
240  $I->seeInSource('<strong class="text-danger">styles</strong>');
241  }
242 
247  {
248  $I->wantTo('Open the TypoScript Object Browser and use the object list.');
249  $I->switchToMainFrame();
250  $I->clickWithLeftButton('//*[text()=\'styleguide TCA demo\']');
251  $I->switchToContentFrame();
252 
253  $I->amGoingTo('Switch to object browser.');
254  $I->wait(2);
255  $I->selectOption('.t3-js-jumpMenuBox', 'TypoScript Object Browser');
256  $I->wait(2);
257  $I->selectOption('select[name="SET[ts_browser_type]"]', 'Setup');
258  $I->waitForText('SETUP ROOT');
259  $I->click('tt_content');
260  $I->waitForText('Edit object/property value');
261 
262  $I->amGoingTo('add tt_content to object list');
263  $I->click('Add key "tt_content" to Object List');
264  $I->see('Remove key from OL');
265  $I->see('key');
266 
267  $I->amGoingTo('verify "all" can still be selected and shows full setup.');
268  $I->selectOption('select[name="SET[ts_browser_toplevel_setup]"]', 'all');
269  $I->seeInSource('<i class="text-muted"># Content element rendering</i>');
270  }
271 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\checkClosestTemplateButton
‪checkClosestTemplateButton(ApplicationTester $I, PageTree $pageTree)
Definition: TemplateCest.php:158
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\useObjectListInObjectBrowser
‪useObjectListInObjectBrowser(ApplicationTester $I)
Definition: TemplateCest.php:246
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\createExtensionTemplate
‪createExtensionTemplate(ApplicationTester $I, PageTree $pageTree)
Definition: TemplateCest.php:188
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template
Definition: TemplateCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\openPath
‪openPath(array $path)
Definition: PageTree.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\searchInTypoScriptObjectBrowser
‪searchInTypoScriptObjectBrowser(ApplicationTester $I)
Definition: TemplateCest.php:225
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\pagesWithNoTemplateShouldShowButtonsToCreateTemplates
‪pagesWithNoTemplateShouldShowButtonsToCreateTemplates(ApplicationTester $I, PageTree $pageTree)
Definition: TemplateCest.php:41
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\closeSecondLevelPaths
‪closeSecondLevelPaths()
Definition: PageTree.php:53
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\_before
‪_before(ApplicationTester $I)
Definition: TemplateCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest
Definition: TemplateCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\addANewSiteTemplate
‪addANewSiteTemplate(ApplicationTester $I, PageTree $pageTree, Scenario $scenario)
Definition: TemplateCest.php:78