‪TYPO3CMS  ‪main
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  private string ‪$sidebarSelector = '.sidebar.list-group';
27  private string ‪$searchSelector = '#tx-indexedsearch-searchbox-sword';
28  private string ‪$advancedSelector = '//a[contains(., "Advanced search")]';
29  private string ‪$regularSelector = '//a[contains(., "Regular search")]';
30  private string ‪$noResultsSelector = '.tx-indexedsearch-info-noresult';
31  private 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  $pageTree->‪openPath(['styleguide frontend demo']);
38  $I->switchToContentFrame();
39  $I->waitForElementVisible('select[name=actionMenu]');
40  $I->selectOption('select[name=actionMenu]', 'Layout');
41  $I->waitForElementVisible('.t3js-module-docheader-bar a[title="View webpage"]');
42  $I->wait(1);
43  $I->click('.t3js-module-docheader-bar a[title="View webpage"]');
44  $I->wait(1);
45  $I->executeInSelenium(static function (RemoteWebDriver $webdriver) {
46  $handles = $webdriver->getWindowHandles();
47  $lastWindow = end($handles);
48  $webdriver->switchTo()->window($lastWindow);
49  });
50  $I->wait(1);
51  $I->see('TYPO3 Styleguide Frontend', '.content');
52  $I->scrollTo('//a[contains(., "indexedsearch_pi2")]');
53  $I->click('indexedsearch_pi2', $this->sidebarSelector);
54  }
55 
56  public function ‪_after(‪ApplicationTester $I): void
57  {
58  // Close FE tab again and switch to BE to avoid side effects
59  $I->executeInSelenium(static function (RemoteWebDriver $webdriver) {
60  $handles = $webdriver->getWindowHandles();
61  // Avoid closing the main backend tab (holds the webdriver session) if the test failed to open the frontend tab
62  // (All subsequent tests would fail with "[Facebook\WebDriver\Exception\InvalidSessionIdException] invalid session id"
63  if (count($handles) > 1) {
64  $webdriver->close();
65  $firstWindow = current($handles);
66  $webdriver->switchTo()->window($firstWindow);
67  }
68  });
69  }
70 
71  public function ‪seeSearchResults(‪ApplicationTester $I): void
72  {
73  $I->fillField($this->searchSelector, 'search word');
74  $I->click($this->submitSelector);
75  $I->see('No results found.', $this->noResultsSelector);
76  }
77 
78  public function ‪seeAdvancedSearch(‪ApplicationTester $I): void
79  {
80  $seeElements = [
81  '#tx-indexedsearch-selectbox-searchtype',
82  '#tx-indexedsearch-selectbox-defaultoperand',
83  '#tx-indexedsearch-selectbox-media',
84  '#tx-indexedsearch-selectbox-sections',
85  '#tx-indexedsearch-selectbox-freeIndexUid',
86  '#tx-indexedsearch-selectbox-order',
87  '#tx-indexedsearch-selectbox-desc',
88  '#tx-indexedsearch-selectbox-results',
89  '#tx-indexedsearch-selectbox-group',
90  ];
91 
92  $I->fillField($this->searchSelector, 'search word');
93  $I->click($this->advancedSelector);
94  foreach ($seeElements as $element) {
95  $I->seeElement($element);
96  }
97 
98  $I->click($this->submitSelector);
99  $I->see('No results found.', $this->noResultsSelector);
100 
101  $I->click($this->regularSelector);
102  foreach ($seeElements as $element) {
103  $I->dontSeeElement($element);
104  }
105  }
106 }
‪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:78
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\seeSearchResults
‪seeSearchResults(ApplicationTester $I)
Definition: IndexedSearchCest.php:71
‪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:28
‪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\AbstractTree\openPath
‪openPath(array $path)
Definition: AbstractTree.php:55
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\IndexedSearchCest\_after
‪_after(ApplicationTester $I)
Definition: IndexedSearchCest.php:56
‪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:26