From fb82b56a7e4be04f8946cad378b5db67716867cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szo=C5=82tysek?= Date: Mon, 6 Jun 2022 15:47:15 +0200 Subject: [PATCH] [Behat] IBX-2693: Cover UDW search (#2049) * [Behat] IBX-2693: Cover UDW search --- features/standard/SearchContent.feature | 14 +++++++++++ src/lib/Behat/BrowserContext/UDWContext.php | 16 +++++++++++++ .../Component/UniversalDiscoveryWidget.php | 24 +++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/features/standard/SearchContent.feature b/features/standard/SearchContent.feature index 8951cf8903..5d5cf4f672 100644 --- a/features/standard/SearchContent.feature +++ b/features/standard/SearchContent.feature @@ -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" diff --git a/src/lib/Behat/BrowserContext/UDWContext.php b/src/lib/Behat/BrowserContext/UDWContext.php index 1249c5f06f..181997491d 100644 --- a/src/lib/Behat/BrowserContext/UDWContext.php +++ b/src/lib/Behat/BrowserContext/UDWContext.php @@ -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); + } } diff --git a/src/lib/Behat/Component/UniversalDiscoveryWidget.php b/src/lib/Behat/Component/UniversalDiscoveryWidget.php index b39f355d67..227a48f7f5 100644 --- a/src/lib/Behat/Component/UniversalDiscoveryWidget.php +++ b/src/lib/Behat/Component/UniversalDiscoveryWidget.php @@ -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 [ @@ -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)'), ]; }