diff --git a/behat_suites.yml b/behat_suites.yml index dbc5ef87aa..89e003e318 100644 --- a/behat_suites.yml +++ b/behat_suites.yml @@ -29,6 +29,7 @@ browser: - Ibexa\AdminUi\Behat\BrowserContext\ContentViewContext - Ibexa\AdminUi\Behat\BrowserContext\DashboardContext - Ibexa\AdminUi\Behat\BrowserContext\LanguageContext + - Ibexa\AdminUi\Behat\BrowserContext\MyDraftsContext - Ibexa\AdminUi\Behat\BrowserContext\NavigationContext - Ibexa\AdminUi\Behat\BrowserContext\NotificationContext - Ibexa\AdminUi\Behat\BrowserContext\ObjectStatesContext @@ -78,6 +79,7 @@ browser: - Ibexa\AdminUi\Behat\BrowserContext\ContentViewContext - Ibexa\AdminUi\Behat\BrowserContext\DashboardContext - Ibexa\AdminUi\Behat\BrowserContext\LanguageContext + - Ibexa\AdminUi\Behat\BrowserContext\MyDraftsContext - Ibexa\AdminUi\Behat\BrowserContext\NavigationContext - Ibexa\AdminUi\Behat\BrowserContext\NotificationContext - Ibexa\AdminUi\Behat\BrowserContext\ObjectStatesContext diff --git a/features/standard/MyDrafts.feature b/features/standard/MyDrafts.feature new file mode 100644 index 0000000000..e91d27b927 --- /dev/null +++ b/features/standard/MyDrafts.feature @@ -0,0 +1,26 @@ +@IbexaOSS @IbexaHeadless @IbexaExperience @IbexaCommerce @javascript +Feature: My Drafts + + Scenario: It is possible to delete a draft + Given I create "article" Content drafts + | title | short_title | parentPath | language | + | TestMyDraft | TestMyDraft | root | eng-GB | + And I am logged as admin + And I open "MyDrafts" page in admin SiteAccess + When I delete the draft "TestMyDraft" from my draft lists + Then I see the draft "TestMyDraft" is deleted + + Scenario: It is possible to edit a draft + Given I create "article" Content drafts + | title | short_title | parentPath | language | + | TestMyDraft | TestMyDraft | root | eng-GB | + And I am logged as admin + And I open "MyDrafts" page in admin SiteAccess + When I edit "TestMyDraft" on MyDrafts page + And I set content fields + | label | value | + | Title | TestMyDraftSavePublish | + | Short title | TestMyDraftSavePublish | + | Intro | TestMyDraftIntro | + And I click on the edit action bar button "Save" + Then I should be on Content update page for "TestMyDraftSavePublish" diff --git a/src/bundle/Resources/config/services/test/feature_contexts.yaml b/src/bundle/Resources/config/services/test/feature_contexts.yaml index 28bf094923..64aee64542 100644 --- a/src/bundle/Resources/config/services/test/feature_contexts.yaml +++ b/src/bundle/Resources/config/services/test/feature_contexts.yaml @@ -45,3 +45,5 @@ services: Ibexa\AdminUi\Behat\BrowserContext\UserPreferencesContext: ~ Ibexa\AdminUi\Behat\BrowserContext\BookmarkContext: ~ + + Ibexa\AdminUi\Behat\BrowserContext\MyDraftsContext: ~ diff --git a/src/bundle/Resources/config/services/test/pages.yaml b/src/bundle/Resources/config/services/test/pages.yaml index 1d2ab76555..01cc3fe713 100644 --- a/src/bundle/Resources/config/services/test/pages.yaml +++ b/src/bundle/Resources/config/services/test/pages.yaml @@ -56,7 +56,7 @@ services: Ibexa\AdminUi\Behat\Page\ChangePasswordPage: ~ - Ibexa\AdminUi\Behat\Page\UserSettingsPage: ~ + Ibexa\AdminUi\Behat\Page\MyDraftsPage: ~ Ibexa\AdminUi\Behat\Page\BookmarksPage: ~ diff --git a/src/lib/Behat/BrowserContext/MyDraftsContext.php b/src/lib/Behat/BrowserContext/MyDraftsContext.php new file mode 100644 index 0000000000..06af9fcbe1 --- /dev/null +++ b/src/lib/Behat/BrowserContext/MyDraftsContext.php @@ -0,0 +1,45 @@ +myDraftsPage = $myDraftsPage; + } + + /** + * @Given I delete the draft :draftName from my draft lists + */ + public function iDeleteADraftFromTheList(string $draftName): void + { + $this->myDraftsPage->deleteDraft($draftName); + } + + /** + * @Given I see the draft :draftName is deleted + */ + public function iSeeTheDraftIsDeleted(string $draftName): void + { + Assert::assertFalse($this->myDraftsPage->isDraftOnTheList($draftName)); + } + + /** + * @Given I edit :draftName on MyDrafts page + */ + public function iEditDraft(string $draftName): void + { + $this->myDraftsPage->edit($draftName); + } +} diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php new file mode 100644 index 0000000000..98499cfcf1 --- /dev/null +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -0,0 +1,72 @@ +table = $tableBuilder->newTable()->build(); + $this->dialog = $dialog; + } + + public function verifyIsLoaded(): void + { + $this->getHTMLPage() + ->find($this->getLocator('pageTitle')) + ->assert()->textEquals('Drafts'); + } + + public function deleteDraft(string $draftName): void + { + $this->table->getTableRow(['Name' => $draftName])->select(); + $this->getHTMLPage()->find($this->getLocator('deleteButton'))->click(); + $this->dialog->verifyIsLoaded(); + $this->dialog->confirm(); + } + + public function isDraftOnTheList(string $draftName): bool + { + return $this->table->hasElement(['Name' => $draftName]); + } + + public function edit(string $draftName): void + { + $this->table->getTableRow(['Name' => $draftName])->edit(); + } + + protected function specifyLocators(): array + { + return [ + new VisibleCSSLocator('deleteButton', '#confirm-content_remove_remove'), + new VisibleCSSLocator('pageTitle', '.ibexa-page-title h1'), + ]; + } + + public function getName(): string + { + return 'MyDrafts'; + } + + protected function getRoute(): string + { + return 'contentdraft/list'; + } +}