diff --git a/behat_suites.yml b/behat_suites.yml index 6ea1d692be..5210b1fb31 100644 --- a/behat_suites.yml +++ b/behat_suites.yml @@ -24,6 +24,7 @@ browser: - Ibexa\AdminUi\Behat\BrowserContext\AdminUpdateContext - Ibexa\AdminUi\Behat\BrowserContext\BookmarkContext - Ibexa\AdminUi\Behat\BrowserContext\ContentPreviewContext + - Ibexa\AdminUi\Behat\BrowserContext\ContentTreeContext - Ibexa\AdminUi\Behat\BrowserContext\ContentTypeContext - Ibexa\AdminUi\Behat\BrowserContext\ContentUpdateContext - Ibexa\AdminUi\Behat\BrowserContext\ContentViewContext @@ -75,6 +76,7 @@ browser: - Ibexa\AdminUi\Behat\BrowserContext\ContentActionsMenuContext - Ibexa\AdminUi\Behat\BrowserContext\BookmarkContext - Ibexa\AdminUi\Behat\BrowserContext\ContentPreviewContext + - Ibexa\AdminUi\Behat\BrowserContext\ContentTreeContext - Ibexa\AdminUi\Behat\BrowserContext\ContentTypeContext - Ibexa\AdminUi\Behat\BrowserContext\ContentUpdateContext - Ibexa\AdminUi\Behat\BrowserContext\ContentViewContext diff --git a/features/standard/ContentTree.feature b/features/standard/ContentTree.feature new file mode 100644 index 0000000000..3a8a783047 --- /dev/null +++ b/features/standard/ContentTree.feature @@ -0,0 +1,30 @@ +@IbexaOSS @IbexaHeadless @IbexaCommerce @IbexaExperience @javascript +Feature: Content tree basic operations + + Scenario: Content tree can be displayed + Given I am logged as admin + When I'm on Content view Page for "root" + Then I verify Content tree visibility + + Scenario: It is possible to display items on Content tree + Given I create "article" Content items + | title | short_title | parentPath | language | + | Article1 | art1 | root | eng-GB | + | Article2 | art2 | root | eng-GB | + | Article3 | art3 | root | eng-GB | + And I am logged as admin + When I'm on Content view Page for "root/art1" + Then Content item "root/art1" exists in Content tree + + Scenario: New Content item can be created under chosen nested node + Given I am logged as admin + And I'm on Content view Page for "root/art1" + When I start creating a new content "Article" + And I set content fields + | label | value | + | Title | TestArt | + | Short title | testart | + | Intro | TestArticleIntro| + And I perform the "Publish" action + And I'm on Content view Page for "root/art1/testart" + Then Content item "root/art1/testart" exists in Content tree diff --git a/src/bundle/Resources/config/services/test/components.yaml b/src/bundle/Resources/config/services/test/components.yaml index c87348d52d..8a6774ece0 100644 --- a/src/bundle/Resources/config/services/test/components.yaml +++ b/src/bundle/Resources/config/services/test/components.yaml @@ -33,6 +33,8 @@ services: Ibexa\AdminUi\Behat\Component\UserNotificationPopup: ~ + Ibexa\AdminUi\Behat\Component\ContentTree: ~ + Ibexa\AdminUi\Behat\Component\ContentTypePicker: ~ Ibexa\AdminUi\Behat\Component\LanguagePicker: ~ diff --git a/src/bundle/Resources/config/services/test/feature_contexts.yaml b/src/bundle/Resources/config/services/test/feature_contexts.yaml index 82ee1eaeb5..8696229ce3 100644 --- a/src/bundle/Resources/config/services/test/feature_contexts.yaml +++ b/src/bundle/Resources/config/services/test/feature_contexts.yaml @@ -26,6 +26,8 @@ services: Ibexa\AdminUi\Behat\BrowserContext\UDWContext: ~ + Ibexa\AdminUi\Behat\BrowserContext\ContentTreeContext: ~ + Ibexa\AdminUi\Behat\BrowserContext\ContentTypeContext: ~ Ibexa\AdminUi\Behat\BrowserContext\NavigationContext: ~ diff --git a/src/lib/Behat/BrowserContext/ContentTreeContext.php b/src/lib/Behat/BrowserContext/ContentTreeContext.php new file mode 100644 index 0000000000..e65e782037 --- /dev/null +++ b/src/lib/Behat/BrowserContext/ContentTreeContext.php @@ -0,0 +1,39 @@ +contentTree = $contentTree; + } + + /** + * @Then I verify Content tree visibility + */ + public function iAmOnContentTree(): void + { + $this->contentTree->verifyIsLoaded(); + } + + /** + * @Then Content item :itemPath exists in Content tree + */ + public function contentItemExistsInContentTree(string $itemPath): void + { + $this->contentTree->verifyIsLoaded(); + $this->contentTree->verifyItemExists($itemPath); + } +} diff --git a/src/lib/Behat/Component/ContentTree.php b/src/lib/Behat/Component/ContentTree.php new file mode 100644 index 0000000000..09a692f095 --- /dev/null +++ b/src/lib/Behat/Component/ContentTree.php @@ -0,0 +1,48 @@ +getHTMLPage()->find($this->getLocator('header'))->assert()->textEquals('Content tree'); + } + + public function verifyItemExists(string $itemPath): void + { + Assert::assertTrue($this->itemExists($itemPath)); + } + + private function itemExists(string $itemPath): bool + { + $pathParts = explode('/', $itemPath); + $elements = $this->getHTMLPage()->findAll($this->getLocator('contentInTree')); + + foreach ($elements as $element) { + if ($element->getText() === end($pathParts)) { + return true; + } + } + + return false; + } + + protected function specifyLocators(): array + { + return [ + new VisibleCSSLocator('header', '.ibexa-content-tree-container .c-tb-header__name-content,.c-header .c-header__name'), + new VisibleCSSLocator('contentInTree', '.c-tb-list-item-single__link, .c-list-item'), + ]; + } +}