Skip to content

Commit 4c7194b

Browse files
committed
IBX-10333 Added scenario for canceling the schedule for hiding later content.
1 parent 06111ec commit 4c7194b

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

features/standard/ContentManagement.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,20 @@ Scenario: Content can be copied
151151
When I run the scheduled jobs
152152
And I clear the behat cache directory
153153
Then I should see the alert "This Content item or its Location is hidden." appear
154+
155+
@IbexaHeadless @IbexaExperience @IbexaCommerce
156+
Scenario: Content hide later can be cancelled
157+
Given a "folder" Content item named "ContentManagement" exists in root
158+
| name | short_name |
159+
| ContentManagement | ContentManagement |
160+
And a "article" Content item named "TestArticleToHideLater" exists in "ContentManagement"
161+
| title | short_title | intro |
162+
| TestArticleToCancelHideLater | TestArticleToCancelHideLater | TestArticleIntro |
163+
And I'm on Content view Page for "ContentManagement/TestArticleToCancelHideLater"
164+
When I perform the "Hide" action
165+
And I select hide "later" for field options
166+
And I perform the "Confirm" action
167+
And I should be on Content view Page for "ContentManagement/TestArticleToCancelHideLater"
168+
Then I should see the alert contains "This Content item will be hidden and won't be publicly available after" appear
169+
When I cancel scheduled hiding of the content item
170+
Then I should see the alert "Canceled scheduled hiding of Content item 'TestArticleToCancelHideLater'." appear

src/bundle/Resources/config/services/test/components.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ services:
6464

6565
Ibexa\AdminUi\Behat\Component\TrashSearch: ~
6666

67+
Ibexa\AdminUi\Behat\Component\CancelContentDialog: ~
68+

src/lib/Behat/BrowserContext/ContentViewContext.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,12 @@ public function iClearTheBehatCacheDirectory(): void
231231
{
232232
$this->contentViewPage->clearBehatCacheDirectory();
233233
}
234+
235+
/**
236+
* @When I cancel scheduled hiding of the content item
237+
*/
238+
public function iCancelScheduledHidingOfTheContentItem(): void
239+
{
240+
$this->contentViewPage->cancelScheduledHiding();
241+
}
234242
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\AdminUi\Behat\Component;
10+
11+
use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion;
12+
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
13+
14+
class CancelContentDialog extends Dialog
15+
{
16+
public function confirmCanceling(string $cancelScheduledHidingButton): void
17+
{
18+
$this->getHTMLPage()
19+
->findAll($this->getLocator('confirmCancelButton'))
20+
->getByCriterion(new ElementTextCriterion($cancelScheduledHidingButton))
21+
->click();
22+
}
23+
24+
public function specifyLocators(): array
25+
{
26+
return array_merge(parent::specifyLocators(), [
27+
new VisibleCSSLocator('confirmCancelButton', '#review-content-modal .ibexa-btn'),
28+
]);
29+
}
30+
}

src/lib/Behat/Page/ContentViewPage.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Behat\Mink\Session;
1212
use Ibexa\AdminUi\Behat\Component\Breadcrumb;
13+
use Ibexa\AdminUi\Behat\Component\CancelContentDialog;
1314
use Ibexa\AdminUi\Behat\Component\ContentActionsMenu;
1415
use Ibexa\AdminUi\Behat\Component\ContentItemAdminPreview;
1516
use Ibexa\AdminUi\Behat\Component\ContentTypePicker;
@@ -94,6 +95,8 @@ class ContentViewPage extends Page
9495

9596
private TableBuilder $tableBuilder;
9697

98+
private ?CancelContentDialog $cancelContentDialog;
99+
97100
public function __construct(
98101
Session $session,
99102
Router $router,
@@ -112,7 +115,8 @@ public function __construct(
112115
UpperMenu $upperMenu,
113116
DeleteContentDialog $deleteContentDialog,
114117
CreateUrlAliasModal $createUrlAliasModal,
115-
TableBuilder $tableBuilder
118+
TableBuilder $tableBuilder,
119+
?CancelContentDialog $cancelContentDialog = null
116120
) {
117121
parent::__construct($session, $router);
118122

@@ -132,6 +136,7 @@ public function __construct(
132136
$this->deleteContentDialog = $deleteContentDialog;
133137
$this->createUrlAliasModal = $createUrlAliasModal;
134138
$this->tableBuilder = $tableBuilder;
139+
$this->cancelContentDialog = $cancelContentDialog;
135140
}
136141

137142
public function startCreatingContent(string $contentTypeName, ?string $language = null)
@@ -341,6 +346,7 @@ protected function specifyLocators(): array
341346
new VisibleCSSLocator('customUrlAliasesTable', '#ibexa-tab-location-view-urls .ibexa-table'),
342347
new VisibleCSSLocator('alertTitle', '.ibexa-alert__title'),
343348
new VisibleCSSLocator('selectHideMode', '.form-check .ibexa-input--radio'),
349+
new VisibleCSSLocator('cancelScheduleButton', '.ibexa-btn--schedule-hide-cancel'),
344350
];
345351
}
346352

@@ -419,4 +425,13 @@ public function clearBehatCacheDirectory(): void
419425
throw new \Exception('Error while clearing cache: ' . $exception->getMessage());
420426
}
421427
}
428+
429+
public function cancelScheduledHiding(): void
430+
{
431+
$this->getHTMLPage()->find($this->getLocator('cancelScheduleButton'))->click();
432+
$this->dialog->verifyIsLoaded();
433+
if ($this->cancelContentDialog !== null) {
434+
$this->cancelContentDialog->confirmCanceling('Cancel scheduled hiding');
435+
}
436+
}
422437
}

0 commit comments

Comments
 (0)