From 0c4c1e6458339a4e9ced75fdcb151cd373b66227 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Tue, 19 Apr 2016 22:14:53 +0200
Subject: [PATCH] [TASK] Tests: Use existing session

Using Admin->useExistingSession() of Admin actor
instead of Kasper actor speeds up the tests a bit
and should make them more reliable.

Change-Id: Ibb462e87e1ce3725cdc40a7a6afa4e3c668b2b5c
Resolves: #75798
Releases: master
Reviewed-on: https://review.typo3.org/47800
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Backend/Page/AddPageInPageModuleCest.php  | 19 ++++++++-------
 .../Backend/Topbar/BookmarkCest.php           |  2 +-
 .../Acceptance/Backend/Topbar/HelpCest.php    | 10 ++++----
 .../Acceptance/Backend/Topbar/LogoCest.php    |  4 ++++
 .../UsernameOnAvatarCest.php                  | 23 +++++++++----------
 5 files changed, 30 insertions(+), 28 deletions(-)
 rename typo3/sysext/core/Tests/Acceptance/Backend/{Profile => Topbar}/UsernameOnAvatarCest.php (52%)

diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php
index 643439ac2433..924db8a27e83 100644
--- a/typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php
+++ b/typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Page;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Kasper;
+use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
 
 /**
  * This testcase is used to check if a page can be added with the page module.
@@ -22,20 +22,19 @@ use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Kasper;
  */
 class AddPageInPageModuleCest
 {
-    public function _before(Kasper $I)
+    public function _before(Admin $I)
     {
-        $I->loginAsAdmin();
-    }
-
-    public function _after(Kasper $I)
-    {
-        $I->logout();
+        $I->useExistingSession();
+        // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
+        $I->switchToIFrame('content');
+        $I->waitForText('Web>Page module');
+        $I->switchToIFrame();
     }
 
     /**
-     * @param Kasper $I
+     * @param Admin $I
      */
-    public function tryToTest(Kasper $I)
+    public function tryToTest(Admin $I)
     {
         // Select page module
         $I->wantToTest('Add a page with page module');
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/BookmarkCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/BookmarkCest.php
index 16415c43273d..94efd13a8ece 100644
--- a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/BookmarkCest.php
+++ b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/BookmarkCest.php
@@ -44,8 +44,8 @@ class BookmarkCest
     public function _before(Admin $I)
     {
         $I->useExistingSession();
-        $I->switchToIFrame('content');
         // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
+        $I->switchToIFrame('content');
         $I->waitForText('Web>Page module');
     }
 
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/HelpCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/HelpCest.php
index 7fc4fde60310..2e9b5b86f4e7 100644
--- a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/HelpCest.php
+++ b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/HelpCest.php
@@ -23,10 +23,10 @@ use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
 class HelpCest
 {
     /**
-    * Selector for the module container in the topbar
-    *
-    * @var string
-    */
+     * Selector for the module container in the topbar
+     *
+     * @var string
+     */
     public static $topBarModuleSelector = '#typo3-cms-backend-backend-toolbaritems-helptoolbaritem';
 
     /**
@@ -35,8 +35,8 @@ class HelpCest
     public function _before(Admin $I)
     {
         $I->useExistingSession();
-        $I->switchToIFrame('content');
         // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
+        $I->switchToIFrame('content');
         $I->waitForText('Web>Page module');
         $I->switchToIFrame();
     }
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/LogoCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/LogoCest.php
index 6655d25ff63e..613e294de88f 100644
--- a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/LogoCest.php
+++ b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/LogoCest.php
@@ -27,6 +27,10 @@ class LogoCest
     public function _before(Admin $I)
     {
         $I->useExistingSession();
+        // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
+        $I->switchToIFrame('content');
+        $I->waitForText('Web>Page module');
+        $I->switchToIFrame();
     }
 
     /**
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Profile/UsernameOnAvatarCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/UsernameOnAvatarCest.php
similarity index 52%
rename from typo3/sysext/core/Tests/Acceptance/Backend/Profile/UsernameOnAvatarCest.php
rename to typo3/sysext/core/Tests/Acceptance/Backend/Topbar/UsernameOnAvatarCest.php
index 8319d9a1ab23..4c913cf491f0 100644
--- a/typo3/sysext/core/Tests/Acceptance/Backend/Profile/UsernameOnAvatarCest.php
+++ b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/UsernameOnAvatarCest.php
@@ -1,5 +1,5 @@
 <?php
-namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Profile;
+namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
 
 /*
  * This file is part of the TYPO3 CMS project.
@@ -14,27 +14,26 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Profile;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Kasper;
+use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
 
 /**
- * This testcase is used to check if username is visible in the toolbar.
+ * This test case is used to check if username is visible in the toolbar.
  */
 class UsernameOnAvatarCest
 {
-    public function _before(Kasper $I)
+    public function _before(Admin $I)
     {
-        $I->loginAsAdmin();
-    }
-
-    public function _after(Kasper $I)
-    {
-        $I->logout();
+        $I->useExistingSession();
+        // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
+        $I->switchToIFrame('content');
+        $I->waitForText('Web>Page module');
+        $I->switchToIFrame();
     }
 
     /**
-     * @param Kasper $I
+     * @param Admin $I
      */
-    public function tryToTest(Kasper $I)
+    public function tryToTest(Admin $I)
     {
         $I->see('admin', '#typo3-cms-backend-backend-toolbaritems-usertoolbaritem');
     }
-- 
GitLab