[TASK] Check if clear cache module is not visible for editor 22/47722/4
authorDirk Juettner <dirk.juettner@gmail.com>
Fri, 15 Apr 2016 18:51:55 +0000 (20:51 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 18 Apr 2016 18:02:46 +0000 (20:02 +0200)
Add an acceptance test to ensure that the clear cache menu in
the topbar is not visible for non admin users.
Also check if the Bookmark section is visible.

Resolves: #75701
Releases: master
Change-Id: Ia1f23c869e6e21c95cc5b4024fa6f0209ca25df9
Reviewed-on: https://review.typo3.org/47722
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Tested-by: Sascha Egerer <sascha@sascha-egerer.de>
Reviewed-by: Dirk Jüttner <dirk.juettner@gmail.com>
Tested-by: Dirk Jüttner <dirk.juettner@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Tests/Acceptance/Backend/Login/EditorCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/BookmarkCest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/FavoriteCest.php [deleted file]
typo3/sysext/core/Tests/Acceptance/Support/Helper/Topbar.php

index 54b36c9..d5920aa 100644 (file)
@@ -15,25 +15,32 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Login;
  */
 
 use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Kasper;
+use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
 
 /**
- * Acceptance test
+ * Editor login tests
  */
 class EditorCest
 {
-
     /**
-     * Login a non-admin user and logout again
+     * Login as a non-admin user, check visible modules and logout again
      *
      * @param Kasper $I
      */
-    public function tryToTest(Kasper $I)
+    public function loginAsEditor(Kasper $I)
     {
-        $I->wantTo('login with editor');
         $I->loginAsEditor();
 
         // user is redirected to 'about modules' after login, but must not see the 'admin tools' section
-        $I->cantSee('Admin tools');
+        $I->cantSee('Admin tools', '#typo3-menu');
+
+        $topBarItemSelector = Topbar::$containerSelector . ' ' . Topbar::$dropdownToggleSelector . ' *';
+
+        // can see bookmarks
+        $I->seeElement($topBarItemSelector, ['title' => 'Bookmarks']);
+
+        // cant see clear cache
+        $I->cantSeeElement($topBarItemSelector, ['title' => 'Clear cache']);
 
         $I->logout();
         $I->waitForElement('#t3-username');
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/BookmarkCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/BookmarkCest.php
new file mode 100644 (file)
index 0000000..34fb0c9
--- /dev/null
@@ -0,0 +1,155 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use Codeception\Scenario;
+use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
+use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
+
+/**
+ * Test for the "Bookmark" functionality
+ */
+class BookmarkCest
+{
+    /**
+     * Selector for the module container in the topbar
+     *
+     * @var string
+     */
+    public static $topBarModuleSelector = '#typo3-cms-backend-backend-toolbaritems-shortcuttoolbaritem';
+
+    /**
+     * Selector for the "Add to bookmark" button
+     *
+     * @var string
+     */
+    protected static $docHeaderBookmarkButtonSelector = '.module-docheader .btn[title="Create a bookmark to this page"]';
+
+    /**
+     * @param Admin $I
+     */
+    public function _before(Admin $I)
+    {
+        $I->useExistingSession();
+        $I->switchToIFrame('content');
+        // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
+        $I->waitForText('Web>Page module');
+    }
+
+    /**
+     * @param Admin $I
+     * @return Admin
+     */
+    public function checkThatBookmarkListIsInitiallyEmpty(Admin $I)
+    {
+        $this->clickBookmarkDropdownToggleInTopbar($I);
+        $I->cantSeeElement(self::$topBarModuleSelector . ' .shortcut');
+        return $I;
+    }
+
+    /**
+     * @depends checkThatBookmarkListIsInitiallyEmpty
+     * @param Admin $I
+     * @param ModalDialog $dialog
+     * @return Admin
+     */
+    public function checkThatAddingABookmarkAddAItemToTheBookmarkList(Admin $I, ModalDialog $dialog, Scenario $scenario)
+    {
+        $I->switchToIFrame();
+        // open the scheduler module as we would like to put it into the bookmark liste
+        $I->click('Scheduler', '#typo3-module-menu');
+
+        $I->switchToIFrame('content');
+
+        $I->click(self::$docHeaderBookmarkButtonSelector);
+        // cancel the action to test the functionality
+        $dialog->clickButtonInDialog('Cancel');
+
+        // check if the list is still empty
+        $this->checkThatBookmarkListIsInitiallyEmpty($I);
+
+        $I->switchToIFrame('content');
+        $I->click(self::$docHeaderBookmarkButtonSelector);
+
+        $dialog->clickButtonInDialog('OK');
+
+        $this->clickBookmarkDropdownToggleInTopbar($I);
+        $I->canSee('Scheduled tasks', self::$topBarModuleSelector . ' ' . Topbar::$dropdownContainerSelector);
+
+        // @test complese test when https://forge.typo3.org/issues/75689 is fixed
+        $scenario->comment(
+            'Test for deleting the item in the list and readd it are missing ' .
+            'as this is currently broken in the core. See https://forge.typo3.org/issues/75689'
+        );
+
+        return $I;
+    }
+
+    /**
+     * @param Admin $I
+     * @depends checkThatAddingABookmarkAddAItemToTheBookmarkList
+     */
+    public function checkIfBookmarkItemLinksToTarget(Admin $I)
+    {
+        $this->clickBookmarkDropdownToggleInTopbar($I);
+        $I->click('Scheduled tasks', self::$topBarModuleSelector);
+        $I->switchToIFrame('content');
+        $I->canSee('Scheduled tasks', 'h1');
+    }
+
+    /**
+     * @param Admin $I
+     * @depends checkThatAddingABookmarkAddAItemToTheBookmarkList
+     */
+    public function checkIfEditBookmarkItemWorks(Admin $I)
+    {
+        $this->clickBookmarkDropdownToggleInTopbar($I);
+        $firstShortcutSelector = self::$topBarModuleSelector . ' .shortcut';
+        $I->click('.shortcut-edit', $firstShortcutSelector);
+
+        $I->fillField($firstShortcutSelector . ' input[name="shortcut-title"]', 'Scheduled tasks renamed');
+        $I->click('.shortcut-form-save', $firstShortcutSelector);
+
+        // searching in a specific context fails with an "Stale Element Reference Exception"
+        // see http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp
+        // currently don't know how to fix that so we search in the whole context.
+        $I->waitForText('Scheduled tasks renamed');
+    }
+
+    /**
+     * @param Admin $I
+     * @depends checkThatAddingABookmarkAddAItemToTheBookmarkList
+     */
+    public function checkIfDeleteBookmarkWorks(Admin $I, ModalDialog $dialog)
+    {
+        $this->clickBookmarkDropdownToggleInTopbar($I);
+
+        $I->canSee('Scheduled tasks renamed', self::$topBarModuleSelector);
+        $I->click('.shortcut-delete', self::$topBarModuleSelector . ' .shortcut');
+        $dialog->clickButtonInDialog('OK');
+
+        $I->cantSee('Scheduled tasks renamed', self::$topBarModuleSelector);
+    }
+
+    /**
+     * @param Admin $I
+     */
+    protected function clickBookmarkDropdownToggleInTopbar(Admin $I)
+    {
+        $I->switchToIFrame();
+        $I->click(Topbar::$dropdownToggleSelector, self::$topBarModuleSelector);
+    }
+}
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/FavoriteCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/FavoriteCest.php
deleted file mode 100644 (file)
index 30b733c..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use Codeception\Scenario;
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
-
-/**
- * Test for the "Favorite" functionality
- */
-class FavoriteCest
-{
-    /**
-     * Selector for the module container in the topbar
-     *
-     * @var string
-     */
-    public static $topBarModuleSelector = '#typo3-cms-backend-backend-toolbaritems-shortcuttoolbaritem';
-
-    /**
-     * Selector for the "Add to favorite" button
-     *
-     * @var string
-     */
-    protected static $docHeaderFavoriteButtonSelector = '.module-docheader .btn[title="Create a bookmark to this page"]';
-
-    /**
-     * @param Admin $I
-     */
-    public function _before(Admin $I)
-    {
-        $I->useExistingSession();
-        $I->switchToIFrame('content');
-        // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
-        $I->waitForText('Web>Page module');
-    }
-
-    /**
-     * @param Admin $I
-     * @return Admin
-     */
-    public function checkThatFavoriteListIsInitiallyEmpty(Admin $I)
-    {
-        $this->clickFavoriteDropdownToggleInTopbar($I);
-        $I->cantSeeElement(self::$topBarModuleSelector . ' .shortcut');
-        return $I;
-    }
-
-    /**
-     * @depends checkThatFavoriteListIsInitiallyEmpty
-     * @param Admin $I
-     * @param ModalDialog $dialog
-     * @return Admin
-     */
-    public function checkThatAddingAFavoriteAddAItemToTheFavoriteList(Admin $I, ModalDialog $dialog, Scenario $scenario)
-    {
-        $I->switchToIFrame();
-        // open the scheduler module as we would like to put it into the favorite liste
-        $I->click('Scheduler', '#typo3-module-menu');
-
-        $I->switchToIFrame('content');
-
-        $I->click(self::$docHeaderFavoriteButtonSelector);
-        // cancel the action to test the functionality
-        $dialog->clickButtonInDialog('Cancel');
-
-        // check if the list is still empty
-        $this->checkThatFavoriteListIsInitiallyEmpty($I);
-
-        $I->switchToIFrame('content');
-        $I->click(self::$docHeaderFavoriteButtonSelector);
-
-        $dialog->clickButtonInDialog('OK');
-
-        $this->clickFavoriteDropdownToggleInTopbar($I);
-        $I->canSee('Scheduled tasks', self::$topBarModuleSelector . ' ' . Topbar::$dropdownContainerSelector);
-
-        // @test complese test when https://forge.typo3.org/issues/75689 is fixed
-        $scenario->comment(
-            'Test for deleting the item in the list and readd it are missing ' .
-            'as this is currently broken in the core. See https://forge.typo3.org/issues/75689'
-        );
-
-        return $I;
-    }
-
-    /**
-     * @param Admin $I
-     * @depends checkThatAddingAFavoriteAddAItemToTheFavoriteList
-     */
-    public function checkIfFavoriteItemLinksToTarget(Admin $I)
-    {
-        $this->clickFavoriteDropdownToggleInTopbar($I);
-        $I->click('Scheduled tasks', self::$topBarModuleSelector);
-        $I->switchToIFrame('content');
-        $I->canSee('Scheduled tasks', 'h1');
-    }
-
-    /**
-     * @param Admin $I
-     * @depends checkThatAddingAFavoriteAddAItemToTheFavoriteList
-     */
-    public function checkIfEditFavoriteItemWorks(Admin $I)
-    {
-        $this->clickFavoriteDropdownToggleInTopbar($I);
-        $firstShortcutSelector = self::$topBarModuleSelector . ' .shortcut';
-        $I->click('.shortcut-edit', $firstShortcutSelector);
-
-        $I->fillField($firstShortcutSelector . ' input[name="shortcut-title"]', 'Scheduled tasks renamed');
-        $I->click('.shortcut-form-save', $firstShortcutSelector);
-
-        // searching in a specific context fails with an "Stale Element Reference Exception"
-        // see http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp
-        // currently don't know how to fix that so we search in the whole context.
-        $I->waitForText('Scheduled tasks renamed');
-    }
-
-    /**
-     * @param Admin $I
-     * @depends checkThatAddingAFavoriteAddAItemToTheFavoriteList
-     */
-    public function checkIfDeleteFavoriteWorks(Admin $I, ModalDialog $dialog)
-    {
-        $this->clickFavoriteDropdownToggleInTopbar($I);
-
-        $I->canSee('Scheduled tasks renamed', self::$topBarModuleSelector);
-        $I->click('.shortcut-delete', self::$topBarModuleSelector . ' .shortcut');
-        $dialog->clickButtonInDialog('OK');
-
-        $I->cantSee('Scheduled tasks renamed', self::$topBarModuleSelector);
-    }
-
-    /**
-     * @param Admin $I
-     */
-    protected function clickFavoriteDropdownToggleInTopbar(Admin $I)
-    {
-        $I->switchToIFrame();
-        $I->click(Topbar::$dropdownToggleSelector, self::$topBarModuleSelector);
-    }
-}
index e3af471..4a38aa1 100644 (file)
@@ -20,6 +20,13 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Support\Helper;
 class Topbar
 {
     /**
+     * Selector for the topbar container
+     *
+     * @var string
+     */
+    public static $containerSelector = '#typo3-top-container';
+
+    /**
      * Selector for the dropdown container
      *
      * @var string