‪TYPO3CMS  11.5
AddPageInPageModuleCest.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 PHPUnit\Framework\SkippedTestError;
22 
27 {
28  public function ‪_before(‪ApplicationTester $I): void
29  {
30  $I->useExistingSession('admin');
31  }
32 
37  public function ‪addAndDeletePage(‪ApplicationTester $I): void
38  {
39  // @todo: Fix in high load scenarios or throw away
40  $this->‪skipUnstable();
41 
42  // Select page module
43  $I->wantToTest('Add a page with page module');
44  $I->click('Page');
45 
46  // New page from root page
47  $typo3NavigationContainer = '.scaffold-content-navigation-component';
48  $I->waitForElement($typo3NavigationContainer);
49  $rootNode = 'a.x-tree-node-anchor > span';
50  $rootNodeIcon = '#identifier-0_0 .node-icon';
51  $rootNodeContextMenuMore = '#contentMenu0 a.list-group-item-submenu';
52  //create new wizard
53  $contextMenuNew = '#contentMenu1 .list-group-item[data-callback-action=newPageWizard]';
54 
55  $I->waitForElement($rootNode);
56  $I->click($rootNodeIcon);
57  $I->waitForElementVisible($rootNodeContextMenuMore);
58 
59  $I->wait(1);
60  $I->click($rootNodeContextMenuMore);
61  $I->waitForElementVisible($contextMenuNew, 30);
62  $I->click($contextMenuNew);
63 
64  $I->switchToContentFrame();
65 
66  // New page select position wizard
67  $I->click('i[title="Insert the new page here"]');
68 
69  // FormEngine new page record
70  $saveButton = 'body > div > div.module-docheader.t3js-module-docheader > div.module-docheader-bar.module-docheader-bar-buttons.t3js-module-docheader-bar.t3js-module-docheader-bar-buttons > div.module-docheader-bar-column-left > div > div > button:nth-child(1)';
71  $I->waitForElement($saveButton);
72 
73  // Check empty
74  $I->amGoingTo('check empty error');
75  $I->wait(2);
76  $editControllerDiv = '#EditDocumentController > div';
77  $generalTab = $editControllerDiv . ' > div:nth-child(1) > ul > li';
78  $classString = $I->executeInSelenium(static function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
79  $generalTab
80  ) {
81  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector($generalTab))->getAttribute('class');
82  });
83  $I->assertStringContainsString('has-validation-error', $classString);
84 
85  // Add page
86  $pageTitleFieldset = $editControllerDiv . ' > div:nth-of-type(1) > div > div.tab-pane:nth-child(1) > fieldset:nth-child(2)';
87  $I->seeElement($pageTitleFieldset . ' > div > div.t3js-formengine-validation-marker.has-error');
88 
89  $pageTitleInput = $pageTitleFieldset . ' > div > div:nth-child(1) > div > div.form-control-wrap > div.form-wizards-wrap > div.form-wizards-element > div > input';
90  $I->fillField($pageTitleInput, 'Testpage');
91  $I->click($saveButton);
92  $I->waitForElement($pageTitleInput);
93  $I->assertEquals('Testpage', $I->grabValueFrom($pageTitleInput), 'Value in input field.');
94  $I->dontSeeElement($pageTitleFieldset . ' > div > div.t3js-formengine-validation-marker.has-error');
95  $I->switchToMainFrame();
96 
97  // Check tree
98  $I->waitForElement($typo3NavigationContainer);
99  $pageInTree = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > a > span';
100  $I->assertEquals('Testpage', $I->grabTextFrom($pageInTree), 'Value in tree.');
101 
102  // And delete page from tree
103  $pageInTreeIcon = '#typo3-pagetree-tree .icon-apps-pagetree-page-default';
104  $delete = '#contentMenu0 .list-group-item[data-callback-action=deleteRecord]';
105  $I->click($pageInTreeIcon);
106  $I->waitForElement($delete);
107  $I->click($delete);
108  $yesButtonInPopup = '.modal-dialog button[name=delete]';
109  $I->waitForElement($yesButtonInPopup);
110  $I->click($yesButtonInPopup);
111  $I->wait(2);
112  $I->cantSee('Testpage');
113  }
114 
118  protected function ‪skipUnstable(): void
119  {
120  throw new SkippedTestError('Test unstable, skipped for now.');
121  }
122 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Page\AddPageInPageModuleCest
Definition: AddPageInPageModuleCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Page
Definition: AddPageInPageModuleCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Page\AddPageInPageModuleCest\addAndDeletePage
‪addAndDeletePage(ApplicationTester $I)
Definition: AddPageInPageModuleCest.php:37
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Page\AddPageInPageModuleCest\_before
‪_before(ApplicationTester $I)
Definition: AddPageInPageModuleCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Page\AddPageInPageModuleCest\skipUnstable
‪skipUnstable()
Definition: AddPageInPageModuleCest.php:118