From e7a206a3e3f4e90782a940577ac1d14ed314d848 Mon Sep 17 00:00:00 2001 From: adrianpawlak Date: Wed, 1 Oct 2025 16:14:56 +0200 Subject: [PATCH 1/8] IBX-10333 Added scenario for hide later coverage --- features/standard/ContentManagement.feature | 18 ++++++++++ .../BrowserContext/ContentViewContext.php | 34 ++++++++++++++++++ src/lib/Behat/Page/ContentViewPage.php | 35 +++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/features/standard/ContentManagement.feature b/features/standard/ContentManagement.feature index b0cc11610f..0eab4ba334 100644 --- a/features/standard/ContentManagement.feature +++ b/features/standard/ContentManagement.feature @@ -133,3 +133,21 @@ Scenario: Content can be copied When I perform the "Reveal" action And I should be on Content view Page for "ContentManagement/TestArticleToHide" Then success notification that "Content item 'TestArticleToHide' revealed." appears + + @IbexaOSS @IbexaHeadless @IbexaExperience @IbexaCommerce + Scenario: Content can be hidden later + Given a "folder" Content item named "ContentManagement" exists in root + | name | short_name | + | ContentManagement | ContentManagement | + And a "article" Content item named "TestArticleToHideLater" exists in "ContentManagement" + | title | short_title | intro | + | TestArticleToHideLater | TestArticleToHideLater | TestArticleIntro | + And I'm on Content view Page for "ContentManagement/TestArticleToHideLater" + When I perform the "Hide" action + And I select hide "later" for field options + And I perform the "Confirm" action + And I should be on Content view Page for "ContentManagement/TestArticleToHideLater" + Then I should see the alert contains "This Content item will be hidden and won't be publicly available after" appear + When I run the scheduled jobs + And I clear the behat cache directory + Then I should see the alert "This Content item or its Location is hidden." appear diff --git a/src/lib/Behat/BrowserContext/ContentViewContext.php b/src/lib/Behat/BrowserContext/ContentViewContext.php index df5d09b9ea..885f6865f4 100644 --- a/src/lib/Behat/BrowserContext/ContentViewContext.php +++ b/src/lib/Behat/BrowserContext/ContentViewContext.php @@ -197,4 +197,38 @@ public function verifyUrlAliasExists(string $path, string $type): void sprintf('Url alias "%s" with type "%s" not found', $path, $type) ); } + + /** + * @Given I select hide :hideOption for field options + */ + public function iSelectForFieldOptions(string $hideOption): void + { + $this->contentViewPage->verifyIsLoaded(); + $this->contentViewPage->selectHideOption($hideOption); + } + + /** + * @Then I should see the alert contains :alertMessage appear + */ + public function iShouldSeeTheAlertContainsAppear(string $alertMessage): void + { + $this->contentViewPage->verifyIsLoaded(); + $this->contentViewPage->verifyMessageContains($alertMessage); + } + + /** + * @When I run the scheduled jobs + */ + public function iRunTheScheduledJobs(): void + { + $this->contentViewPage->runScheduledJobs(); + } + + /** + * @When I clear the behat cache directory + */ + public function iClearTheBehatCacheDirectory(): void + { + $this->contentViewPage->clearBehatCacheDirectory(); + } } diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index 64a78ee31a..9c9a61a872 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -24,6 +24,7 @@ use Ibexa\AdminUi\Behat\Component\UniversalDiscoveryWidget; use Ibexa\AdminUi\Behat\Component\UpperMenu; use Ibexa\Behat\Browser\Element\Condition\ElementExistsCondition; +use Ibexa\Behat\Browser\Element\Criterion\ElementAttributeCriterion; use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; use Ibexa\Behat\Browser\Page\Page; @@ -33,6 +34,8 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias; use PHPUnit\Framework\Assert; +use Symfony\Component\Filesystem\Exception\IOExceptionInterface; +use Symfony\Component\Filesystem\Filesystem; class ContentViewPage extends Page { @@ -337,6 +340,7 @@ protected function specifyLocators(): array new VisibleCSSLocator('addUrlAliasButton', '#ibexa-tab-location-view-urls [data-bs-target="#ibexa-modal--custom-url-alias"]'), new VisibleCSSLocator('customUrlAliasesTable', '#ibexa-tab-location-view-urls .ibexa-table'), new VisibleCSSLocator('alertTitle', '.ibexa-alert__title'), + new VisibleCSSLocator('selectHideMode', '.form-check .ibexa-input--radio'), ]; } @@ -384,4 +388,35 @@ public function verifyMessage(string $expectedMessage): void { $this->getHTMLPage()->setTimeout(3)->find($this->getLocator('alertTitle'))->assert()->textEquals($expectedMessage); } + + public function selectHideOption(string $viewMode): void + { + $this->getHTMLPage() + ->findAll($this->getLocator('selectHideMode')) + ->getByCriterion(new ElementAttributeCriterion('value', $viewMode))->click(); + } + + public function verifyMessageContains(string $alertMessage): void + { + $this->getHTMLPage()->find($this->getLocator('alertTitle'))->assert()->textContains($alertMessage); + } + + public function runScheduledJobs(): void + { + shell_exec('bin/console ibexa:scheduled:run'); + } + + public function clearBehatCacheDirectory(): void + { + $filesystem = new Filesystem(); + $cacheDir = getcwd() . \DIRECTORY_SEPARATOR . 'var' . \DIRECTORY_SEPARATOR . 'cache'; + + try { + $filesystem->remove($cacheDir); + $this->getHTMLPage()->setTimeout(5); + $this->getSession()->reload(); + } catch (IOExceptionInterface $exception) { + throw new \Exception('Error while clearing cache: ' . $exception->getMessage()); + } + } } From 1b268e1d43b5856996865fa1b202e44fa67558f2 Mon Sep 17 00:00:00 2001 From: adrianpawlak Date: Thu, 2 Oct 2025 09:39:13 +0200 Subject: [PATCH 2/8] IBX-10333 Removed OSS from hide later scenario --- features/standard/ContentManagement.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/standard/ContentManagement.feature b/features/standard/ContentManagement.feature index 0eab4ba334..2a13494a42 100644 --- a/features/standard/ContentManagement.feature +++ b/features/standard/ContentManagement.feature @@ -134,7 +134,7 @@ Scenario: Content can be copied And I should be on Content view Page for "ContentManagement/TestArticleToHide" Then success notification that "Content item 'TestArticleToHide' revealed." appears - @IbexaOSS @IbexaHeadless @IbexaExperience @IbexaCommerce + @IbexaHeadless @IbexaExperience @IbexaCommerce Scenario: Content can be hidden later Given a "folder" Content item named "ContentManagement" exists in root | name | short_name | From 075e84063ae2c869eed4fa2b16958a424bc83e72 Mon Sep 17 00:00:00 2001 From: adrianpawlak Date: Fri, 3 Oct 2025 12:43:19 +0200 Subject: [PATCH 3/8] IBX-10333 Added scenario for canceling the schedule for hiding later content. --- features/standard/ContentManagement.feature | 17 +++++++++++ .../config/services/test/components.yaml | 2 ++ .../BrowserContext/ContentViewContext.php | 8 +++++ .../Behat/Component/CancelContentDialog.php | 30 +++++++++++++++++++ src/lib/Behat/Page/ContentViewPage.php | 17 ++++++++++- 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/lib/Behat/Component/CancelContentDialog.php diff --git a/features/standard/ContentManagement.feature b/features/standard/ContentManagement.feature index 2a13494a42..eca522648f 100644 --- a/features/standard/ContentManagement.feature +++ b/features/standard/ContentManagement.feature @@ -151,3 +151,20 @@ Scenario: Content can be copied When I run the scheduled jobs And I clear the behat cache directory Then I should see the alert "This Content item or its Location is hidden." appear + + @IbexaHeadless @IbexaExperience @IbexaCommerce + Scenario: Content hide later can be cancelled + Given a "folder" Content item named "ContentManagement" exists in root + | name | short_name | + | ContentManagement | ContentManagement | + And a "article" Content item named "TestArticleToHideLater" exists in "ContentManagement" + | title | short_title | intro | + | TestArticleToCancelHideLater | TestArticleToCancelHideLater | TestArticleIntro | + And I'm on Content view Page for "ContentManagement/TestArticleToCancelHideLater" + When I perform the "Hide" action + And I select hide "later" for field options + And I perform the "Confirm" action + And I should be on Content view Page for "ContentManagement/TestArticleToCancelHideLater" + Then I should see the alert contains "This Content item will be hidden and won't be publicly available after" appear + When I cancel scheduled hiding of the content item + Then I should see the alert "Canceled scheduled hiding of Content item 'TestArticleToCancelHideLater'." appear diff --git a/src/bundle/Resources/config/services/test/components.yaml b/src/bundle/Resources/config/services/test/components.yaml index c87348d52d..feea18c180 100644 --- a/src/bundle/Resources/config/services/test/components.yaml +++ b/src/bundle/Resources/config/services/test/components.yaml @@ -64,3 +64,5 @@ services: Ibexa\AdminUi\Behat\Component\TrashSearch: ~ + Ibexa\AdminUi\Behat\Component\CancelContentDialog: ~ + diff --git a/src/lib/Behat/BrowserContext/ContentViewContext.php b/src/lib/Behat/BrowserContext/ContentViewContext.php index 885f6865f4..ee22d0c024 100644 --- a/src/lib/Behat/BrowserContext/ContentViewContext.php +++ b/src/lib/Behat/BrowserContext/ContentViewContext.php @@ -231,4 +231,12 @@ public function iClearTheBehatCacheDirectory(): void { $this->contentViewPage->clearBehatCacheDirectory(); } + + /** + * @When I cancel scheduled hiding of the content item + */ + public function iCancelScheduledHidingOfTheContentItem(): void + { + $this->contentViewPage->cancelScheduledHiding(); + } } diff --git a/src/lib/Behat/Component/CancelContentDialog.php b/src/lib/Behat/Component/CancelContentDialog.php new file mode 100644 index 0000000000..a482fa86a9 --- /dev/null +++ b/src/lib/Behat/Component/CancelContentDialog.php @@ -0,0 +1,30 @@ +getHTMLPage() + ->findAll($this->getLocator('confirmCancelButton')) + ->getByCriterion(new ElementTextCriterion($cancelScheduledHidingButton)) + ->click(); + } + + public function specifyLocators(): array + { + return array_merge(parent::specifyLocators(), [ + new VisibleCSSLocator('confirmCancelButton', '#review-content-modal .ibexa-btn'), + ]); + } +} diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index 9c9a61a872..0c8ef5fc46 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -10,6 +10,7 @@ use Behat\Mink\Session; use Ibexa\AdminUi\Behat\Component\Breadcrumb; +use Ibexa\AdminUi\Behat\Component\CancelContentDialog; use Ibexa\AdminUi\Behat\Component\ContentActionsMenu; use Ibexa\AdminUi\Behat\Component\ContentItemAdminPreview; use Ibexa\AdminUi\Behat\Component\ContentTypePicker; @@ -94,6 +95,8 @@ class ContentViewPage extends Page private TableBuilder $tableBuilder; + private ?CancelContentDialog $cancelContentDialog; + public function __construct( Session $session, Router $router, @@ -112,7 +115,8 @@ public function __construct( UpperMenu $upperMenu, DeleteContentDialog $deleteContentDialog, CreateUrlAliasModal $createUrlAliasModal, - TableBuilder $tableBuilder + TableBuilder $tableBuilder, + ?CancelContentDialog $cancelContentDialog = null ) { parent::__construct($session, $router); @@ -132,6 +136,7 @@ public function __construct( $this->deleteContentDialog = $deleteContentDialog; $this->createUrlAliasModal = $createUrlAliasModal; $this->tableBuilder = $tableBuilder; + $this->cancelContentDialog = $cancelContentDialog; } public function startCreatingContent(string $contentTypeName, ?string $language = null) @@ -341,6 +346,7 @@ protected function specifyLocators(): array new VisibleCSSLocator('customUrlAliasesTable', '#ibexa-tab-location-view-urls .ibexa-table'), new VisibleCSSLocator('alertTitle', '.ibexa-alert__title'), new VisibleCSSLocator('selectHideMode', '.form-check .ibexa-input--radio'), + new VisibleCSSLocator('cancelScheduleButton', '.ibexa-btn--schedule-hide-cancel'), ]; } @@ -419,4 +425,13 @@ public function clearBehatCacheDirectory(): void throw new \Exception('Error while clearing cache: ' . $exception->getMessage()); } } + + public function cancelScheduledHiding(): void + { + $this->getHTMLPage()->find($this->getLocator('cancelScheduleButton'))->click(); + $this->dialog->verifyIsLoaded(); + if ($this->cancelContentDialog !== null) { + $this->cancelContentDialog->confirmCanceling('Cancel scheduled hiding'); + } + } } From 624827e443eb2a37099fbaf896bb1f4db6649bed Mon Sep 17 00:00:00 2001 From: adrianpawlak Date: Tue, 18 Nov 2025 15:47:16 +0100 Subject: [PATCH 4/8] Fixes after review --- features/standard/ContentManagement.feature | 8 ++--- .../Behat/Component/CancelContentDialog.php | 30 ------------------- src/lib/Behat/Page/ContentViewPage.php | 15 ++-------- 3 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 src/lib/Behat/Component/CancelContentDialog.php diff --git a/features/standard/ContentManagement.feature b/features/standard/ContentManagement.feature index eca522648f..a616b92c40 100644 --- a/features/standard/ContentManagement.feature +++ b/features/standard/ContentManagement.feature @@ -143,11 +143,11 @@ Scenario: Content can be copied | title | short_title | intro | | TestArticleToHideLater | TestArticleToHideLater | TestArticleIntro | And I'm on Content view Page for "ContentManagement/TestArticleToHideLater" - When I perform the "Hide" action + And I perform the "Hide" action And I select hide "later" for field options And I perform the "Confirm" action And I should be on Content view Page for "ContentManagement/TestArticleToHideLater" - Then I should see the alert contains "This Content item will be hidden and won't be publicly available after" appear + And I should see the alert contains "This Content item will be hidden and won't be publicly available after" appear When I run the scheduled jobs And I clear the behat cache directory Then I should see the alert "This Content item or its Location is hidden." appear @@ -161,10 +161,10 @@ Scenario: Content can be copied | title | short_title | intro | | TestArticleToCancelHideLater | TestArticleToCancelHideLater | TestArticleIntro | And I'm on Content view Page for "ContentManagement/TestArticleToCancelHideLater" - When I perform the "Hide" action + And I perform the "Hide" action And I select hide "later" for field options And I perform the "Confirm" action And I should be on Content view Page for "ContentManagement/TestArticleToCancelHideLater" - Then I should see the alert contains "This Content item will be hidden and won't be publicly available after" appear + And I should see the alert contains "This Content item will be hidden and won't be publicly available after" appear When I cancel scheduled hiding of the content item Then I should see the alert "Canceled scheduled hiding of Content item 'TestArticleToCancelHideLater'." appear diff --git a/src/lib/Behat/Component/CancelContentDialog.php b/src/lib/Behat/Component/CancelContentDialog.php deleted file mode 100644 index a482fa86a9..0000000000 --- a/src/lib/Behat/Component/CancelContentDialog.php +++ /dev/null @@ -1,30 +0,0 @@ -getHTMLPage() - ->findAll($this->getLocator('confirmCancelButton')) - ->getByCriterion(new ElementTextCriterion($cancelScheduledHidingButton)) - ->click(); - } - - public function specifyLocators(): array - { - return array_merge(parent::specifyLocators(), [ - new VisibleCSSLocator('confirmCancelButton', '#review-content-modal .ibexa-btn'), - ]); - } -} diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index 0c8ef5fc46..55b793afeb 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -95,8 +95,6 @@ class ContentViewPage extends Page private TableBuilder $tableBuilder; - private ?CancelContentDialog $cancelContentDialog; - public function __construct( Session $session, Router $router, @@ -115,8 +113,7 @@ public function __construct( UpperMenu $upperMenu, DeleteContentDialog $deleteContentDialog, CreateUrlAliasModal $createUrlAliasModal, - TableBuilder $tableBuilder, - ?CancelContentDialog $cancelContentDialog = null + TableBuilder $tableBuilder ) { parent::__construct($session, $router); @@ -136,16 +133,12 @@ public function __construct( $this->deleteContentDialog = $deleteContentDialog; $this->createUrlAliasModal = $createUrlAliasModal; $this->tableBuilder = $tableBuilder; - $this->cancelContentDialog = $cancelContentDialog; } - public function startCreatingContent(string $contentTypeName, ?string $language = null) + public function startCreatingContent(string $contentTypeName) { $this->contentActionsMenu->clickButton('Create content'); $this->contentTypePicker->verifyIsLoaded(); - if ($language !== null) { - $this->contentTypePicker->selectLanguage($language); - } $this->contentTypePicker->select($contentTypeName); $this->contentTypePicker->confirm(); } @@ -430,8 +423,6 @@ public function cancelScheduledHiding(): void { $this->getHTMLPage()->find($this->getLocator('cancelScheduleButton'))->click(); $this->dialog->verifyIsLoaded(); - if ($this->cancelContentDialog !== null) { - $this->cancelContentDialog->confirmCanceling('Cancel scheduled hiding'); - } + $this->dialog->confirm(); } } From 958619a3b6ac8cdac17f5c22acaac2ed2b21fbad Mon Sep 17 00:00:00 2001 From: adrianpawlak Date: Tue, 18 Nov 2025 16:14:05 +0100 Subject: [PATCH 5/8] Restored some parts of code --- src/lib/Behat/Page/ContentViewPage.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index 55b793afeb..bc0fb416d1 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -10,7 +10,6 @@ use Behat\Mink\Session; use Ibexa\AdminUi\Behat\Component\Breadcrumb; -use Ibexa\AdminUi\Behat\Component\CancelContentDialog; use Ibexa\AdminUi\Behat\Component\ContentActionsMenu; use Ibexa\AdminUi\Behat\Component\ContentItemAdminPreview; use Ibexa\AdminUi\Behat\Component\ContentTypePicker; @@ -135,10 +134,13 @@ public function __construct( $this->tableBuilder = $tableBuilder; } - public function startCreatingContent(string $contentTypeName) + public function startCreatingContent(string $contentTypeName, ?string $language = null) { $this->contentActionsMenu->clickButton('Create content'); $this->contentTypePicker->verifyIsLoaded(); + if ($language !== null) { + $this->contentTypePicker->selectLanguage($language); + } $this->contentTypePicker->select($contentTypeName); $this->contentTypePicker->confirm(); } From d3af9daf019e473bf8762585e034a6170147f5fb Mon Sep 17 00:00:00 2001 From: adrianpawlak Date: Thu, 20 Nov 2025 09:50:33 +0100 Subject: [PATCH 6/8] Removed unused component --- src/bundle/Resources/config/services/test/components.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bundle/Resources/config/services/test/components.yaml b/src/bundle/Resources/config/services/test/components.yaml index feea18c180..5b4a830ccc 100644 --- a/src/bundle/Resources/config/services/test/components.yaml +++ b/src/bundle/Resources/config/services/test/components.yaml @@ -64,5 +64,4 @@ services: Ibexa\AdminUi\Behat\Component\TrashSearch: ~ - Ibexa\AdminUi\Behat\Component\CancelContentDialog: ~ From 50f8ec8305bc335fed9479c19c96d6d0e11f935a Mon Sep 17 00:00:00 2001 From: adrianpawlak Date: Thu, 20 Nov 2025 10:23:42 +0100 Subject: [PATCH 7/8] Fix line --- src/bundle/Resources/config/services/test/components.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bundle/Resources/config/services/test/components.yaml b/src/bundle/Resources/config/services/test/components.yaml index 5b4a830ccc..c238279903 100644 --- a/src/bundle/Resources/config/services/test/components.yaml +++ b/src/bundle/Resources/config/services/test/components.yaml @@ -63,5 +63,3 @@ services: Ibexa\AdminUi\Behat\Component\CreateUrlAliasModal: ~ Ibexa\AdminUi\Behat\Component\TrashSearch: ~ - - From 688403d9487e5767bdf496c4ec33c398946f576d Mon Sep 17 00:00:00 2001 From: adrianpawlak Date: Thu, 20 Nov 2025 10:25:29 +0100 Subject: [PATCH 8/8] Fix line --- src/bundle/Resources/config/services/test/components.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bundle/Resources/config/services/test/components.yaml b/src/bundle/Resources/config/services/test/components.yaml index c238279903..c87348d52d 100644 --- a/src/bundle/Resources/config/services/test/components.yaml +++ b/src/bundle/Resources/config/services/test/components.yaml @@ -63,3 +63,4 @@ services: Ibexa\AdminUi\Behat\Component\CreateUrlAliasModal: ~ Ibexa\AdminUi\Behat\Component\TrashSearch: ~ +