643439ac24339b780c64ccca4f5ee015274546c2
[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 TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Kasper;
18
19 /**
20 * This testcase is used to check if a page can be added with the page module.
21 * It also tests to remove the new page with the page tree context menu.
22 */
23 class AddPageInPageModuleCest
24 {
25 public function _before(Kasper $I)
26 {
27 $I->loginAsAdmin();
28 }
29
30 public function _after(Kasper $I)
31 {
32 $I->logout();
33 }
34
35 /**
36 * @param Kasper $I
37 */
38 public function tryToTest(Kasper $I)
39 {
40 // Select page module
41 $I->wantToTest('Add a page with page module');
42 $I->click('Page');
43
44 // New page from root page
45 $typo3NavigationContainer = '#typo3-navigationContainer';
46 $I->waitForElement($typo3NavigationContainer);
47 $rootNode = 'a.x-tree-node-anchor > span';
48 $rootNodeIcon = '#extdd-1 > span.t3js-icon.icon.icon-size-small.icon-state-default.icon-apps-pagetree-root';
49 $contextMenuNew = '#typo3-pagetree-contextmenu > ul > li.x-menu-list-item:nth-of-type(2) > a > span.x-menu-item-text';
50 $I->waitForElement($rootNode);
51 $I->click($rootNodeIcon);
52 $I->waitForElement($contextMenuNew);
53 $I->click($contextMenuNew);
54
55 // Switch to content frame
56 $I->switchToIFrame('content');
57
58 // New page select position wizard
59 $I->click('i[title="Insert the new page here"]');
60
61 // FormEngine new page record
62 $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)';
63 $I->waitForElement($saveButton);
64
65 // Check empty
66 $I->amGoingTo('check empty error');
67 $I->click($saveButton);
68 $I->wait(2);
69 $editControllerDiv = '#EditDocumentController > div';
70 $generalTab = $editControllerDiv . ' > div:nth-child(1) > ul > li';
71 $classString = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
72 $generalTab
73 ) {
74 return $webdriver->findElement(\WebDriverBy::cssSelector($generalTab))->getAttribute('class');
75 });
76 $I->assertContains('has-validation-error', $classString);
77
78 // Add page
79 $pageTitle = $editControllerDiv . ' > div:nth-child(1) > div > div.tab-pane:nth-child(1) > fieldset:nth-child(2) > div > div:nth-child(1) > div > div.form-control-wrap > div > input';
80 $I->fillField($pageTitle, 'Testpage');
81 $I->click($saveButton);
82 $I->waitForElement($pageTitle);
83 $I->assertEquals('Testpage', $I->grabValueFrom($pageTitle), 'Value in input field.');
84 $I->switchToIFrame();
85
86 // Check tree
87 $I->waitForElement($typo3NavigationContainer);
88 $pageInTree = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > a > span';
89 $I->assertEquals('Testpage', $I->grabTextFrom($pageInTree), 'Value in tree.');
90
91 // And delete page from tree
92 $pageInTreeIcon = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > span.t3js-icon.icon.icon-size-small.icon-state-default.icon-apps-pagetree-page-default';
93 $pageActions = '#typo3-pagetree-contextmenu > ul > li:nth-child(8) > a > span.x-menu-item-text';
94 $delete = '#typo3-pagetree-contextmenu-sub1 > ul > li:nth-child(6) > a > span.x-menu-item-text';
95 $I->click($pageInTreeIcon);
96 $I->waitForElement('#typo3-pagetree-contextmenu');
97 $I->waitForElement($pageActions);
98 $I->moveMouseOver($pageActions);
99 $I->waitForElement('#typo3-pagetree-contextmenu-sub1');
100 $I->click($delete);
101 $yesButtonPopup = '#main > div.x-window.x-window-plain.x-window-dlg > div.x-window-bwrap > div.x-window-bl > div > div > div > div.x-panel-fbar.x-small-editor.x-toolbar-layout-ct > table > tbody > tr > td.x-toolbar-left > table > tbody > tr > td:nth-child(2) > table > tbody > tr:nth-child(2) > td.x-btn-mc > em > button';
102 $I->waitForElement($yesButtonPopup);
103 $I->click($yesButtonPopup);
104 $I->wait(2);
105 $I->cantSee('Testpage');
106 }
107 }