‪TYPO3CMS  ‪main
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 
22 
23 final class ‪TemplateCest
24 {
25  public function ‪_before(‪ApplicationTester $I): void
26  {
27  $I->useExistingSession('admin');
28 
29  $I->switchToMainFrame();
30  $I->see('TypoScript');
31  $I->click('TypoScript');
32  $I->switchToContentFrame();
33  }
34 
36  {
37  $I->wantTo('show TypoScript records overview on root page (uid = 0)');
38  // Select the root page
39  $I->switchToMainFrame();
40  // click on PID=0
41  $I->clickWithLeftButton('#typo3-pagetree-treeContainer [role="treeitem"][data-id="0"] .node-contentlabel');
42 
43  $I->switchToContentFrame();
44  $I->waitForElementVisible('#ts-overview');
45  $I->see('Global overview of all pages in the database containing one or more TypoScript records.');
46 
47  $I->wantTo('show TypoScript records overview on website root page (uid = 1 and pid = 0)');
48  $I->switchToMainFrame();
49  // click on website root page
50  $I->clickWithLeftButton('//*[text()=\'styleguide TCA demo\']');
51  $I->switchToContentFrame();
52  $I->waitForElementVisible('div.module-docheader select.t3-js-jumpMenuBox');
53  $I->waitForElementNotVisible('#nprogress', 120);
54  $I->selectOption('div.module-docheader select.t3-js-jumpMenuBox', 'Edit TypoScript Record');
55  $I->waitForText('No TypoScript record');
56  $I->see('No TypoScript record on the current page');
57  $I->see('You need to create a TypoScript record in order to edit your configuration.');
58  }
59 
60  public function ‪addANewSiteTemplate(‪ApplicationTester $I): void
61  {
62  $I->waitForText('TypoScript records');
63  $I->wantTo('create a new root TypoScript record');
64  $I->switchToMainFrame();
65  $I->clickWithLeftButton('//*[text()=\'styleguide TCA demo\']');
66  $I->switchToContentFrame();
67  $I->waitForElementVisible('.t3-js-jumpMenuBox');
68  $I->waitForElementNotVisible('#nprogress', 120);
69  $I->selectOption('.t3-js-jumpMenuBox', 'Constant Editor');
70  $I->wait(3);
71  $I->waitForText('Root TypoScript record');
72  $I->click("//input[@name='newWebsite']");
73 
74  $I->wantTo('change to Override TypoScript and see the TypoScript record overview table');
75  $I->waitForElementVisible('.t3-js-jumpMenuBox');
76  $I->waitForElementNotVisible('#nprogress', 120);
77  $I->selectOption('.t3-js-jumpMenuBox', 'Edit TypoScript Record');
78  $I->wait(3);
79  $I->waitForElement('.table-striped');
80  $I->see('Title');
81  $I->see('Description');
82  $I->see('Constants');
83  $I->see('Setup');
84  $I->see('Edit the whole TypoScript record');
85  $I->click('Edit the whole TypoScript record');
86 
87  $I->wantTo('change the title and save the TypoScsript record');
88  $I->waitForElement('#EditDocumentController');
89  // fill title input field
90  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_template]") and contains(@data-formengine-input-name, "[title]")]', 'Acceptance Test Site');
91  $I->click("//button[@name='_savedok']");
92  $I->waitForElementNotVisible('#t3js-ui-block', 30);
93  $I->waitForElement('#EditDocumentController');
94  $I->waitForElementNotVisible('#t3js-ui-block');
95 
96  $codeMirrorSelector = 'typo3-t3editor-codemirror[name$="[config]"]';
97 
98  $I->wantTo('change the setup, save the TypoScript record and close the form');
99  $I->waitForElementVisible($codeMirrorSelector);
100  $I->executeJS("const codeMirror = document.querySelector('" . $codeMirrorSelector . "'); const config = codeMirror.getContent().replace('HELLO WORLD!', 'Hello Acceptance Test!'); codeMirror.setContent(config)");
101  $I->switchToMainFrame();
102  $I->waitForElementNotVisible('typo3-notification-message', 20);
103  $I->switchToContentFrame();
104  $I->click('//*/button[@name="_savedok"][1]');
105  $I->wait(10);
106  $I->waitForElement('a.t3js-editform-close');
107  $I->click('a.t3js-editform-close');
108 
109  $I->wantTo('see the changed title');
110  $I->waitForElement('.table-striped');
111  $I->see('Acceptance Test Site');
112 
113  $I->wantTo('change the TypoScript record within the TypoScript Object Browser');
114  $I->waitForElementVisible('.t3-js-jumpMenuBox');
115  $I->waitForElementNotVisible('#nprogress', 120);
116  $I->selectOption('.t3-js-jumpMenuBox', 'Active TypoScript');
117  $I->click('#panel-tree-heading-setup');
118  $I->waitForText('Setup');
119  // find and open page in tree
120  $I->waitForText('page = PAGE');
121  $I->click('//span[@class="treelist-label"]/a[text()=\'page\']/../../../typo3-backend-tree-node-toggle');
122  // find and open page.10 in tree
123  $I->waitForText('10 = TEXT');
124  $I->click('//span[@class="treelist-label"]/a[text()=\'page\']/../../../div/ul//span[@class="treelist-label"]/a[text()=\'10\']/../../../typo3-backend-tree-node-toggle');
125  // find and edit page.10.value in tree
126  $I->waitForText('value = Hello Acceptance Test!');
127  $I->click('//span[@class="treelist-label"]/a[text()=\'10\']/../../../div/ul//span[@class="treelist-label"]/a[text()=\'value\']');
128  $I->waitForText('page.10.value =');
129  $I->fillField('//input[@name="value"]', 'HELLO WORLD!');
130  $I->click('//input[@name="updateValue"]');
131  $I->wait(2);
132  $I->waitForText('Line added to current TypoScript record');
133  $I->see('page.10.value = HELLO WORLD!');
134  $I->see('value = HELLO WORLD!');
135  }
136 
138  {
139  $I->wantTo('click on the button to go to the closest page with a TypoScript record');
140  $I->switchToMainFrame();
141  $pageTree->‪openPath(['styleguide frontend demo', 'menu_sitemap_pages']);
142  $I->clickWithLeftButton('//*[text()=\'menu_sitemap_pages\']');
143  $I->switchToContentFrame();
144  $I->waitForElementVisible('.t3-js-jumpMenuBox');
145  $I->waitForElementNotVisible('#nprogress', 120);
146  $I->selectOption('.t3-js-jumpMenuBox', 'Constant Editor');
147  $I->waitForText('No TypoScript record');
148  $I->see('No TypoScript record on the current page');
149  $I->see('You need to create a TypoScript record in order to edit your configuration.');
150  $I->seeLink('Select this TypoScript record');
151  $I->clickWithLeftButton('//a[text()[normalize-space(.) = "Select this TypoScript record"]]');
152 
153  $I->wantTo('see that the page has a TypoScript record');
154  $I->waitForElementVisible('.t3-js-jumpMenuBox');
155  $I->waitForElementNotVisible('#nprogress', 120);
156  $I->selectOption('.t3-js-jumpMenuBox', 'Edit TypoScript Record');
157  $I->waitForElement('.table-striped');
158  $I->waitForText('Title');
159  $I->see('Title');
160  $I->waitForText('Description');
161  $I->see('Description');
162  $I->waitForText('Constants');
163  $I->see('Constants');
164  $I->waitForText('Setup');
165  $I->see('Setup');
166  $I->waitForText('Edit the whole TypoScript record');
167  $I->see('Edit the whole TypoScript record');
168  $I->click('Edit the whole TypoScript record');
169  // Avoid race condition:
170  // SEVERE - http://web/typo3/sysext/backend/Resources/Public/JavaScript/code-editor/autocomplete/ts-ref.js?bust=[…]
171  // 12:613 Uncaught TypeError: Cannot convert undefined or null to object
172  $I->waitForElementNotVisible('#nprogress', 120);
173  }
174 
175  public function ‪createExtensionTemplate(‪ApplicationTester $I, ‪PageTree $pageTree): void
176  {
177  $I->wantTo('see the button to create an additional TypoScript record');
178  $I->switchToMainFrame();
179  $pageTree->‪openPath(['styleguide frontend demo', 'menu_sitemap_pages']);
180  $I->clickWithLeftButton('//*[text()=\'menu_sitemap_pages\']');
181  $I->switchToContentFrame();
182  $I->waitForElementVisible('.t3-js-jumpMenuBox');
183  $I->waitForElementNotVisible('#nprogress', 120);
184  $I->selectOption('.t3-js-jumpMenuBox', 'Constant Editor');
185  $I->waitForText('No TypoScript record');
186  $I->see('No TypoScript record on the current page');
187  $I->see('You need to create a TypoScript record in order to edit your configuration.');
188  $I->clickWithLeftButton('//input[@name=\'createExtension\']');
189  $I->wantTo('see that the page has a TypoScript record');
190  $I->waitForElementVisible('.t3-js-jumpMenuBox');
191  $I->waitForElementNotVisible('#nprogress', 120);
192  $I->selectOption('.t3-js-jumpMenuBox', 'Edit TypoScript Record');
193  $I->waitForElement('.table-striped');
194  $I->waitForText('Title');
195  $I->see('Title');
196  $I->waitForText('Description');
197  $I->see('Description');
198  $I->waitForText('Constants');
199  $I->see('Constants');
200  $I->waitForText('Setup');
201  $I->see('Setup');
202  $I->waitForText('Edit the whole TypoScript record');
203  $I->see('Edit the whole TypoScript record');
204  $I->click('Edit the whole TypoScript record');
205  $I->waitForText('Edit TypoScript record "+ext" on page "menu_sitemap_pages"');
206  $I->wait(2); // wait for code mirror init
207  }
208 
213  {
214  $I->wantTo('Open the TypoScript Object Browser and search a keyword.');
215  $I->switchToMainFrame();
216  $I->clickWithLeftButton('//*[text()=\'styleguide TCA demo\']');
217  $I->switchToContentFrame();
218  $I->waitForElementVisible('.t3-js-jumpMenuBox');
219  $I->waitForElementNotVisible('#nprogress', 120);
220  $I->selectOption('.t3-js-jumpMenuBox', 'Active TypoScript');
221  $I->waitForText('Active TypoScript for record');
222  $I->amGoingTo('type "styles" into the search field and submit.');
223  $I->fillField('#searchValue', 'styles');
224  $I->waitForText('Setup');
225  $I->waitForText('1 search match(es)');
226  $I->seeInSource('<strong data-markjs="true" class="text-danger">styles</strong>');
227  }
228 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\checkClosestTemplateButton
‪checkClosestTemplateButton(ApplicationTester $I, PageTree $pageTree)
Definition: TemplateCest.php:137
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\searchInTypoScriptActive
‪searchInTypoScriptActive(ApplicationTester $I)
Definition: TemplateCest.php:212
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\createExtensionTemplate
‪createExtensionTemplate(ApplicationTester $I, PageTree $pageTree)
Definition: TemplateCest.php:175
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\pagesWithNoTemplateShouldShowButtonsToCreateTemplates
‪pagesWithNoTemplateShouldShowButtonsToCreateTemplates(ApplicationTester $I)
Definition: TemplateCest.php:35
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template
Definition: TemplateCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\AbstractTree\openPath
‪openPath(array $path)
Definition: AbstractTree.php:55
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\_before
‪_before(ApplicationTester $I)
Definition: TemplateCest.php:25
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest
Definition: TemplateCest.php:24
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Template\TemplateCest\addANewSiteTemplate
‪addANewSiteTemplate(ApplicationTester $I)
Definition: TemplateCest.php:60