[TASK] Stabilize acceptance tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Page / AddPageInPageModuleCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Page;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use PHPUnit\Framework\SkippedTestError;
18 use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
19
20 /**
21 * Page and page tree related tests.
22 */
23 class AddPageInPageModuleCest
24 {
25 public function _before(Admin $I)
26 {
27 $I->useExistingSession();
28 }
29
30 /**
31 * This test case is used to check if a page can be added with the page module.
32 * It also tests to remove the new page with the page tree context menu.
33 *
34 * @param Admin $I
35 */
36 public function addAndDeletePage(Admin $I)
37 {
38 // @todo: Fix in high load scenarios or throw away
39 $this->skipUnstable();
40
41 // Select page module
42 $I->wantToTest('Add a page with page module');
43 $I->click('Page');
44
45 // New page from root page
46 $typo3NavigationContainer = '.scaffold-content-navigation-component';
47 $I->waitForElement($typo3NavigationContainer);
48 $rootNode = 'a.x-tree-node-anchor > span';
49 $rootNodeIcon = '.node.identifier-0_0 .node-icon';
50 $rootNodeContextMenuMore = '#contentMenu0 a.list-group-item-submenu';
51 //create new wizard
52 $contextMenuNew = '#contentMenu1 .list-group-item[data-callback-action=newPageWizard]';
53
54 $I->waitForElement($rootNode);
55 $I->click($rootNodeIcon);
56 $I->waitForElementVisible($rootNodeContextMenuMore);
57
58 $I->wait(1);
59 $I->click($rootNodeContextMenuMore);
60 $I->waitForElementVisible($contextMenuNew, 30);
61 $I->click($contextMenuNew);
62
63 $I->switchToContentFrame();
64
65 // New page select position wizard
66 $I->click('i[title="Insert the new page here"]');
67
68 // FormEngine new page record
69 $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)';
70 $I->waitForElement($saveButton);
71
72 // Check empty
73 $I->amGoingTo('check empty error');
74 $I->wait(2);
75 $editControllerDiv = '#EditDocumentController > div';
76 $generalTab = $editControllerDiv . ' > div:nth-child(1) > ul > li';
77 $classString = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
78 $generalTab
79 ) {
80 return $webdriver->findElement(\WebDriverBy::cssSelector($generalTab))->getAttribute('class');
81 });
82 $I->assertContains('has-validation-error', $classString);
83
84 // Add page
85 $pageTitleFieldset = $editControllerDiv . ' > div:nth-of-type(1) > div > div.tab-pane:nth-child(1) > fieldset:nth-child(2)';
86 $I->seeElement($pageTitleFieldset . ' > div > div.t3js-formengine-validation-marker.has-error');
87
88 $pageTitleInput = $pageTitleFieldset . ' > div > div:nth-child(1) > div > div.form-control-wrap > div.form-wizards-wrap > div.form-wizards-element > div > input';
89 $I->fillField($pageTitleInput, 'Testpage');
90 $I->click($saveButton);
91 $I->waitForElement($pageTitleInput);
92 $I->assertEquals('Testpage', $I->grabValueFrom($pageTitleInput), 'Value in input field.');
93 $I->dontSeeElement($pageTitleFieldset . ' > div > div.t3js-formengine-validation-marker.has-error');
94 $I->switchToMainFrame();
95
96 // Check tree
97 $I->waitForElement($typo3NavigationContainer);
98 $pageInTree = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > a > span';
99 $I->assertEquals('Testpage', $I->grabTextFrom($pageInTree), 'Value in tree.');
100
101 // And delete page from tree
102 $pageInTreeIcon = '#typo3-pagetree-tree .icon-apps-pagetree-page-default';
103 $delete = '#contentMenu0 .list-group-item[data-callback-action=deleteRecord]';
104 $I->click($pageInTreeIcon);
105 $I->waitForElement($delete);
106 $I->click($delete);
107 $yesButtonInPopup = '.modal-dialog button[name=delete]';
108 $I->waitForElement($yesButtonInPopup);
109 $I->click($yesButtonInPopup);
110 $I->wait(2);
111 $I->cantSee('Testpage');
112 }
113
114 /**
115 * @throws SkippedTestError
116 */
117 protected function skipUnstable()
118 {
119 throw new SkippedTestError('Test unstable, skipped for now.');
120 }
121 }