From 11fd7b9da5b28a6775cbd61820220b495f533c64 Mon Sep 17 00:00:00 2001 From: katarzynazawada <> Date: Mon, 26 Aug 2024 15:07:49 +0200 Subject: [PATCH 1/2] IBX-8217: Implemented basic methods for site context and full view --- .../config/services/test/components.yaml | 2 ++ src/lib/Behat/Component/FullView.php | 30 +++++++++++++++++++ src/lib/Behat/Component/UpperMenu.php | 18 +++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/lib/Behat/Component/FullView.php diff --git a/src/bundle/Resources/config/services/test/components.yaml b/src/bundle/Resources/config/services/test/components.yaml index 3b5b333d20..cdc42cce9a 100644 --- a/src/bundle/Resources/config/services/test/components.yaml +++ b/src/bundle/Resources/config/services/test/components.yaml @@ -55,3 +55,5 @@ services: Ibexa\AdminUi\Behat\Component\CreateNewPopup: ~ Ibexa\AdminUi\Behat\Component\PropertiesList: ~ + + Ibexa\AdminUi\Behat\Component\FullView: ~ diff --git a/src/lib/Behat/Component/FullView.php b/src/lib/Behat/Component/FullView.php new file mode 100644 index 0000000000..db97f554c0 --- /dev/null +++ b/src/lib/Behat/Component/FullView.php @@ -0,0 +1,30 @@ +getHTMLPage()->setTimeout(10)->waitUntilCondition( + new ElementExistsCondition($this->getHTMLPage(), $this->getLocator('locationFullPreview')) + ); + } + + protected function specifyLocators(): array + { + return [ + new CSSLocator('locationFullPreview', '.ibexa-sc-location-full-preview--loaded'), + ]; + } +} diff --git a/src/lib/Behat/Component/UpperMenu.php b/src/lib/Behat/Component/UpperMenu.php index 0c9a5464bd..6a244d7ba5 100644 --- a/src/lib/Behat/Component/UpperMenu.php +++ b/src/lib/Behat/Component/UpperMenu.php @@ -8,12 +8,21 @@ namespace Ibexa\AdminUi\Behat\Component; +use Behat\Mink\Session; use Ibexa\Behat\Browser\Component\Component; use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; class UpperMenu extends Component { + private IbexaDropdown $ibexaDropdown; + + public function __construct(Session $session, IbexaDropdown $ibexaDropdown) + { + parent::__construct($session); + $this->ibexaDropdown = $ibexaDropdown; + } + public function goToDashboard(): void { $this->getHTMLPage()->find($this->getLocator('dashboardLink'))->click(); @@ -68,6 +77,13 @@ public function verifyIsLoaded(): void $this->getHTMLPage()->find($this->getLocator('userSettingsToggle'))->assert()->isVisible(); } + public function selectSiteContext(string $siteName): void + { + $this->getHTMLPage()->find($this->getLocator('siteDropdown'))->click(); + $this->ibexaDropdown->selectOptionByValueFragment($siteName); + $this->getHTMLPage()->setTimeout(5)->find($this->getLocator('siteDropdownSelectedItem'))->assert()->textEquals(sprintf('Site: %s', $siteName)); + } + protected function specifyLocators(): array { return [ @@ -82,6 +98,8 @@ protected function specifyLocators(): array new VisibleCSSLocator('userFocusEnabled', '[name="focus_mode_change"] .ibexa-toggle__label--on'), new VisibleCSSLocator('userFocusMode', '[name="focus_mode_change"] .ibexa-toggle__switcher'), new VisibleCSSLocator('focusModeBadge', '.ibexa-user-mode-badge'), + new VisibleCSSLocator('siteDropdown', '.ibexa-preview-context-switch-form .ibexa-dropdown'), + new VisibleCSSLocator('siteDropdownSelectedItem', '.ibexa-preview-context-switch-form .ibexa-dropdown li.ibexa-dropdown__selected-item:nth-of-type(1)'), ]; } } From f84ab5c38971cb9ce03087c85b866a6ea4615f07 Mon Sep 17 00:00:00 2001 From: katarzynazawada <> Date: Mon, 2 Sep 2024 12:59:32 +0200 Subject: [PATCH 2/2] IBX-8217: Changed CSSLocator to VisibleCSSLocator --- src/lib/Behat/Component/FullView.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Behat/Component/FullView.php b/src/lib/Behat/Component/FullView.php index db97f554c0..920bf63401 100644 --- a/src/lib/Behat/Component/FullView.php +++ b/src/lib/Behat/Component/FullView.php @@ -10,7 +10,7 @@ use Ibexa\Behat\Browser\Component\Component; use Ibexa\Behat\Browser\Element\Condition\ElementExistsCondition; -use Ibexa\Behat\Browser\Locator\CSSLocator; +use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; final class FullView extends Component { @@ -24,7 +24,7 @@ public function verifyIsLoaded(): void protected function specifyLocators(): array { return [ - new CSSLocator('locationFullPreview', '.ibexa-sc-location-full-preview--loaded'), + new VisibleCSSLocator('locationFullPreview', '.ibexa-sc-location-full-preview--loaded'), ]; } }