Skip to content

Commit

Permalink
[Behat] IBX-6505: Covered Content on the Fly with Visual Test (#907)
Browse files Browse the repository at this point in the history
* IBX-6505: Extension of UDW code with create on the fly

---------

Co-authored-by: katarzynazawada <>
  • Loading branch information
katarzynazawada authored Sep 20, 2023
1 parent 91d572f commit 8f83ccf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
10 changes: 8 additions & 2 deletions src/lib/Behat/Component/ContentTypePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,19 @@ public function verifyIsLoaded(): void
$this->getHTMLPage()->find($this->getLocator('filterInput'))->clear();
}

public function confirm(): void
{
$this->getHTMLPage()->find($this->getLocator('createNewButtonInUDW'))->click();
}

protected function specifyLocators(): array
{
return [
new VisibleCSSLocator('filterInput', '.ibexa-content-menu-wrapper .ibexa-extra-actions__section-content--content-type .ibexa-instant-filter__input'),
new VisibleCSSLocator('filteredItem', '.ibexa-content-menu-wrapper .ibexa-extra-actions__section-content--content-type .ibexa-instant-filter__group-item:not([hidden]) .form-check-label'),
new VisibleCSSLocator('filterInput', '.ibexa-content-menu-wrapper .ibexa-extra-actions__section-content--content-type .ibexa-instant-filter__input, .c-udw-tab .ibexa-extra-actions__section-content--content-type .ibexa-instant-filter__input'),
new VisibleCSSLocator('filteredItem', '.ibexa-content-menu-wrapper .ibexa-extra-actions__section-content--content-type .ibexa-instant-filter__group-item:not([hidden]) .form-check-label, .c-udw-tab .ibexa-extra-actions__section-content--content-type .ibexa-instant-filter__group-item:not([hidden]) .form-check-label'),
new VisibleCSSLocator('header', '.ibexa-content-menu-wrapper .ibexa-extra-actions--create .ibexa-extra-actions__header h2'),
new VisibleCSSLocator('languageDropdown', '.ibexa-content-menu-wrapper .ibexa-dropdown__selection-info'),
new VisibleCSSLocator('createNewButtonInUDW', '.c-content-create__confirm-button'),
];
}
}
34 changes: 26 additions & 8 deletions src/lib/Behat/Component/UniversalDiscoveryWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,7 @@ public function selectBookmark(string $bookmarkName): void
public function editSelectedContent(): void
{
$this->getHTMLPage()->setTimeout(self::SHORT_TIMEOUT)->find($this->getLocator('editButton'))->click();
$iframeLocator = $this->getLocator('iframe');
$script = sprintf("document.querySelector('%s').setAttribute('name','editIframe')", $iframeLocator->getSelector());
$this->getHTMLPage()->setTimeout(self::SHORT_TIMEOUT)->waitUntilCondition(
new ElementExistsCondition($this->getHTMLPage(), $iframeLocator)
);
$this->getHTMLPage()->executeJavaScript($script);
$this->getSession()->switchToIFrame('editIframe');
$this->switchIntoContentOnTheFlyIframe();
}

public function searchForContent(string $name): void
Expand All @@ -194,6 +188,28 @@ public function selectInSearchResults(string $name): void
->click();
}

public function clickCreateNewButton(): void
{
$this->getHTMLPage()->find($this->getLocator('createNewButton'))->click();
}

public function verifyCreateOnTheFlyFormIsLoaded(): void
{
$this->switchIntoContentOnTheFlyIframe();
$this->getHTMLPage()->setTimeout(self::LONG_TIMEOUT)->find($this->getLocator('createOnTheFlyForm'))->assert()->isVisible();
}

private function switchIntoContentOnTheFlyIframe(): void
{
$iframeLocator = $this->getLocator('contentIframe');
$script = sprintf("document.querySelector('%s').setAttribute('name','iframe')", $iframeLocator->getSelector());
$this->getHTMLPage()->setTimeout(self::SHORT_TIMEOUT)->waitUntilCondition(
new ElementExistsCondition($this->getHTMLPage(), $iframeLocator)
);
$this->getHTMLPage()->executeJavaScript($script);
$this->getSession()->switchToIFrame('iframe');
}

protected function specifyLocators(): array
{
return [
Expand All @@ -205,10 +221,12 @@ protected function specifyLocators(): array
new CSSLocator('selectedLocationsTab', '.c-selected-locations'),
new CSSLocator('categoryTabSelector', '.c-tab-selector__item'),
new CSSLocator('selectedTab', '.c-tab-selector__item--selected'),
new VisibleCSSLocator('iframe', '.c-content-edit__iframe'),
new VisibleCSSLocator('contentIframe', '.c-content-edit__iframe, .m-content-create__iframe'),
new VisibleCSSLocator('multiselect', '.m-ud .c-finder-leaf .ibexa-input--checkbox'),
new VisibleCSSLocator('selectedItemName', '.c-content-meta-preview__content-name'),
new VisibleCSSLocator('previewImage', '.c-content-meta-preview__preview'),
new VisibleCSSLocator('createNewButton', '.c-content-create-button__btn'),
new VisibleCSSLocator('createOnTheFlyForm', '.ibexa-edit-content'),
// selectors for path traversal
new CSSLocator('treeLevelFormat', '.c-finder-branch:nth-child(%d)'),
new CSSLocator('treeLevelElementsFormat', '.c-finder-branch:nth-of-type(%d) .c-finder-leaf'),
Expand Down

0 comments on commit 8f83ccf

Please sign in to comment.