[BUGFIX] Acceptance tests fails due to viewport changes
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Topbar / BookmarkCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
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 Codeception\Scenario;
18 use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
19 use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
20 use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
21
22 /**
23 * Test for the "Bookmark" functionality
24 */
25 class BookmarkCest
26 {
27 /**
28 * Selector for the module container in the topbar
29 *
30 * @var string
31 */
32 public static $topBarModuleSelector = '#typo3-cms-backend-backend-toolbaritems-shortcuttoolbaritem';
33
34 /**
35 * Selector for the "Add to bookmark" button
36 *
37 * @var string
38 */
39 protected static $docHeaderBookmarkButtonSelector = '.module-docheader .btn[title="Create a bookmark to this page"]';
40
41 /**
42 * @param Admin $I
43 */
44 public function _before(Admin $I)
45 {
46 $I->useExistingSession();
47 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
48 $I->switchToIFrame('contentIframe');
49 $I->waitForText('Web Content Management System');
50 $I->switchToIFrame();
51 }
52
53 /**
54 * @param Admin $I
55 * @return Admin
56 */
57 public function checkThatBookmarkListIsInitiallyEmpty(Admin $I)
58 {
59 $this->clickBookmarkDropdownToggleInTopbar($I);
60 $I->cantSeeElement(self::$topBarModuleSelector . ' .shortcut');
61 return $I;
62 }
63
64 /**
65 * @depends checkThatBookmarkListIsInitiallyEmpty
66 * @param Admin $I
67 * @param ModalDialog $dialog
68 * @return Admin
69 */
70 public function checkThatAddingABookmarkAddsItemToTheBookmarkList(Admin $I, ModalDialog $dialog, Scenario $scenario)
71 {
72 $I->switchToIFrame();
73 // open the scheduler module as we would like to put it into the bookmark liste
74 $I->click('Scheduler', '.scaffold-modulemenu');
75
76 $I->switchToIFrame('contentIframe');
77
78 $I->click(self::$docHeaderBookmarkButtonSelector);
79 // cancel the action to test the functionality
80 $dialog->clickButtonInDialog('Cancel');
81
82 // check if the list is still empty
83 $this->checkThatBookmarkListIsInitiallyEmpty($I);
84
85 $I->switchToIFrame('contentIframe');
86 $I->click(self::$docHeaderBookmarkButtonSelector);
87
88 $dialog->clickButtonInDialog('OK');
89
90 $this->clickBookmarkDropdownToggleInTopbar($I);
91 $I->waitForText('Scheduled tasks', 15, self::$topBarModuleSelector . ' ' . Topbar::$dropdownListSelector);
92
93 // @test complete test when https://forge.typo3.org/issues/75689 is fixed
94 $scenario->comment(
95 'Tests for deleting the item in the list and readding it are missing ' .
96 'as this is currently broken in the core. See https://forge.typo3.org/issues/75689'
97 );
98
99 return $I;
100 }
101
102 /**
103 * @param Admin $I
104 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
105 */
106 public function checkIfBookmarkItemLinksToTarget(Admin $I)
107 {
108 $this->clickBookmarkDropdownToggleInTopbar($I);
109 $I->click('Scheduled tasks', self::$topBarModuleSelector);
110 $I->switchToIFrame('contentIframe');
111 $I->canSee('Scheduled tasks', 'h1');
112 }
113
114 /**
115 * @param Admin $I
116 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
117 */
118 public function checkIfEditBookmarkItemWorks(Admin $I)
119 {
120 $this->clickBookmarkDropdownToggleInTopbar($I);
121 $firstShortcutSelector = self::$topBarModuleSelector . ' .t3js-topbar-shortcut';
122 $I->click('.t3js-shortcut-edit', $firstShortcutSelector);
123 $secondShortcutSelector = self::$topBarModuleSelector . ' form.shortcut-form';
124 $I->fillField($secondShortcutSelector . ' input[name="shortcut-title"]', 'Scheduled tasks renamed');
125 $I->click('.shortcut-form-save', $secondShortcutSelector);
126
127 // searching in a specific context fails with an "Stale Element Reference Exception"
128 // see http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp
129 // currently don't know how to fix that so we search in the whole context.
130 $I->waitForText('Scheduled tasks renamed');
131 }
132
133 /**
134 * @param Admin $I
135 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
136 */
137 public function checkIfDeleteBookmarkWorks(Admin $I, ModalDialog $dialog)
138 {
139 $this->clickBookmarkDropdownToggleInTopbar($I);
140
141 $I->canSee('Scheduled tasks renamed', self::$topBarModuleSelector);
142 $I->click('.t3js-shortcut-delete', self::$topBarModuleSelector . ' .t3js-topbar-shortcut');
143 $dialog->clickButtonInDialog('OK');
144
145 $I->cantSee('Scheduled tasks renamed', self::$topBarModuleSelector);
146 }
147
148 /**
149 * @param Admin $I
150 */
151 protected function clickBookmarkDropdownToggleInTopbar(Admin $I)
152 {
153 $I->click(Topbar::$dropdownToggleSelector, self::$topBarModuleSelector);
154 }
155 }