[TASK] Refactor acceptance tests for search module in topbar 26/47726/3
authorSascha Egerer <sascha@sascha-egerer.de>
Fri, 15 Apr 2016 19:50:34 +0000 (21:50 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 15 Apr 2016 21:46:51 +0000 (23:46 +0200)
Change-Id: I74ec9d5afaedb30916403941e6dac8df3c6b0fc8
Related: #75631
Releases: master
Reviewed-on: https://review.typo3.org/47726
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/Search/SearchAdminCest.php [deleted file]
typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchNoResultCest.php [deleted file]
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/SearchCest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Acceptance/Support/Helper/Topbar.php

diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchAdminCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchAdminCest.php
deleted file mode 100644 (file)
index 727b843..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Search;
-
-/*
- * 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 TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Kasper;
-
-/**
- * This testcase searches for "ad" and expects to retrieve
- * the admin backend user as result.
- */
-class SearchAdminCest
-{
-    public function _before(Kasper $I)
-    {
-        $I->loginAsAdmin();
-    }
-
-    public function _after(Kasper $I)
-    {
-        $I->logout();
-    }
-
-    // tests
-    public function tryToTest(\AcceptanceTester $I)
-    {
-        $liveSearchToolBarItem = '#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem';
-        $searchResultHeader = $liveSearchToolBarItem . ' > div > div > div:nth-child(1)';
-        $I->wantTo('Search "admin" with auto completion');
-        $I->fillField('#live-search-box', 'ad');
-        $I->waitForElement($searchResultHeader);
-        $dropDownHeader = $I->grabTextFrom($searchResultHeader);
-        $I->assertEquals('Backend user', $dropDownHeader);
-        $I->click($liveSearchToolBarItem . ' > div > div > div:nth-child(2) > a');
-        $I->switchToIFrame('content');
-        $I->waitForElement('#EditDocumentController');
-        $I->see('Edit Backend user "admin" on root level');
-        $I->switchToIFrame();
-    }
-}
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchNoResultCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchNoResultCest.php
deleted file mode 100644 (file)
index 46d24ed..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Search;
-
-/*
- * 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 TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Kasper;
-
-/**
- * This testcase performs a search in the backend and checks if
- * no results get returned for the query "no results".
- */
-class SearchNoResultCest
-{
-    public function _before(Kasper $I)
-    {
-        $I->loginAsAdmin();
-    }
-
-    public function _after(Kasper $I)
-    {
-        $I->logout();
-    }
-
-    // tests
-    public function tryToTest(Kasper $I)
-    {
-        $liveSearchToolBarItem = '#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem';
-        $searchDropdownInfo = $liveSearchToolBarItem . ' > div > div > div > div.dropdown-info';
-        $I->wantTo('Search "no" and check no result info');
-        $I->fillField('#live-search-box', 'no result');
-        // Using more than two letters to have better test stability on phantomjs
-        $I->waitForElement($searchDropdownInfo);
-        $dropdownHeader = $I->grabTextFrom($searchDropdownInfo);
-        $I->assertEquals('No results found.', $dropdownHeader);
-    }
-}
diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/SearchCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Topbar/SearchCest.php
new file mode 100644 (file)
index 0000000..f0d1470
--- /dev/null
@@ -0,0 +1,88 @@
+<?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 TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
+
+/**
+ * Test the search module in the top bar
+ */
+class SearchCest
+{
+    /**
+     * Selector for the module container in the topbar
+     *
+     * @var string
+     */
+    public static $topBarModuleSelector = '#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem';
+
+    /**
+     * @param Admin $I
+     */
+    public function _before(Admin $I)
+    {
+        $I->useExistingSession();
+    }
+
+    /**
+     * @param Admin $I
+     */
+    public function searchAndTestIfAutocompletionWorks(Admin $I)
+    {
+        $I->cantSeeElement(self::$topBarModuleSelector . ' ' . Topbar::$dropdownListSelector);
+        $I->fillField('#live-search-box', 'adm');
+        $I->waitForElementVisible(self::$topBarModuleSelector . ' ' . Topbar::$dropdownListSelector);
+
+        $I->canSee('Backend user', self::$topBarModuleSelector);
+        $I->click('.icon-status-user-admin', self::$topBarModuleSelector);
+
+        $I->switchToIFrame("content");
+        $I->waitForElementVisible('#EditDocumentController');
+        $I->canSee('Edit Backend user "admin" on root level');
+    }
+
+    /**
+     * @param Admin $I
+     */
+    public function searchForFancyTextAndCheckEmptyResultInfo(Admin $I)
+    {
+        $I->fillField('#live-search-box', 'Kasper = Jesus # joh316');
+        $I->waitForElementVisible(self::$topBarModuleSelector . ' ' . Topbar::$dropdownListSelector);
+
+        // tod0: check why TYPO3 does not return a result for "Kasper" by itself
+        $I->canSee('No results found.', self::$topBarModuleSelector);
+
+        $I->click(self::$topBarModuleSelector . ' .close');
+        $I->waitForElementNotVisible(self::$topBarModuleSelector . ' ' . Topbar::$dropdownListSelector);
+        $I->cantSeeInField('#live-search-box', 'Kasper = Jesus # joh316');
+    }
+
+    /**
+     * @param Admin $I
+     */
+    public function checkIfTheShowAllLinkPointsToTheListViewWithSearchResults(Admin $I)
+    {
+        $I->fillField('#live-search-box', 'fileadmin');
+        $I->waitForElementVisible(self::$topBarModuleSelector . ' ' . Topbar::$dropdownListSelector);
+
+        $I->canSee('fileadmin/ (auto-created)', self::$topBarModuleSelector);
+        $I->click('.t3js-live-search-show-all', self::$topBarModuleSelector);
+
+        $I->switchToIFrame('content');
+        $I->waitForElementVisible('form[name="dblistForm"]');
+        $I->canSee('fileadmin/ (auto-created)');
+    }
+}
index 3a348a0..e3af471 100644 (file)
@@ -27,6 +27,13 @@ class Topbar
     public static $dropdownContainerSelector = '.dropdown-menu';
 
     /**
+     * Selector for the dropdown container
+     *
+     * @var string
+     */
+    public static $dropdownListSelector = '.dropdown-menu .dropdown-list';
+
+    /**
      * Selector for the dropdown toggle
      *
      * @var string