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/dependencies.json b/dependencies.json new file mode 100644 index 0000000000..af99aad510 --- /dev/null +++ b/dependencies.json @@ -0,0 +1,11 @@ +{ + "recipesEndpoint": "", + "packages": [ + { + "requirement": "dev-IBX-9519-behat-coverage-contenttree as 4.6.x-dev", + "repositoryUrl": "https://github.com/ibexa/behat", + "package": "ibexa/behat", + "shouldBeAddedAsVCS": false + } + ] +} \ No newline at end of file diff --git a/features/standard/ContentTree.feature b/features/standard/ContentTree.feature new file mode 100644 index 0000000000..69e45c3fff --- /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 | Arttest | + | Short title | arttest | + | Intro | TestArticleIntro| + And I perform the "Publish" action + And I'm on Content view Page for "root/art1/arttest" + Then Content item "root/art1/arttest" 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..d4a04f01a0 --- /dev/null +++ b/src/lib/Behat/BrowserContext/ContentTreeContext.php @@ -0,0 +1,50 @@ +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); + } + /** + * @Given I wait :number seconds + */ + public function iWait(string $number): void + { + $number = (int) $number; + sleep($number); + } +} diff --git a/src/lib/Behat/Component/ContentTree.php b/src/lib/Behat/Component/ContentTree.php new file mode 100644 index 0000000000..9937a962e3 --- /dev/null +++ b/src/lib/Behat/Component/ContentTree.php @@ -0,0 +1,44 @@ +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); + $searchedElement = $this->getHTMLPage()->findAll($this->getLocator('contextInTree'))->getByCriterion(new ElementTextCriterion(end($pathParts))); + return $searchedElement !== null; + } + + protected function specifyLocators(): array + { + return [ + new VisibleCSSLocator('header', '.ibexa-content-tree-container .c-tb-header__name-content,.c-header .c-header__name'), + new VisibleCSSLocator('treeItem', '.c-tb-list-item-single__label'), + new VisibleCSSLocator('treeElement', '.ibexa-content-tree-container__root .c-tb-list-item-single__element'), + new VisibleCSSLocator('search', '.c-tb-search .ibexa-input'), + new VisibleCSSLocator('contentItemInTree', '.c-tb-list-item-single__link'), + ]; + } +}