a678d9d216eb86e1e0796bbcfff2b70b6d3c5e6e
[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\TestingFramework\Core\Acceptance\Step\Backend\Admin;
18
19 /**
20 * Page and page tree related tests.
21 */
22 class AddPageInPageModuleCest
23 {
24 public function _before(Admin $I)
25 {
26 $I->useExistingSession();
27 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
28 $I->switchToIFrame('list_frame');
29 $I->waitForText('Web Content Management System');
30 $I->switchToIFrame();
31 }
32
33 /**
34 * This test case is used to check if a page can be added with the page module.
35 * It also tests to remove the new page with the page tree context menu.
36 *
37 * @param Admin $I
38 */
39 public function addAndDeletePage(Admin $I)
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 = '#extdd-1 .icon-apps-pagetree-root';
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 // Switch to content frame
64 $I->switchToIFrame('list_frame');
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(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
79 $generalTab
80 ) {
81 return $webdriver->findElement(\WebDriverBy::cssSelector($generalTab))->getAttribute('class');
82 });
83 $I->assertContains('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->switchToIFrame();
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 }