From 15e4db1893630da4238edf9856c99118ca7843d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 17 Aug 2023 16:18:44 +0200 Subject: [PATCH 1/9] Initial implementation --- behat_suites.yml | 2 + features/standard/MyDrafts.feature | 13 ++++ .../Resources/config/services/test/pages.yaml | 2 +- .../Behat/BrowserContext/MyDraftsContext.php | 31 ++++++++++ src/lib/Behat/Page/MyDraftsPage.php | 61 +++++++++++++++++++ 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 features/standard/MyDrafts.feature create mode 100644 src/lib/Behat/BrowserContext/MyDraftsContext.php create mode 100644 src/lib/Behat/Page/MyDraftsPage.php 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..847d4f70a0 --- /dev/null +++ b/features/standard/MyDrafts.feature @@ -0,0 +1,13 @@ +@IbexaOSS @IbexaHeadless @IbexaExperience @IbexaCommerce @javascript +Feature: My Drafts + + @test + 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 nie ma notyfikacji +# Then tego drafta nie ma 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..788f6f4d0a --- /dev/null +++ b/src/lib/Behat/BrowserContext/MyDraftsContext.php @@ -0,0 +1,31 @@ +myDraftsPage = $myDraftsPage; + } + + /** + * @Given I delete the draft :draftName from my draft lists + */ + public function iDeleteADraftFromTheList(string $draftName): void + { + $this->myDraftsPage->deleteDraft($draftName); + } +} diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php new file mode 100644 index 0000000000..45a46c3e07 --- /dev/null +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -0,0 +1,61 @@ +table = $tableBuilder->newTable()->build(); + $this->dialog = $dialog; + } + + public function verifyIsLoaded(): void + { + } + + public function deleteDraft(string $draftName): void + { + $this->table->getTableRow(['Name' => $draftName])->select(); + +// $this->setInteractiveBreakpoint(get_defined_vars()); + + $this->getHTMLPage()->find($this->getLocator('deleteButton'))->click(); + $this->dialog->confirm(); + } + + protected function specifyLocators(): array + { + return [ + new VisibleCSSLocator('deleteButton', '#confirm-content_remove_remove'), + ]; + } + + public function getName(): string + { + return 'MyDrafts'; + } + + protected function getRoute(): string + { + return 'contentdraft/list'; + } +} From a101525e70bff0afdddbd63e588431169e52e9ba Mon Sep 17 00:00:00 2001 From: Jakub Wesolowski Date: Fri, 18 Aug 2023 15:35:47 +0200 Subject: [PATCH 2/9] FInished the task of testing draft deletion --- features/standard/MyDrafts.feature | 9 ++++----- .../config/services/test/feature_contexts.yaml | 2 ++ src/lib/Behat/BrowserContext/MyDraftsContext.php | 8 ++++++++ src/lib/Behat/Page/MyDraftsPage.php | 12 ++++++++++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/features/standard/MyDrafts.feature b/features/standard/MyDrafts.feature index 847d4f70a0..6a8044b21c 100644 --- a/features/standard/MyDrafts.feature +++ b/features/standard/MyDrafts.feature @@ -3,11 +3,10 @@ Feature: My Drafts @test Scenario: It is possible to delete a draft -# Given I create "article" Content drafts -# | title | short_title | parentPath | language | -# | TestMyDraft | TestMyDraft | root | eng-GB | + 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 nie ma notyfikacji -# Then tego drafta nie ma + Then I see the draft "TestMyDraft" is deleted 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/lib/Behat/BrowserContext/MyDraftsContext.php b/src/lib/Behat/BrowserContext/MyDraftsContext.php index 788f6f4d0a..2e43022f97 100644 --- a/src/lib/Behat/BrowserContext/MyDraftsContext.php +++ b/src/lib/Behat/BrowserContext/MyDraftsContext.php @@ -28,4 +28,12 @@ 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($this->myDraftsPage->doSeeDraft($draftName)); + } } diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php index 45a46c3e07..f94a582337 100644 --- a/src/lib/Behat/Page/MyDraftsPage.php +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -35,13 +35,21 @@ public function verifyIsLoaded(): void public function deleteDraft(string $draftName): void { $this->table->getTableRow(['Name' => $draftName])->select(); - -// $this->setInteractiveBreakpoint(get_defined_vars()); $this->getHTMLPage()->find($this->getLocator('deleteButton'))->click(); $this->dialog->confirm(); } + public function doSeeDraft(string $draftName): bool + { + if (!$this->table->getTableRow(['Name' => $draftName])->canBeSelected()) + { + return true; + } + return false; + } + + protected function specifyLocators(): array { return [ From ce02d339dfaf3b5dbeb13a4dcb0f5f358856f26e Mon Sep 17 00:00:00 2001 From: Jakub Wesolowski Date: Tue, 22 Aug 2023 15:19:21 +0200 Subject: [PATCH 3/9] Added the test for the edition of draft, splited the tests into 2 versions. --- features/standard/MyDrafts.feature | 17 ++++++++++++++++- .../Behat/BrowserContext/MyDraftsContext.php | 8 ++++++++ src/lib/Behat/Page/MyDraftsPage.php | 8 +++++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/features/standard/MyDrafts.feature b/features/standard/MyDrafts.feature index 6a8044b21c..6038953651 100644 --- a/features/standard/MyDrafts.feature +++ b/features/standard/MyDrafts.feature @@ -1,7 +1,6 @@ @IbexaOSS @IbexaHeadless @IbexaExperience @IbexaCommerce @javascript Feature: My Drafts - @test Scenario: It is possible to delete a draft Given I create "article" Content drafts | title | short_title | parentPath | language | @@ -10,3 +9,19 @@ Feature: My Drafts 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 + + @test + 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 click edit "TestMyDraft" + 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" \ No newline at end of file diff --git a/src/lib/Behat/BrowserContext/MyDraftsContext.php b/src/lib/Behat/BrowserContext/MyDraftsContext.php index 2e43022f97..e5e4bff810 100644 --- a/src/lib/Behat/BrowserContext/MyDraftsContext.php +++ b/src/lib/Behat/BrowserContext/MyDraftsContext.php @@ -36,4 +36,12 @@ public function iSeeTheDraftIsDeleted(string $draftName): void { assert($this->myDraftsPage->doSeeDraft($draftName)); } + + /** + * @Given I click edit :draftName + */ + public function iClickEdit(string $draftName): void + { + $this->myDraftsPage->clickEditDraft($draftName); + } } diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php index f94a582337..11072954a9 100644 --- a/src/lib/Behat/Page/MyDraftsPage.php +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -19,8 +19,6 @@ final class MyDraftsPage extends Page private TableInterface $table; private Dialog $dialog; - use \Ibexa\Behat\Core\Debug\InteractiveDebuggerTrait; - public function __construct(Session $session, Router $router, TableBuilder $tableBuilder, Dialog $dialog) { parent::__construct($session, $router); @@ -49,11 +47,15 @@ public function doSeeDraft(string $draftName): bool return false; } - + public function clickEditDraft(string $draftName): void + { + $this->getHTMLPage()->find($this->getLocator('editButton'))->click(); + } protected function specifyLocators(): array { return [ new VisibleCSSLocator('deleteButton', '#confirm-content_remove_remove'), + new VisibleCSSLocator('editButton', '.ibexa-btn--content-draft-edit'), ]; } From ce60cf92e1e7ce3c39f828b3b6708edced67b5e9 Mon Sep 17 00:00:00 2001 From: Jakub Wesolowski Date: Tue, 22 Aug 2023 15:21:25 +0200 Subject: [PATCH 4/9] cleanup --- features/standard/MyDrafts.feature | 1 - 1 file changed, 1 deletion(-) diff --git a/features/standard/MyDrafts.feature b/features/standard/MyDrafts.feature index 6038953651..ca30b8bc9a 100644 --- a/features/standard/MyDrafts.feature +++ b/features/standard/MyDrafts.feature @@ -10,7 +10,6 @@ Feature: My Drafts When I delete the draft "TestMyDraft" from my draft lists Then I see the draft "TestMyDraft" is deleted - @test Scenario: It is possible to edit a draft Given I create "article" Content drafts | title | short_title | parentPath | language | From d18ed297ad114884e330a0ea2f614e81bed5eb64 Mon Sep 17 00:00:00 2001 From: Jakub Wesolowski Date: Tue, 22 Aug 2023 15:39:24 +0200 Subject: [PATCH 5/9] Improvemtn of the edit table selector --- src/lib/Behat/Page/MyDraftsPage.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php index 11072954a9..fa3273af18 100644 --- a/src/lib/Behat/Page/MyDraftsPage.php +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -49,13 +49,14 @@ public function doSeeDraft(string $draftName): bool public function clickEditDraft(string $draftName): void { - $this->getHTMLPage()->find($this->getLocator('editButton'))->click(); + // $this->getHTMLPage()->find($this->getLocator('editButton'))->click(); + $this->table->getTableRow(['Name' => $draftName])->edit(); } protected function specifyLocators(): array { return [ new VisibleCSSLocator('deleteButton', '#confirm-content_remove_remove'), - new VisibleCSSLocator('editButton', '.ibexa-btn--content-draft-edit'), + //new VisibleCSSLocator('editButton', '.ibexa-btn--content-draft-edit'), ]; } From 46ff77dcc3a39218a2a231a77bc6d270a45695df Mon Sep 17 00:00:00 2001 From: Jakub Wesolowski Date: Tue, 22 Aug 2023 15:50:21 +0200 Subject: [PATCH 6/9] Fixes regarding editing draft selectors --- src/lib/Behat/Page/MyDraftsPage.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php index fa3273af18..e9d99fc859 100644 --- a/src/lib/Behat/Page/MyDraftsPage.php +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -49,14 +49,12 @@ public function doSeeDraft(string $draftName): bool public function clickEditDraft(string $draftName): void { - // $this->getHTMLPage()->find($this->getLocator('editButton'))->click(); $this->table->getTableRow(['Name' => $draftName])->edit(); } protected function specifyLocators(): array { return [ new VisibleCSSLocator('deleteButton', '#confirm-content_remove_remove'), - //new VisibleCSSLocator('editButton', '.ibexa-btn--content-draft-edit'), ]; } From 7598d529da29ca92ad4d08ec5bae6e671acde880 Mon Sep 17 00:00:00 2001 From: Jakub Wesolowski Date: Tue, 22 Aug 2023 16:02:24 +0200 Subject: [PATCH 7/9] code style check fix --- src/lib/Behat/BrowserContext/MyDraftsContext.php | 3 --- src/lib/Behat/Page/MyDraftsPage.php | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/Behat/BrowserContext/MyDraftsContext.php b/src/lib/Behat/BrowserContext/MyDraftsContext.php index e5e4bff810..72ac264bdf 100644 --- a/src/lib/Behat/BrowserContext/MyDraftsContext.php +++ b/src/lib/Behat/BrowserContext/MyDraftsContext.php @@ -7,9 +7,6 @@ namespace Ibexa\AdminUi\Behat\BrowserContext; use Behat\Behat\Context\Context; -use Ibexa\AdminUi\Behat\Component\Dialog; -use Ibexa\AdminUi\Behat\Component\Table\TableBuilder; -use Ibexa\AdminUi\Behat\Component\Table\TableInterface; use Ibexa\AdminUi\Behat\Page\MyDraftsPage; final class MyDraftsContext implements Context diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php index e9d99fc859..b22cbb99ae 100644 --- a/src/lib/Behat/Page/MyDraftsPage.php +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -17,6 +17,7 @@ final class MyDraftsPage extends Page { private TableInterface $table; + private Dialog $dialog; public function __construct(Session $session, Router $router, TableBuilder $tableBuilder, Dialog $dialog) @@ -40,10 +41,10 @@ public function deleteDraft(string $draftName): void public function doSeeDraft(string $draftName): bool { - if (!$this->table->getTableRow(['Name' => $draftName])->canBeSelected()) - { + if (!$this->table->getTableRow(['Name' => $draftName])->canBeSelected()) { return true; } + return false; } @@ -51,6 +52,7 @@ public function clickEditDraft(string $draftName): void { $this->table->getTableRow(['Name' => $draftName])->edit(); } + protected function specifyLocators(): array { return [ From 056438692e51e3b3bd52f2189e248b2760af45b9 Mon Sep 17 00:00:00 2001 From: Jakub Wesolowski Date: Wed, 23 Aug 2023 15:28:54 +0200 Subject: [PATCH 8/9] Fixes regarding veryfiing deletion, style fixes, veryfiisloaded added --- features/standard/MyDrafts.feature | 6 +++--- src/lib/Behat/BrowserContext/MyDraftsContext.php | 9 +++++---- src/lib/Behat/Page/MyDraftsPage.php | 14 +++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/features/standard/MyDrafts.feature b/features/standard/MyDrafts.feature index ca30b8bc9a..9ac0c50a35 100644 --- a/features/standard/MyDrafts.feature +++ b/features/standard/MyDrafts.feature @@ -3,7 +3,7 @@ Feature: My Drafts Scenario: It is possible to delete a draft Given I create "article" Content drafts - | title | short_title | parentPath | language | + | title | short_title | parentPath | language | | TestMyDraft | TestMyDraft | root | eng-GB | And I am logged as admin And I open "MyDrafts" page in admin SiteAccess @@ -16,11 +16,11 @@ Feature: My Drafts | TestMyDraft | TestMyDraft | root | eng-GB | And I am logged as admin And I open "MyDrafts" page in admin SiteAccess - When I click edit "TestMyDraft" + When I click 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" \ No newline at end of file + Then I should be on Content update page for "TestMyDraftSavePublish" diff --git a/src/lib/Behat/BrowserContext/MyDraftsContext.php b/src/lib/Behat/BrowserContext/MyDraftsContext.php index 72ac264bdf..f3856022f6 100644 --- a/src/lib/Behat/BrowserContext/MyDraftsContext.php +++ b/src/lib/Behat/BrowserContext/MyDraftsContext.php @@ -8,6 +8,7 @@ use Behat\Behat\Context\Context; use Ibexa\AdminUi\Behat\Page\MyDraftsPage; +use PHPUnit\Framework\Assert; final class MyDraftsContext implements Context { @@ -31,14 +32,14 @@ public function iDeleteADraftFromTheList(string $draftName): void */ public function iSeeTheDraftIsDeleted(string $draftName): void { - assert($this->myDraftsPage->doSeeDraft($draftName)); + Assert::assertFalse($this->myDraftsPage->isDraftOnTheList($draftName)); } /** - * @Given I click edit :draftName + * @Given I click edit :draftName on MyDrafts page */ - public function iClickEdit(string $draftName): void + public function iEditDraft(string $draftName): void { - $this->myDraftsPage->clickEditDraft($draftName); + $this->myDraftsPage->edit($draftName); } } diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php index b22cbb99ae..e942faff0a 100644 --- a/src/lib/Behat/Page/MyDraftsPage.php +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -29,6 +29,9 @@ public function __construct(Session $session, Router $router, TableBuilder $tabl public function verifyIsLoaded(): void { + $this->getHTMLPage() + ->find($this->getLocator('pageTitle')) + ->assert()->textEquals('Drafts'); } public function deleteDraft(string $draftName): void @@ -39,16 +42,12 @@ public function deleteDraft(string $draftName): void $this->dialog->confirm(); } - public function doSeeDraft(string $draftName): bool + public function isDraftOnTheList(string $draftName): bool { - if (!$this->table->getTableRow(['Name' => $draftName])->canBeSelected()) { - return true; - } - - return false; + return $this->table->hasElement(['Name' => $draftName]); } - public function clickEditDraft(string $draftName): void + public function edit(string $draftName): void { $this->table->getTableRow(['Name' => $draftName])->edit(); } @@ -57,6 +56,7 @@ protected function specifyLocators(): array { return [ new VisibleCSSLocator('deleteButton', '#confirm-content_remove_remove'), + new VisibleCSSLocator('pageTitle', '.ibexa-page-title h1'), ]; } From ed4d919463f19f2c6c0cf8660c30c72c38bf6801 Mon Sep 17 00:00:00 2001 From: Jakub Wesolowski Date: Thu, 24 Aug 2023 09:21:08 +0200 Subject: [PATCH 9/9] Added fix regarding not finding delete confirmation, naming fix --- features/standard/MyDrafts.feature | 2 +- src/lib/Behat/BrowserContext/MyDraftsContext.php | 2 +- src/lib/Behat/Page/MyDraftsPage.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/standard/MyDrafts.feature b/features/standard/MyDrafts.feature index 9ac0c50a35..e91d27b927 100644 --- a/features/standard/MyDrafts.feature +++ b/features/standard/MyDrafts.feature @@ -16,7 +16,7 @@ Feature: My Drafts | TestMyDraft | TestMyDraft | root | eng-GB | And I am logged as admin And I open "MyDrafts" page in admin SiteAccess - When I click edit "TestMyDraft" on MyDrafts page + When I edit "TestMyDraft" on MyDrafts page And I set content fields | label | value | | Title | TestMyDraftSavePublish | diff --git a/src/lib/Behat/BrowserContext/MyDraftsContext.php b/src/lib/Behat/BrowserContext/MyDraftsContext.php index f3856022f6..06af9fcbe1 100644 --- a/src/lib/Behat/BrowserContext/MyDraftsContext.php +++ b/src/lib/Behat/BrowserContext/MyDraftsContext.php @@ -36,7 +36,7 @@ public function iSeeTheDraftIsDeleted(string $draftName): void } /** - * @Given I click edit :draftName on MyDrafts page + * @Given I edit :draftName on MyDrafts page */ public function iEditDraft(string $draftName): void { diff --git a/src/lib/Behat/Page/MyDraftsPage.php b/src/lib/Behat/Page/MyDraftsPage.php index e942faff0a..98499cfcf1 100644 --- a/src/lib/Behat/Page/MyDraftsPage.php +++ b/src/lib/Behat/Page/MyDraftsPage.php @@ -37,8 +37,8 @@ public function verifyIsLoaded(): void 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(); }