[TASK] Update codeception to 2.4.0
[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 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
29 $I->switchToIFrame('list_frame');
30 $I->waitForText('Web Content Management System');
31 $I->switchToIFrame();
32 }
33
34 /**
35 * This test case is used to check if a page can be added with the page module.
36 * It also tests to remove the new page with the page tree context menu.
37 *
38 * @param Admin $I
39 */
40 public function addAndDeletePage(Admin $I)
41 {
42 // @todo: Fix in high load scenarios or throw away
43 $this->skipUnstable();
44
45 // Select page module
46 $I->wantToTest('Add a page with page module');
47 $I->click('Page');
48
49 // New page from root page
50 $typo3NavigationContainer = '.scaffold-content-navigation-component';
51 $I->waitForElement($typo3NavigationContainer);
52 $rootNode = 'a.x-tree-node-anchor > span';
53 $rootNodeIcon = '.node.identifier-0_0 .node-icon';
54 $rootNodeContextMenuMore = '#contentMenu0 a.list-group-item-submenu';
55 //create new wizard
56 $contextMenuNew = '#contentMenu1 .list-group-item[data-callback-action=newPageWizard]';
57
58 $I->waitForElement($rootNode);
59 $I->click($rootNodeIcon);
60 $I->waitForElementVisible($rootNodeContextMenuMore);
61
62 $I->wait(1);
63 $I->click($rootNodeContextMenuMore);
64 $I->waitForElementVisible($contextMenuNew, 30);
65 $I->click($contextMenuNew);
66
67 // Switch to content frame
68 $I->switchToIFrame('list_frame');
69
70 // New page select position wizard
71 $I->click('i[title="Insert the new page here"]');
72
73 // FormEngine new page record
74 $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)';
75 $I->waitForElement($saveButton);
76
77 // Check empty
78 $I->amGoingTo('check empty error');
79 $I->wait(2);
80 $editControllerDiv = '#EditDocumentController > div';
81 $generalTab = $editControllerDiv . ' > div:nth-child(1) > ul > li';
82 $classString = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
83 $generalTab
84 ) {
85 return $webdriver->findElement(\WebDriverBy::cssSelector($generalTab))->getAttribute('class');
86 });
87 $I->assertContains('has-validation-error', $classString);
88
89 // Add page
90 $pageTitleFieldset = $editControllerDiv . ' > div:nth-of-type(1) > div > div.tab-pane:nth-child(1) > fieldset:nth-child(2)';
91 $I->seeElement($pageTitleFieldset . ' > div > div.t3js-formengine-validation-marker.has-error');
92
93 $pageTitleInput = $pageTitleFieldset . ' > div > div:nth-child(1) > div > div.form-control-wrap > div.form-wizards-wrap > div.form-wizards-element > div > input';
94 $I->fillField($pageTitleInput, 'Testpage');
95 $I->click($saveButton);
96 $I->waitForElement($pageTitleInput);
97 $I->assertEquals('Testpage', $I->grabValueFrom($pageTitleInput), 'Value in input field.');
98 $I->dontSeeElement($pageTitleFieldset . ' > div > div.t3js-formengine-validation-marker.has-error');
99 $I->switchToIFrame();
100
101 // Check tree
102 $I->waitForElement($typo3NavigationContainer);
103 $pageInTree = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > a > span';
104 $I->assertEquals('Testpage', $I->grabTextFrom($pageInTree), 'Value in tree.');
105
106 // And delete page from tree
107 $pageInTreeIcon = '#typo3-pagetree-tree .icon-apps-pagetree-page-default';
108 $delete = '#contentMenu0 .list-group-item[data-callback-action=deleteRecord]';
109 $I->click($pageInTreeIcon);
110 $I->waitForElement($delete);
111 $I->click($delete);
112 $yesButtonInPopup = '.modal-dialog button[name=delete]';
113 $I->waitForElement($yesButtonInPopup);
114 $I->click($yesButtonInPopup);
115 $I->wait(2);
116 $I->cantSee('Testpage');
117 }
118
119 /**
120 * @throws SkippedTestError
121 */
122 protected function skipUnstable()
123 {
124 throw new SkippedTestError('Test unstable, skipped for now.');
125 }
126 }