[TASK] Stabilize acceptance tests
[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 }
48
49 /**
50 * @param Admin $I
51 * @return Admin
52 */
53 public function checkThatBookmarkListIsInitiallyEmpty(Admin $I)
54 {
55 $this->clickBookmarkDropdownToggleInTopbar($I);
56 $I->cantSeeElement(self::$topBarModuleSelector . ' .shortcut');
57 return $I;
58 }
59
60 /**
61 * @depends checkThatBookmarkListIsInitiallyEmpty
62 * @param Admin $I
63 * @param ModalDialog $dialog
64 * @return Admin
65 */
66 public function checkThatAddingABookmarkAddsItemToTheBookmarkList(Admin $I, ModalDialog $dialog, Scenario $scenario)
67 {
68 // open the scheduler module as we would like to put it into the bookmark liste
69 $I->click('Scheduler', '.scaffold-modulemenu');
70
71 $I->switchToContentFrame();
72
73 $I->click(self::$docHeaderBookmarkButtonSelector);
74 // cancel the action to test the functionality
75 // don't use $modalDialog->clickButtonInDialog due to too low timeout
76 $dialog->canSeeDialog();
77 $I->click('Cancel', ModalDialog::$openedModalButtonContainerSelector);
78 $I->waitForElementNotVisible(ModalDialog::$openedModalSelector, 30);
79
80 // check if the list is still empty
81 $this->checkThatBookmarkListIsInitiallyEmpty($I);
82
83 $I->switchToContentFrame();
84 $I->click(self::$docHeaderBookmarkButtonSelector);
85
86 $dialog->clickButtonInDialog('OK');
87
88 $this->clickBookmarkDropdownToggleInTopbar($I);
89 $I->waitForText('Scheduled tasks', 15, self::$topBarModuleSelector . ' ' . Topbar::$dropdownListSelector);
90
91 // @test complete test when https://forge.typo3.org/issues/75689 is fixed
92 $scenario->comment(
93 'Tests for deleting the item in the list and readding it are missing ' .
94 'as this is currently broken in the core. See https://forge.typo3.org/issues/75689'
95 );
96
97 return $I;
98 }
99
100 /**
101 * @param Admin $I
102 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
103 */
104 public function checkIfBookmarkItemLinksToTarget(Admin $I)
105 {
106 $this->clickBookmarkDropdownToggleInTopbar($I);
107 $I->click('Scheduled tasks', self::$topBarModuleSelector);
108 $I->switchToContentFrame();
109 $I->canSee('Scheduled tasks', 'h1');
110 }
111
112 /**
113 * @param Admin $I
114 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
115 */
116 public function checkIfEditBookmarkItemWorks(Admin $I)
117 {
118 $this->clickBookmarkDropdownToggleInTopbar($I);
119 $firstShortcutSelector = self::$topBarModuleSelector . ' .t3js-topbar-shortcut';
120 $I->click('.t3js-shortcut-edit', $firstShortcutSelector);
121 $secondShortcutSelector = self::$topBarModuleSelector . ' form.shortcut-form';
122 $I->fillField($secondShortcutSelector . ' input[name="shortcut-title"]', 'Scheduled tasks renamed');
123 $I->click('.shortcut-form-save', $secondShortcutSelector);
124
125 // searching in a specific context fails with an "Stale Element Reference Exception"
126 // see http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp
127 // currently don't know how to fix that so we search in the whole context.
128 $I->waitForText('Scheduled tasks renamed');
129 }
130
131 /**
132 * @param Admin $I
133 * @depends checkThatAddingABookmarkAddsItemToTheBookmarkList
134 */
135 public function checkIfDeleteBookmarkWorks(Admin $I, ModalDialog $dialog)
136 {
137 $this->clickBookmarkDropdownToggleInTopbar($I);
138
139 $I->canSee('Scheduled tasks renamed', self::$topBarModuleSelector);
140 $I->click('.t3js-shortcut-delete', self::$topBarModuleSelector . ' .t3js-topbar-shortcut');
141 $dialog->clickButtonInDialog('OK');
142
143 $I->cantSee('Scheduled tasks renamed', self::$topBarModuleSelector);
144 }
145
146 /**
147 * @param Admin $I
148 */
149 protected function clickBookmarkDropdownToggleInTopbar(Admin $I)
150 {
151 $I->waitForElementVisible(self::$topBarModuleSelector . ' ' . Topbar::$dropdownToggleSelector);
152 $I->click(Topbar::$dropdownToggleSelector, self::$topBarModuleSelector);
153 }
154 }