Skip to content

Commit

Permalink
[WiP][Behat] Added language selection coverage (#2022)
Browse files Browse the repository at this point in the history
* [WiP][Behat] added language selection coverage

* deleted LanguageSelectorPicker

* fixes due to changes in steps

* locator fixed

* added review fixes
  • Loading branch information
tomaszszopinski authored Jan 24, 2022
1 parent 411c4b2 commit 7895032
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/lib/Behat/BrowserContext/ContentUpdateContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
5 changes: 3 additions & 2 deletions src/lib/Behat/BrowserContext/ContentViewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/lib/Behat/Component/ContentTypePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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'),
];
}
}
7 changes: 7 additions & 0 deletions src/lib/Behat/Page/ContentUpdateItemPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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');
}
}
5 changes: 4 additions & 1 deletion src/lib/Behat/Page/ContentViewPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 7895032

Please sign in to comment.