‪TYPO3CMS  11.5
IndexedSearchCest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Facebook\WebDriver\Remote\RemoteWebDriver;
23 
25 {
26  protected string ‪$sidebarSelector = '.sidebar.list-group';
27  protected string ‪$searchSelector = '#tx-indexedsearch-searchbox-sword';
28  protected string ‪$advancedSelector = '//a[contains(., "Advanced search")]';
29  protected string ‪$regularSelector = '//a[contains(., "Regular search")]';
30  protected string ‪$noResultsSelector = '.tx-indexedsearch-info-noresult';
31  protected string ‪$submitSelector = '.tx-indexedsearch-search-submit input[type=submit]';
32 
33  public function ‪_before(‪ApplicationTester $I, ‪PageTree $pageTree): void
34  {
35  $I->useExistingSession('admin');
36  $I->click('Page');
37  $I->waitForElement('#typo3-pagetree-tree .nodes .node', 5);
38  $pageTree->‪openPath(['styleguide frontend demo']);
39  $I->switchToContentFrame();
40  $I->waitForElementVisible('select[name=actionMenu]');
41  $I->selectOption('select[name=actionMenu]', 'Columns');
42  $I->wait(1);
43  $I->waitForElementVisible('.t3js-module-docheader-bar a[title="View webpage"]');
44  $I->wait(1);
45  $I->click('.t3js-module-docheader-bar a[title="View webpage"]');
46  $I->wait(1);
47  $I->executeInSelenium(static function (RemoteWebDriver $webdriver) {
48  $handles = $webdriver->getWindowHandles();
49  $lastWindow = end($handles);
50  $webdriver->switchTo()->window($lastWindow);
51  });
52  $I->wait(1);
53  $I->see('TYPO3 Styleguide Frontend', '.content');
54  $I->scrollTo('//a[contains(., "list")]');
55  $I->click('list', $this->sidebarSelector);
56  }
57 
58  public function ‪_after(‪ApplicationTester $I): void
59  {
60  // Close FE tab again and switch to BE to avoid side effects
61  $I->executeInSelenium(static function (RemoteWebDriver $webdriver) {
62  $handles = $webdriver->getWindowHandles();
63  // Avoid closing the main backend tab (holds the webdriver session) if the test failed to open the frontend tab
64  // (All subsequent tests would fail with "[Facebook\WebDriver\Exception\InvalidSessionIdException] invalid session id"
65  if (count($handles) > 1) {
66  $webdriver->close();
67  $firstWindow = current($handles);
68  $webdriver->switchTo()->window($firstWindow);
69  }
70  });
71  }
72 
73  public function ‪seeSearchResults(‪ApplicationTester $I): void
74  {
75  $I->fillField($this->searchSelector, 'search word');
76  $I->click($this->submitSelector);
77  $I->see('No results found.', $this->noResultsSelector);
78  }
79 
80  public function ‪seeAdvancedSearch(‪ApplicationTester $I): void
81  {
82  $seeElements = [
83  '#tx-indexedsearch-selectbox-searchtype',
84  '#tx-indexedsearch-selectbox-defaultoperand',
85  '#tx-indexedsearch-selectbox-media',
86  '#tx-indexedsearch-selectbox-lang',
87  '#tx-indexedsearch-selectbox-sections',
88  '#tx-indexedsearch-selectbox-freeIndexUid',
89  '#tx-indexedsearch-selectbox-order',
90  '#tx-indexedsearch-selectbox-desc',
91  '#tx-indexedsearch-selectbox-results',
92  '#tx-indexedsearch-selectbox-group',
93  ];
94 
95  $I->fillField($this->searchSelector, 'search word');
96  $I->click($this->advancedSelector);
97  foreach ($seeElements as $element) {
98  $I->seeElement($element);
99  }
100 
101  $I->click($this->submitSelector);
102  $I->see('No results found.', $this->noResultsSelector);
103 
104  $I->click($this->regularSelector);
105  foreach ($seeElements as $element) {
106  $I->dontSeeElement($element);
107  }
108  }
109 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest
Definition: IndexedSearchCest.php:25
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\$searchSelector
‪string $searchSelector
Definition: IndexedSearchCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\seeAdvancedSearch
‪seeAdvancedSearch(ApplicationTester $I)
Definition: IndexedSearchCest.php:80
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\seeSearchResults
‪seeSearchResults(ApplicationTester $I)
Definition: IndexedSearchCest.php:73
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\$sidebarSelector
‪string $sidebarSelector
Definition: IndexedSearchCest.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend
Definition: ContentElementsCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\_before
‪_before(ApplicationTester $I, PageTree $pageTree)
Definition: IndexedSearchCest.php:33
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\$noResultsSelector
‪string $noResultsSelector
Definition: IndexedSearchCest.php:30
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\openPath
‪openPath(array $path)
Definition: PageTree.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\_after
‪_after(ApplicationTester $I)
Definition: IndexedSearchCest.php:58
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\$advancedSelector
‪string $advancedSelector
Definition: IndexedSearchCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\$submitSelector
‪string $submitSelector
Definition: IndexedSearchCest.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\$regularSelector
‪string $regularSelector
Definition: IndexedSearchCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31