‪TYPO3CMS  11.5
ContentElementsCest.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 Facebook\WebDriver\Remote\RemoteWebDriver;
23 
25 {
26  protected string ‪$sidebar = '.sidebar.list-group';
27 
28  public function ‪_before(‪ApplicationTester $I, ‪PageTree $pageTree): void
29  {
30  $I->useExistingSession('admin');
31  $I->click('Page');
32  $I->waitForElement('#typo3-pagetree-tree .nodes .node', 5);
33  $pageTree->‪openPath(['styleguide frontend demo']);
34  $I->switchToContentFrame();
35  $I->waitForElementVisible('select[name=actionMenu]');
36  $I->selectOption('select[name=actionMenu]', 'Columns');
37  $I->wait(1);
38  $I->waitForElementVisible('.t3js-module-docheader-bar a[title="View webpage"]');
39  $I->wait(1);
40  $I->click('.t3js-module-docheader-bar a[title="View webpage"]');
41  $I->wait(1);
42  $I->executeInSelenium(static function (RemoteWebDriver $webdriver) {
43  $handles = $webdriver->getWindowHandles();
44  $lastWindow = end($handles);
45  $webdriver->switchTo()->window($lastWindow);
46  });
47  $I->wait(1);
48  $I->see('TYPO3 Styleguide Frontend', '.content');
49  }
50 
51  public function ‪_after(‪ApplicationTester $I): void
52  {
53  // Close FE tab again and switch to BE to avoid side effects
54  $I->executeInSelenium(static function (RemoteWebDriver $webdriver) {
55  $handles = $webdriver->getWindowHandles();
56  // Avoid closing the main backend tab (holds the webdriver session) if the test failed to open the frontend tab
57  // (All subsequent tests would fail with "[Facebook\WebDriver\Exception\InvalidSessionIdException] invalid session id"
58  if (count($handles) > 1) {
59  $webdriver->close();
60  $firstWindow = current($handles);
61  $webdriver->switchTo()->window($firstWindow);
62  }
63  });
64  }
65 
67  {
68  $I->see('styleguide frontend demo');
69  foreach ($this->‪contentElementsDataProvider() as $contentElement) {
70  $I->scrollTo('//a[contains(., "' . $contentElement['link'] . '")]');
71  $I->click($contentElement['link'], $this->sidebar);
72  foreach ($contentElement['seeElement'] ?? [] as $element) {
73  $I->seeElement($element);
74  }
75  foreach ($contentElement['see'] ?? [] as $text) {
76  $I->see($text, '.content.col');
77  }
78  }
79  }
80 
81  protected function ‪contentElementsDataProvider(): array
82  {
83  return [
84  [
85  'link' => 'bullets',
86  'seeElement' => ['.ce-bullets'],
87  'see' => [
88  'Another bullet list',
89  'A bullet list',
90  ],
91  ],
92  [
93  'link' => 'div',
94  'seeElement' => ['hr.ce-div'],
95  ],
96  [
97  'link' => 'header',
98  'seeElement' => ['.frame-type-header'],
99  'see' => [
100  'Bacon ipsum dolor sit strong amet capicola jerky pork chop rump shoulder shank. Shankle strip steak pig salami link.',
101  ],
102  ],
103  [
104  'link' => 'text',
105  'seeElement' => ['.frame-type-text', '.content.col a'],
106  'see' => [
107  'Bacon ipsum dolor sit strong amet capicola jerky pork chop rump shoulder shank. Shankle strip steak pig salami link.',
108  ],
109  ],
110  [
111  'link' => 'textpic',
112  'seeElement' => ['.frame-type-textpic', '.content.col a', '.ce-gallery img'],
113  'see' => [
114  'Bacon ipsum dolor sit strong amet capicola jerky pork chop rump shoulder shank. Shankle strip steak pig salami link.',
115  ],
116  ],
117  [
118  'link' => 'textmedia',
119  'seeElement' => ['.frame-type-textmedia', '.content.col a', '.ce-gallery img'],
120  'see' => [
121  'Bacon ipsum dolor sit strong amet capicola jerky pork chop rump shoulder shank. Shankle strip steak pig salami link.',
122  ],
123  ],
124  [
125  'link' => 'image',
126  'seeElement' => ['.frame-type-image', '.ce-gallery img'],
127  'see' => [
128  'Bacon ipsum dolor sit strong amet capicola jerky pork chop rump shoulder shank. Shankle strip steak pig salami link.',
129  ],
130  ],
131  [
132  'link' => 'html',
133  'seeElement' => ['.frame-type-html', '.content.col a', '.content.col strong'],
134  'see' => [
135  'Bacon ipsum dolor sit strong amet capicola jerky pork chop rump shoulder shank. Shankle strip steak pig salami link.',
136  ],
137  ],
138  [
139  'link' => 'table',
140  'seeElement' => ['.frame-type-table', 'table.table'],
141  'see' => [
142  'row4 col4',
143  ],
144  ],
145  [
146  'link' => 'shortcut',
147  'seeElement' => [
148  '.frame-type-shortcut',
149  '.content.col a',
150  ],
151  'see' => [
152  'Bacon ipsum dolor sit strong amet capicola jerky pork chop rump shoulder shank. Shankle strip steak pig salami link.',
153  ],
154  ],
155  [
156  'link' => 'uploads',
157  'seeElement' => [
158  '.frame-type-uploads',
159  '.ce-uploads',
160  ],
161  'see' => [
162  'bus_lane.jpg',
163  'telephone_box.jpg',
164  'underground.jpg',
165  ],
166  ],
167  [
168  'link' => 'menu_categorized_pages',
169  'seeElement' => [
170  '.frame-type-menu_categorized_pages ul li',
171  ],
172  'see' => [
173  'Menu categorized pages',
174  ],
175  ],
176  [
177  'link' => 'menu_categorized_content',
178  'seeElement' => [
179  '.frame-type-menu_categorized_content ul li',
180  ],
181  'see' => [
182  'Menu categorized content',
183  ],
184  ],
185  [
186  'link' => 'menu_pages',
187  'seeElement' => [
188  '.frame-type-menu_pages ul li',
189  ],
190  'see' => [
191  'Menu pages',
192  ],
193  ],
194  [
195  'link' => 'menu_subpages',
196  'seeElement' => [
197  '.frame-type-menu_subpages ul li',
198  ],
199  'see' => [
200  'Menu subpages',
201  ],
202  ],
203  [
204  'link' => 'menu_sitemap',
205  'seeElement' => [
206  '.frame-type-menu_sitemap ul li',
207  ],
208  'see' => [
209  'Menu sitemap',
210  ],
211  ],
212  [
213  'link' => 'menu_section',
214  'seeElement' => [
215  '.frame-type-menu_section ul ul li',
216  ],
217  'see' => [
218  'Menu section',
219  ],
220  ],
221  [
222  'link' => 'menu_abstract',
223  'seeElement' => [
224  '.frame-type-menu_abstract ul li a',
225  '.frame-type-menu_abstract ul li p',
226  ],
227  'see' => [
228  'Menu abstract',
229  ],
230  ],
231  [
232  'link' => 'menu_recently_updated',
233  'seeElement' => [
234  '.frame-type-menu_recently_updated ul li',
235  ],
236  'see' => [
237  'Menu recently updated',
238  ],
239  ],
240  [
241  'link' => 'menu_related_pages',
242  'seeElement' => [
243  '.frame-type-menu_related_pages ul li',
244  ],
245  'see' => [
246  'Menu related pages',
247  ],
248  ],
249  [
250  'link' => 'menu_section_pages',
251  'seeElement' => [
252  '.frame-type-menu_section_pages ul ul',
253  ],
254  'see' => [
255  'Menu section pages',
256  ],
257  ],
258  [
259  'link' => 'menu_sitemap_pages',
260  'seeElement' => [
261  '.frame-type-menu_sitemap_pages ul li',
262  ],
263  'see' => [
264  'Menu sitemap pages',
265  ],
266  ],
267  ];
268  }
269 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\ContentElementsCest\contentElementsDataProvider
‪contentElementsDataProvider()
Definition: ContentElementsCest.php:81
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\ContentElementsCest\_before
‪_before(ApplicationTester $I, PageTree $pageTree)
Definition: ContentElementsCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend
Definition: ContentElementsCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\openPath
‪openPath(array $path)
Definition: PageTree.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\ContentElementsCest\$sidebar
‪string $sidebar
Definition: ContentElementsCest.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\ContentElementsCest
Definition: ContentElementsCest.php:25
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\ContentElementsCest\seeAllContentElements
‪seeAllContentElements(ApplicationTester $I)
Definition: ContentElementsCest.php:66
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\ContentElementsCest\_after
‪_after(ApplicationTester $I)
Definition: ContentElementsCest.php:51