/
IndexedSearchCest.php
88 lines (76 loc) · 3.25 KB
/
IndexedSearchCest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
declare(strict_types=1);
/*
* 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!
*/
namespace TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree;
final class IndexedSearchCest
{
private string $sidebarSelector = '.sidebar.list-group';
private string $searchSelector = '#tx-indexedsearch-searchbox-sword';
private string $advancedSelector = '//a[contains(., "Advanced search")]';
private string $regularSelector = '//a[contains(., "Regular search")]';
private string $noResultsSelector = '.tx-indexedsearch-info-noresult';
private string $submitSelector = '.tx-indexedsearch-search-submit input[type=submit]';
public function _before(ApplicationTester $I, PageTree $pageTree): void
{
$I->useExistingSession('admin');
$I->click('Page');
$I->waitForElement('#typo3-pagetree-tree .nodes .node', 5);
$pageTree->openPath(['styleguide frontend demo']);
$I->switchToContentFrame();
$I->waitForElementVisible('.t3js-module-docheader-bar a[title="View webpage"]');
$I->click('.t3js-module-docheader-bar a[title="View webpage"]');
$I->executeInSelenium(static function (RemoteWebDriver $webdriver) {
$handles = $webdriver->getWindowHandles();
$lastWindow = end($handles);
$webdriver->switchTo()->window($lastWindow);
});
$I->scrollTo('//a[contains(., "list")]');
$I->click('list', $this->sidebarSelector);
}
public function seeSearchResults(ApplicationTester $I): void
{
$I->fillField($this->searchSelector, 'search word');
$I->click($this->submitSelector);
$I->see('No results found.', $this->noResultsSelector);
}
public function seeAdvancedSearch(ApplicationTester $I): void
{
$seeElements = [
'#tx-indexedsearch-selectbox-searchtype',
'#tx-indexedsearch-selectbox-defaultoperand',
'#tx-indexedsearch-selectbox-media',
'#tx-indexedsearch-selectbox-lang',
'#tx-indexedsearch-selectbox-sections',
'#tx-indexedsearch-selectbox-freeIndexUid',
'#tx-indexedsearch-selectbox-order',
'#tx-indexedsearch-selectbox-desc',
'#tx-indexedsearch-selectbox-results',
'#tx-indexedsearch-selectbox-group',
];
$I->fillField($this->searchSelector, 'search word');
$I->click($this->advancedSelector);
foreach ($seeElements as $element) {
$I->seeElement($element);
}
$I->click($this->submitSelector);
$I->see('No results found.', $this->noResultsSelector);
$I->click($this->regularSelector);
foreach ($seeElements as $element) {
$I->dontSeeElement($element);
}
}
}