beabb971ec3430db7dd1d0629132bcc4e6e095c0
[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\TestingFramework\Core\Acceptance\Step\Backend\Admin;
19 use TYPO3\TestingFramework\Core\Acceptance\Support\Helper\ModalDialog;
20 use TYPO3\TestingFramework\Core\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('list_frame');
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('list_frame');
77
78 $I->click(self::$docHeaderBookmarkButtonSelector);
79 // cancel the action to test the functionality
80 // don't use $modalDialog->clickButtonInDialog due to too low timeout
81 $dialog->canSeeDialog();
82 $I->click('Cancel', ModalDialog::$openedModalButtonContainerSelector);
83 $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
84
85 // check if the list is still empty
86 $this->checkThatBookmarkListIsInitiallyEmpty($I);
87
88 $I->switchToIFrame('list_frame');
89 $I->click(self::$docHeaderBookmarkButtonSelector);
90
91 $dialog->clickButtonInDialog('OK');
92
93 $this->clickBookmarkDropdownToggleInTopbar($I);
94 $I->waitForText('Scheduled tasks', 15, self::$topBarModuleSelector . ' ' . Topbar::$dropdownListSelector);
95
96 // @test complete test when https://forge.typo3.org/issues/75689 is fixed
97 $scenario->comment(
98 'Tests for deleting the item in the list and readding it are missing ' .
99 'as this is currently broken in the core. See https://forge.typo3.org/issues/75689'
100 );
101
102 return $I;
103 }
104
105 /**
106 * @param Admin $I
107 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
108 */
109 public function checkIfBookmarkItemLinksToTarget(Admin $I)
110 {
111 $this->clickBookmarkDropdownToggleInTopbar($I);
112 $I->click('Scheduled tasks', self::$topBarModuleSelector);
113 $I->switchToIFrame('list_frame');
114 $I->canSee('Scheduled tasks', 'h1');
115 }
116
117 /**
118 * @param Admin $I
119 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
120 */
121 public function checkIfEditBookmarkItemWorks(Admin $I)
122 {
123 $this->clickBookmarkDropdownToggleInTopbar($I);
124 $firstShortcutSelector = self::$topBarModuleSelector . ' .t3js-topbar-shortcut';
125 $I->click('.t3js-shortcut-edit', $firstShortcutSelector);
126 $secondShortcutSelector = self::$topBarModuleSelector . ' form.shortcut-form';
127 $I->fillField($secondShortcutSelector . ' input[name="shortcut-title"]', 'Scheduled tasks renamed');
128 $I->click('.shortcut-form-save', $secondShortcutSelector);
129
130 // searching in a specific context fails with an "Stale Element Reference Exception"
131 // see http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp
132 // currently don't know how to fix that so we search in the whole context.
133 $I->waitForText('Scheduled tasks renamed');
134 }
135
136 /**
137 * @param Admin $I
138 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
139 */
140 public function checkIfDeleteBookmarkWorks(Admin $I, ModalDialog $dialog)
141 {
142 $this->clickBookmarkDropdownToggleInTopbar($I);
143
144 $I->canSee('Scheduled tasks renamed', self::$topBarModuleSelector);
145 $I->click('.t3js-shortcut-delete', self::$topBarModuleSelector . ' .t3js-topbar-shortcut');
146 $dialog->clickButtonInDialog('OK');
147
148 $I->cantSee('Scheduled tasks renamed', self::$topBarModuleSelector);
149 }
150
151 /**
152 * @param Admin $I
153 */
154 protected function clickBookmarkDropdownToggleInTopbar(Admin $I)
155 {
156 $I->click(Topbar::$dropdownToggleSelector, self::$topBarModuleSelector);
157 }
158 }