Skip to content

Commit f0aaf3e

Browse files
committed
IBX-10333 Added scenario for canceling the schedule for hiding later content.
1 parent b1a5fb4 commit f0aaf3e

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
@@ -61,3 +61,5 @@ services:
6161
Ibexa\AdminUi\Behat\Component\DeleteContentDialog: ~
6262

6363
Ibexa\AdminUi\Behat\Component\TrashSearch: ~
64+
65+
Ibexa\AdminUi\Behat\Component\CancelContentDialog: ~

src/lib/Behat/BrowserContext/ContentViewContext.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,12 @@ public function iClearTheBehatCacheDirectory(): void
211211
{
212212
$this->contentViewPage->clearBehatCacheDirectory();
213213
}
214+
215+
/**
216+
* @When I cancel scheduled hiding of the content item
217+
*/
218+
public function iCancelScheduledHidingOfTheContentItem(): void
219+
{
220+
$this->contentViewPage->cancelScheduledHiding();
221+
}
214222
}
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;
@@ -88,6 +89,8 @@ class ContentViewPage extends Page
8889

8990
private DeleteContentDialog $deleteContentDialog;
9091

92+
private ?CancelContentDialog $cancelContentDialog;
93+
9194
public function __construct(
9295
Session $session,
9396
Router $router,
@@ -104,7 +107,8 @@ public function __construct(
104107
UniversalDiscoveryWidget $universalDiscoveryWidget,
105108
IbexaDropdown $ibexaDropdown,
106109
UpperMenu $upperMenu,
107-
DeleteContentDialog $deleteContentDialog
110+
DeleteContentDialog $deleteContentDialog,
111+
?CancelContentDialog $cancelContentDialog = null
108112
) {
109113
parent::__construct($session, $router);
110114
$this->contentActionsMenu = $contentActionsMenu;
@@ -121,6 +125,7 @@ public function __construct(
121125
$this->ibexaDropdown = $ibexaDropdown;
122126
$this->upperMenu = $upperMenu;
123127
$this->deleteContentDialog = $deleteContentDialog;
128+
$this->cancelContentDialog = $cancelContentDialog;
124129
}
125130

126131
public function startCreatingContent(string $contentTypeName, ?string $language = null)
@@ -313,6 +318,7 @@ protected function specifyLocators(): array
313318
new VisibleCSSLocator('popupMenuItem', '.ibexa-popup-menu__item .ibexa-popup-menu__item-content'),
314319
new VisibleCSSLocator('alertTitle', '.ibexa-alert__title'),
315320
new VisibleCSSLocator('selectHideMode', '.form-check .ibexa-input--radio'),
321+
new VisibleCSSLocator('cancelScheduleButton', '.ibexa-btn--schedule-hide-cancel'),
316322
];
317323
}
318324

@@ -391,4 +397,13 @@ public function clearBehatCacheDirectory(): void
391397
throw new \Exception('Error while clearing cache: ' . $exception->getMessage());
392398
}
393399
}
400+
401+
public function cancelScheduledHiding(): void
402+
{
403+
$this->getHTMLPage()->find($this->getLocator('cancelScheduleButton'))->click();
404+
$this->dialog->verifyIsLoaded();
405+
if ($this->cancelContentDialog !== null) {
406+
$this->cancelContentDialog->confirmCanceling('Cancel scheduled hiding');
407+
}
408+
}
394409
}

0 commit comments

Comments
 (0)