From c2b994b42a58ff1e920eabdf0378f0b812ba01c2 Mon Sep 17 00:00:00 2001 From: Roland Golla <rolandgolla@gmail.com> Date: Sat, 5 Mar 2016 23:42:01 +0100 Subject: [PATCH] [TASK] Codeception simple tests for admin user Resolves: #73566 Releases: master Change-Id: I294ae235c7e9edcbbfeb838dadaec68722b492ba Reviewed-on: https://review.typo3.org/46912 Reviewed-by: Timo Schmidt <timo-schmidt@gmx.net> Tested-by: Timo Schmidt <timo-schmidt@gmx.net> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Acceptance/acceptance.suite.yml | 5 +- .../Backend/Menu/ModuleMenuSliderCest.php | 71 +++++++++++++++++++ .../Backend/Page/AddPageInPageModuleCest.php | 66 +++++++++++++++++ .../Backend/Page/InfoOnModuleCest.php | 47 ++++++++++++ .../Backend/Profile/UsernameOnAvatarCest.php | 41 +++++++++++ .../Backend/Search/SearchAdminCest.php | 51 +++++++++++++ .../Backend/Search/SearchNoResultCest.php | 47 ++++++++++++ 7 files changed, 325 insertions(+), 3 deletions(-) create mode 100644 typo3/sysext/core/Tests/Acceptance/Backend/Menu/ModuleMenuSliderCest.php create mode 100644 typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php create mode 100644 typo3/sysext/core/Tests/Acceptance/Backend/Page/InfoOnModuleCest.php create mode 100644 typo3/sysext/core/Tests/Acceptance/Backend/Profile/UsernameOnAvatarCest.php create mode 100644 typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchAdminCest.php create mode 100644 typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchNoResultCest.php diff --git a/typo3/sysext/core/Build/Configuration/Acceptance/acceptance.suite.yml b/typo3/sysext/core/Build/Configuration/Acceptance/acceptance.suite.yml index 4c4285287c39..36d893390f8b 100644 --- a/typo3/sysext/core/Build/Configuration/Acceptance/acceptance.suite.yml +++ b/typo3/sysext/core/Build/Configuration/Acceptance/acceptance.suite.yml @@ -8,11 +8,10 @@ modules: WebDriver: url: http://localhost:8000/typo3temp/var/tests/acceptance browser: phantomjs - http_proxy: direct - window_size: 1024x768 + window_size: 1440x570 env: firefox: modules: config: WebDriver: - browser: 'firefox' \ No newline at end of file + browser: firefox diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Menu/ModuleMenuSliderCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Menu/ModuleMenuSliderCest.php new file mode 100644 index 000000000000..d8fe1460c79e --- /dev/null +++ b/typo3/sysext/core/Tests/Acceptance/Backend/Menu/ModuleMenuSliderCest.php @@ -0,0 +1,71 @@ +<?php +namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Menu; + +/* + * 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; + +/** + * Acceptance test + */ +class ModuleMenuSliderCest +{ + public function _before(Kasper $I) + { + $I->loginAsAdmin(); + } + + public function _after(Kasper $I) + { + $I->logout(); + } + + // tests + public function tryToTest(Kasper $I) + { + $ids = ['#web', '#tools', '#system']; + $sees = ['Page', 'Extensions']; + $typo3Menu = '#typo3-menu'; + + $I->wantTo('check the slider in the module menu'); + + foreach ($ids as $id) { + $I->waitForElement($id); + + // we close all + $classString = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use ($id) { + return $webdriver->findElement(\WebDriverBy::cssSelector($id))->getAttribute('class'); + }); + + if (strpos($classString, 'expanded') !== false) { + $I->click($id . ' > div'); + $I->wait(2); // the animation is so fast + } + } + + foreach ($sees as $see) { + $I->cantSee($see); + } + + // we open all + foreach ($ids as $id) { + $I->click($id . ' > div'); + $I->wait(2); + } + + foreach ($sees as $see) { + $I->see($see); + } + } +} \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php new file mode 100644 index 000000000000..5baa56efadd8 --- /dev/null +++ b/typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php @@ -0,0 +1,66 @@ +<?php +namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Page; + +/* + * 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 is used to check if a page can be added with the page module. + */ +class AddPageInPageModuleCest +{ + public function _before(Kasper $I) + { + $I->loginAsAdmin(); + } + + public function _after(Kasper $I) + { + $I->logout(); + } + + /** + * @env firefox + * @env chrome + * @param Kasper $I + */ + public function tryToTest(Kasper $I) + { + $I->wantToTest('Add a page with page module'); + $I->click('Page'); + $I->waitForElement('#typo3-navigationContainer'); + $rootNode = '.x-tree-node:nth-child(1) > div > a'; + $contextMenuNew = '#typo3-pagetree-contextmenu > ul > li:nth-child(2) > a > span.x-menu-item-text'; + $I->waitForElement($rootNode); + $I->clickWithRightButton($rootNode); + $I->waitForElement($contextMenuNew); + $I->click($contextMenuNew); + $I->switchToIFrame('content'); + $saveButton = 'body > div > div.module-docheader.t3js-module-docheader > div.module-docheader-bar.module-docheader-bar-buttons.t3js-module-docheader-bar.t3js-module-docheader-bar-buttons > div.module-docheader-bar-column-left > div > div > button:nth-child(1)'; + $I->waitForElement($saveButton); + + // Check empty + $I->amGoingTo('check empty error'); + $I->click($saveButton); + $I->wait(2); + $generalTab = '#EditDocumentController > div > div:nth-child(1) > ul > li'; + $classString = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use ($generalTab) { + return $webdriver->findElement(\WebDriverBy::cssSelector($generalTab))->getAttribute('class'); + }); + $I->assertNotEquals(false, strpos($classString, 'has-validation-error')); + $I->switchToIFrame(); + } + +} \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Page/InfoOnModuleCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Page/InfoOnModuleCest.php new file mode 100644 index 000000000000..e66186066c1d --- /dev/null +++ b/typo3/sysext/core/Tests/Acceptance/Backend/Page/InfoOnModuleCest.php @@ -0,0 +1,47 @@ +<?php +namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Page; + +/* + * 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 is used to check if the expected information is found when + * the page module was opened. + */ +class InfoOnModuleCest +{ + public function _before(Kasper $I) + { + $I->loginAsAdmin(); + } + + public function _after(Kasper $I) + { + $I->logout(); + } + + /** + * @param Kasper $I + */ + public function tryToTest(Kasper $I) + { + $I->wantToTest('Info is ok when select page module'); + $I->click('Page'); + $I->switchToIFrame('content'); + $I->waitForElement('h4'); + $I->see('Web>Page module'); + $I->switchToIFrame(); + } +} \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Profile/UsernameOnAvatarCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Profile/UsernameOnAvatarCest.php new file mode 100644 index 000000000000..8319d9a1ab23 --- /dev/null +++ b/typo3/sysext/core/Tests/Acceptance/Backend/Profile/UsernameOnAvatarCest.php @@ -0,0 +1,41 @@ +<?php +namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Profile; + +/* + * 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 is used to check if username is visible in the toolbar. + */ +class UsernameOnAvatarCest +{ + public function _before(Kasper $I) + { + $I->loginAsAdmin(); + } + + public function _after(Kasper $I) + { + $I->logout(); + } + + /** + * @param Kasper $I + */ + public function tryToTest(Kasper $I) + { + $I->see('admin', '#typo3-cms-backend-backend-toolbaritems-usertoolbaritem'); + } +} diff --git a/typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchAdminCest.php b/typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchAdminCest.php new file mode 100644 index 000000000000..986b89cfe7df --- /dev/null +++ b/typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchAdminCest.php @@ -0,0 +1,51 @@ +<?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 new file mode 100644 index 000000000000..46d24eda6bb2 --- /dev/null +++ b/typo3/sysext/core/Tests/Acceptance/Backend/Search/SearchNoResultCest.php @@ -0,0 +1,47 @@ +<?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); + } +} -- GitLab