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