From 7895032c7900f62da565d59e54e1f2c67fe2f1c9 Mon Sep 17 00:00:00 2001 From: tomaszszopinski <59650405+tomaszszopinski@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:42:17 +0100 Subject: [PATCH 1/2] [WiP][Behat] Added language selection coverage (#2022) * [WiP][Behat] added language selection coverage * deleted LanguageSelectorPicker * fixes due to changes in steps * locator fixed * added review fixes --- src/lib/Behat/BrowserContext/ContentUpdateContext.php | 8 ++++++++ src/lib/Behat/BrowserContext/ContentViewContext.php | 5 +++-- src/lib/Behat/Component/ContentTypePicker.php | 6 ++++++ src/lib/Behat/Page/ContentUpdateItemPage.php | 7 +++++++ src/lib/Behat/Page/ContentViewPage.php | 5 ++++- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/lib/Behat/BrowserContext/ContentUpdateContext.php b/src/lib/Behat/BrowserContext/ContentUpdateContext.php index 1e28820943..34f932939a 100644 --- a/src/lib/Behat/BrowserContext/ContentUpdateContext.php +++ b/src/lib/Behat/BrowserContext/ContentUpdateContext.php @@ -50,6 +50,14 @@ public function verifyFieldIsNotEditable(string $fieldName): void Assert::assertEquals(NonEditableField::EXPECTED_NON_EDITABLE_TEXT, $field->getValue()[0]); } + /** + * @When the :fieldName field cannot be edited due to limitation + */ + public function theFieldCannotBeEditedDueToLimitation(string $fieldName): void + { + $this->contentUpdateItemPage->verifyFieldCannotBeEditedDueToLimitation($fieldName); + } + /** * @When I set content fields for user */ diff --git a/src/lib/Behat/BrowserContext/ContentViewContext.php b/src/lib/Behat/BrowserContext/ContentViewContext.php index 1b1dcd1bb8..da76f6bc62 100644 --- a/src/lib/Behat/BrowserContext/ContentViewContext.php +++ b/src/lib/Behat/BrowserContext/ContentViewContext.php @@ -49,10 +49,11 @@ public function __construct( /** * @Given I start creating a new Content :contentType + * @Given I start creating a new Content :contentType in :language language */ - public function startCreatingContent(string $contentType): void + public function startCreatingContent(string $contentType, string $language = null): void { - $this->contentViewPage->startCreatingContent($contentType); + $this->contentViewPage->startCreatingContent($contentType, $language); } /** diff --git a/src/lib/Behat/Component/ContentTypePicker.php b/src/lib/Behat/Component/ContentTypePicker.php index ba71d8b3b0..42d7674d38 100644 --- a/src/lib/Behat/Component/ContentTypePicker.php +++ b/src/lib/Behat/Component/ContentTypePicker.php @@ -27,6 +27,11 @@ public function select(string $contentTypeName): void ->click(); } + public function selectLanguage(string $language): void + { + $this->getHTMLPage()->find($this->getLocator('languageSelectWhileCreatingItem'))->selectOption($language); + } + protected function getDisplayedItemsCount(): int { return $this->getHTMLPage()->findAll($this->getLocator('filteredItem'))->count(); @@ -44,6 +49,7 @@ protected function specifyLocators(): array new VisibleCSSLocator('filterInput', '.ez-extra-actions__section-content--content-type .ez-instant-filter__input'), new VisibleCSSLocator('filteredItem', '.ez-extra-actions__section-content--content-type .ez-instant-filter__group-item:not([hidden])'), new VisibleCSSLocator('headerSelector', '.ez-extra-actions--create .ez-extra-actions__header'), + new VisibleCSSLocator('languageSelectWhileCreatingItem', '#content_create_language'), ]; } } diff --git a/src/lib/Behat/Page/ContentUpdateItemPage.php b/src/lib/Behat/Page/ContentUpdateItemPage.php index 213b8e5a25..779619b25f 100644 --- a/src/lib/Behat/Page/ContentUpdateItemPage.php +++ b/src/lib/Behat/Page/ContentUpdateItemPage.php @@ -93,6 +93,7 @@ protected function specifyLocators(): array new VisibleCSSLocator('closeButton', '.ez-content-edit-container__close'), new VisibleCSSLocator('fieldLabel', '.ez-field-edit__label-wrapper label.ez-field-edit__label, .ez-field-edit__label-wrapper legend, .ez-card > .card-body > div > div > legend'), new VisibleCSSLocator('nthField', '.ez-field-edit:nth-of-type(%s)'), + new VisibleCSSLocator('activeNthField', '.active .ez-field-edit:nth-of-type(%s)'), new VisibleCSSLocator('noneditableFieldClass', 'ez-field-edit--eznoneditable'), new VisibleCSSLocator('fieldOfType', '.ez-field-edit--%s'), new VisibleCSSLocator('navigationTabs', '.nav-item.ez-tabs__nav-item'), @@ -163,4 +164,10 @@ public function switchToFieldGroup(string $tabName): void ->getByCriterion(new ElementTextCriterion($tabName)) ->click(); } + + public function verifyFieldCannotBeEditedDueToLimitation(string $fieldName) + { + $fieldLocator = new VisibleCSSLocator('', sprintf($this->getLocator('activeNthField')->getSelector(), $this->getFieldPosition($fieldName))); + $this->getHTMLPage()->find($fieldLocator)->assert()->hasClass('ez-field-edit--disabled'); + } } diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index 1e886c36ab..03cfc746a4 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -116,10 +116,13 @@ public function __construct( $this->universalDiscoveryWidget = $universalDiscoveryWidget; } - public function startCreatingContent(string $contentTypeName) + public function startCreatingContent(string $contentTypeName, string $language = null) { $this->rightMenu->clickButton('Create'); $this->contentTypePicker->verifyIsLoaded(); + if ($language !== null) { + $this->contentTypePicker->selectLanguage($language); + } $this->contentTypePicker->select($contentTypeName); } From 41b3e59db5bdba6bc51c7a6ba3f68f94a56f4eb0 Mon Sep 17 00:00:00 2001 From: tomaszszopinski Date: Mon, 24 Jan 2022 14:12:03 +0100 Subject: [PATCH 2/2] additional fixes for v4 deleted empty line --- .../BrowserContext/ContentUpdateContext.php | 5 +++-- src/lib/Behat/Component/ContentTypePicker.php | 20 +++++++++++-------- src/lib/Behat/Page/ContentUpdateItemPage.php | 17 +++++----------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/lib/Behat/BrowserContext/ContentUpdateContext.php b/src/lib/Behat/BrowserContext/ContentUpdateContext.php index 34f932939a..1e3330853c 100644 --- a/src/lib/Behat/BrowserContext/ContentUpdateContext.php +++ b/src/lib/Behat/BrowserContext/ContentUpdateContext.php @@ -51,10 +51,11 @@ public function verifyFieldIsNotEditable(string $fieldName): void } /** - * @When the :fieldName field cannot be edited due to limitation + * @When the :fieldName field in :fieldGroup field group cannot be edited due to limitation */ - public function theFieldCannotBeEditedDueToLimitation(string $fieldName): void + public function theFieldCannotBeEditedDueToLimitation(string $fieldName, string $fieldGroup): void { + $this->contentUpdateItemPage->switchToFieldGroup($fieldGroup); $this->contentUpdateItemPage->verifyFieldCannotBeEditedDueToLimitation($fieldName); } diff --git a/src/lib/Behat/Component/ContentTypePicker.php b/src/lib/Behat/Component/ContentTypePicker.php index 16dbc7ecbc..8ec715a85d 100644 --- a/src/lib/Behat/Component/ContentTypePicker.php +++ b/src/lib/Behat/Component/ContentTypePicker.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 ContentTypePicker extends Component { + private IbexaDropdown $ibexaDropdown; + + public function __construct(Session $session, IbexaDropdown $ibexaDropdown) + { + parent::__construct($session); + $this->ibexaDropdown = $ibexaDropdown; + } + public function select(string $contentTypeName): void { $countBeforeFiltering = $this->getDisplayedItemsCount(); @@ -29,7 +38,8 @@ public function select(string $contentTypeName): void public function selectLanguage(string $language): void { - $this->getHTMLPage()->find($this->getLocator('languageSelectWhileCreatingItem'))->selectOption($language); + $this->getHTMLPage()->find($this->getLocator('languageDropdown'))->click(); + $this->ibexaDropdown->selectOption($language); } protected function getDisplayedItemsCount(): int @@ -46,16 +56,10 @@ public function verifyIsLoaded(): void protected function specifyLocators(): array { return [ -<<<<<<< HEAD - new VisibleCSSLocator('filterInput', '.ez-extra-actions__section-content--content-type .ez-instant-filter__input'), - new VisibleCSSLocator('filteredItem', '.ez-extra-actions__section-content--content-type .ez-instant-filter__group-item:not([hidden])'), - new VisibleCSSLocator('headerSelector', '.ez-extra-actions--create .ez-extra-actions__header'), - new VisibleCSSLocator('languageSelectWhileCreatingItem', '#content_create_language'), -======= new VisibleCSSLocator('filterInput', '.ibexa-extra-actions__section-content--content-type .ibexa-instant-filter__input'), new VisibleCSSLocator('filteredItem', '.ibexa-extra-actions__section-content--content-type .ibexa-instant-filter__group-item:not([hidden]) .form-check-label'), new VisibleCSSLocator('header', '.ibexa-extra-actions--create .ibexa-extra-actions__header h2'), ->>>>>>> ibexa-adminui/main + new VisibleCSSLocator('languageDropdown', '.ibexa-dropdown__selection-info'), ]; } } diff --git a/src/lib/Behat/Page/ContentUpdateItemPage.php b/src/lib/Behat/Page/ContentUpdateItemPage.php index 3ced4ea84e..b9849db4e2 100644 --- a/src/lib/Behat/Page/ContentUpdateItemPage.php +++ b/src/lib/Behat/Page/ContentUpdateItemPage.php @@ -93,21 +93,12 @@ protected function specifyLocators(): array return [ new VisibleCSSLocator('pageTitle', '.ibexa-edit-header__title'), new VisibleCSSLocator('formElement', '[name=ezplatform_content_forms_content_edit]'), -<<<<<<< HEAD - new VisibleCSSLocator('closeButton', '.ez-content-edit-container__close'), - new VisibleCSSLocator('fieldLabel', '.ez-field-edit__label-wrapper label.ez-field-edit__label, .ez-field-edit__label-wrapper legend, .ez-card > .card-body > div > div > legend'), - new VisibleCSSLocator('nthField', '.ez-field-edit:nth-of-type(%s)'), - new VisibleCSSLocator('activeNthField', '.active .ez-field-edit:nth-of-type(%s)'), - new VisibleCSSLocator('noneditableFieldClass', 'ez-field-edit--eznoneditable'), - new VisibleCSSLocator('fieldOfType', '.ez-field-edit--%s'), - new VisibleCSSLocator('navigationTabs', '.nav-item.ez-tabs__nav-item'), -======= new VisibleCSSLocator('closeButton', '.ibexa-anchor-navigation-menu__back'), new VisibleCSSLocator('nthField', '.ibexa-field-edit:nth-of-type(%s)'), + new VisibleCSSLocator('fieldGroupNthField', '[data-anchor-section-id="%s"] div .ibexa-field-edit:nth-of-type(%s)'), new VisibleCSSLocator('noneditableFieldClass', 'ibexa-field-edit--eznoneditable'), new VisibleCSSLocator('fieldOfType', '.ibexa-field-edit--%s'), new VisibleCSSLocator('navigationTabs', '.ibexa-anchor-navigation-menu__item'), ->>>>>>> ibexa-adminui/main ]; } @@ -189,7 +180,9 @@ public function switchToFieldGroup(string $tabName): void public function verifyFieldCannotBeEditedDueToLimitation(string $fieldName) { - $fieldLocator = new VisibleCSSLocator('', sprintf($this->getLocator('activeNthField')->getSelector(), $this->getFieldPosition($fieldName))); - $this->getHTMLPage()->find($fieldLocator)->assert()->hasClass('ez-field-edit--disabled'); + $activeSections = $this->getHTMLPage()->findAll(new VisibleCSSLocator('activeSection', '.ibexa-anchor-navigation-menu__item-btn--active')); + $fieldLocator = new VisibleCSSLocator('', sprintf($this + ->getLocator('fieldGroupNthField')->getSelector(), $activeSections->single()->getAttribute('data-anchor-target-section-id'), $this->getFieldPosition($fieldName))); + $this->getHTMLPage()->find($fieldLocator)->assert()->hasClass('ibexa-field-edit--disabled'); } }