From 58e2c36eb776eb92c7ba3d5b6847e885557bad57 Mon Sep 17 00:00:00 2001 From: katarzynazawada <> Date: Fri, 25 Apr 2025 12:16:17 +0200 Subject: [PATCH] IBX-9859: Adjustments for discounts tests --- src/lib/Behat/Component/CreateNewPopup.php | 18 ++++++++++++++++-- src/lib/Behat/Component/Dialog.php | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/lib/Behat/Component/CreateNewPopup.php b/src/lib/Behat/Component/CreateNewPopup.php index 87d09acc72..247d6a1c13 100644 --- a/src/lib/Behat/Component/CreateNewPopup.php +++ b/src/lib/Behat/Component/CreateNewPopup.php @@ -12,6 +12,7 @@ use Ibexa\Behat\Browser\Component\Component; use Ibexa\Behat\Browser\Element\Condition\ElementTransitionHasEndedCondition; use Ibexa\Behat\Browser\Element\Criterion\ChildElementTextCriterion; +use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; class CreateNewPopup extends Component @@ -40,7 +41,7 @@ public function verifyHeaderText(string $expectedHeader): void public function selectFromDropdown(string $dropdownLabel, string $dropdownValue): void { $definition = $this->getHTMLPage()->setTimeout(5)->find($this->getLocator('popup'))->findAll($this->getLocator('formGroup')) - ->getByCriterion(new ChildElementTextCriterion($this->getLocator('dropdownLabel'), $dropdownLabel)); + ->getByCriterion(new ChildElementTextCriterion($this->getLocator('label'), $dropdownLabel)); if ($definition->find($this->getLocator('dropdownValue'))->getText() === $dropdownValue) { return; } @@ -50,6 +51,17 @@ public function selectFromDropdown(string $dropdownLabel, string $dropdownValue) $this->ibexaDropdown->selectOption($dropdownValue); } + public function selectRadio(string $radioLabel, string $radioValue): void + { + $definition = $this->getHTMLPage()->setTimeout(5)->find($this->getLocator('popup'))->findAll($this->getLocator('formGroup')) + ->getByCriterion(new ChildElementTextCriterion($this->getLocator('label'), $radioLabel)); + if ($definition->find($this->getLocator('radioValue'))->getText() === $radioValue) { + return; + } + $this->getHTMLPage()->setTimeout(5)->findAll($this->getLocator('radioValue'))->getByCriterion(new ElementTextCriterion($radioValue)) + ->find($this->getLocator('radioLabel'))->click(); + } + public function confirm(): void { $this->getHTMLPage()->find($this->getLocator('addButton'))->click(); @@ -69,8 +81,10 @@ protected function specifyLocators(): array new VisibleCSSLocator('popup', '.ibexa-extra-actions:not(.ibexa-extra-actions--hidden)'), new VisibleCSSLocator('formGroup', '.form-group'), new VisibleCSSLocator('dropdown', '.ibexa-dropdown'), - new VisibleCSSLocator('dropdownLabel', '.ibexa-label'), + new VisibleCSSLocator('label', '.ibexa-label'), new VisibleCSSLocator('dropdownValue', '.ibexa-dropdown__selection-info'), + new VisibleCSSLocator('radioValue', '.ibexa-dc-extra-actions-applies-to__option'), + new VisibleCSSLocator('radioLabel', '.ibexa-label--checkbox-radio'), ]; } } diff --git a/src/lib/Behat/Component/Dialog.php b/src/lib/Behat/Component/Dialog.php index 4abc6c5d47..c74ecf2cd0 100644 --- a/src/lib/Behat/Component/Dialog.php +++ b/src/lib/Behat/Component/Dialog.php @@ -32,7 +32,7 @@ public function verifyIsLoaded(): void protected function specifyLocators(): array { return [ - new VisibleCSSLocator('confirm', '.modal.show button[type="submit"],.modal.show button[data-click], .modal.show .ibexa-btn--confirm'), + new VisibleCSSLocator('confirm', '.modal.show button[type="submit"],.modal.show button[data-click], .modal.show .ibexa-btn--confirm, .modal.show .ibexa-btn--primary'), new VisibleCSSLocator('decline', '.modal.show .ibexa-btn--secondary'), ]; }