Skip to content

Commit

Permalink
[Behat] IBX-2693: Cover UDW search (#2049)
Browse files Browse the repository at this point in the history
* [Behat] IBX-2693: Cover UDW search
  • Loading branch information
micszo authored Jun 6, 2022
1 parent 49176d3 commit fb82b56
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
14 changes: 14 additions & 0 deletions features/standard/SearchContent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ Feature: Searching for a Content item
And I open "Search" page in admin SiteAccess
When I search for a Content named "Searched folder"
Then I should see in search results an item named "Searched folder"

@javascript @APIUser:admin
Scenario: Content can be searched for in UDW
Given I create "folder" Content items in root in "eng-GB"
| name | short_name |
| folderUDW | folderUDW |
And I am logged as admin
And I'm on Content view Page for "root"
And I click on the left menu bar button "Browse"
When I change the UDW tab to "Search"
And I search for content item "folderUDW" through UDW
And I select "folderUDW" item in search results through UDW
And I preview selected content
Then I'm on Content view Page for "root/folderUDW"
16 changes: 16 additions & 0 deletions src/lib/Behat/BrowserContext/UDWContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,20 @@ public function previewBookmarkedContent(): void
{
$this->universalDiscoveryWidget->openPreview();
}

/**
* @Given I search for content item :item through UDW
*/
public function searchForContentItem(string $item): void
{
$this->universalDiscoveryWidget->searchForContent($item);
}

/**
* @Given I select :item (content) item in search results through UDW
*/
public function selectItemInSearchResults(string $item): void
{
$this->universalDiscoveryWidget->selectInSearchResults($item);
}
}
24 changes: 24 additions & 0 deletions src/lib/Behat/Component/UniversalDiscoveryWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,25 @@ public function selectBookmark(string $bookmarkName): void
$this->getHTMLPage()->find($this->getLocator('markedBookmarkedItem'))->assert()->textEquals($bookmarkName);
}

public function searchForContent(string $name): void
{
$this->getHTMLPage()->find($this->getLocator('inputField'))->setValue($name);
$this->getHTMLPage()->find($this->getLocator('searchButton'))->click();

$this->getHTMLPage()
->setTimeout(self::SHORT_TIMEOUT)
->find($this->getLocator('searchResults'))
->assert()->textContains('Search results');
}

public function selectInSearchResults(string $name): void
{
$this->getHTMLPage()
->find($this->getLocator('targetResult'))
->assert()->textEquals($name)
->click();
}

protected function specifyLocators(): array
{
return [
Expand All @@ -205,6 +224,11 @@ protected function specifyLocators(): array
new VisibleCSSLocator('bookmarkButton', '.c-content-meta-preview__toggle-bookmark-button'),
new VisibleCSSLocator('bookmarkedItem', '.c-bookmarks-list__item-name'),
new VisibleCSSLocator('markedBookmarkedItem', '.c-bookmarks-list__item--marked'),
// search
new VisibleCSSLocator('inputField', '.c-search__input'),
new VisibleCSSLocator('searchButton', '.c-search__search-btn'),
new VisibleCSSLocator('searchResults', '.c-content-table__title'),
new VisibleCSSLocator('targetResult', '.c-content-table-item td:nth-child(2)'),
];
}

Expand Down

0 comments on commit fb82b56

Please # to comment.