Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions features/standard/ContentManagement.feature
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,38 @@ 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

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets only use When/Then once per scenario. Focus of this scenario should a be a scheduler run.

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

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

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
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/services/test/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ services:
Ibexa\AdminUi\Behat\Component\DeleteContentDialog: ~

Ibexa\AdminUi\Behat\Component\TrashSearch: ~

Ibexa\AdminUi\Behat\Component\CancelContentDialog: ~
42 changes: 42 additions & 0 deletions src/lib/Behat/BrowserContext/ContentViewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,46 @@ public function iShouldSeeAlertAppears(string $alertMessage): void
$this->contentViewPage->verifyIsLoaded();
$this->contentViewPage->verifyMessage($alertMessage);
}

/**
* @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();
}

/**
* @When I cancel scheduled hiding of the content item
*/
public function iCancelScheduledHidingOfTheContentItem(): void
{
$this->contentViewPage->cancelScheduledHiding();
}
}
30 changes: 30 additions & 0 deletions src/lib/Behat/Component/CancelContentDialog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\Behat\Component;

use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion;
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;

class CancelContentDialog extends Dialog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that Dialog component should be enough here.
This locator https://github.com/ibexa/admin-ui/blob/main/src/lib/Behat/Component/Dialog.php#L35C47-L35C177 covers Cancel scheduled hiding button
Screenshot 2025-10-06 at 12 22 15

{
public function confirmCanceling(string $cancelScheduledHidingButton): void
{
$this->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'),
]);
}
}
52 changes: 51 additions & 1 deletion src/lib/Behat/Page/ContentViewPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +23,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;
Expand All @@ -31,6 +33,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
{
Expand Down Expand Up @@ -85,6 +89,8 @@ class ContentViewPage extends Page

private DeleteContentDialog $deleteContentDialog;

private ?CancelContentDialog $cancelContentDialog;

public function __construct(
Session $session,
Router $router,
Expand All @@ -101,7 +107,8 @@ public function __construct(
UniversalDiscoveryWidget $universalDiscoveryWidget,
IbexaDropdown $ibexaDropdown,
UpperMenu $upperMenu,
DeleteContentDialog $deleteContentDialog
DeleteContentDialog $deleteContentDialog,
?CancelContentDialog $cancelContentDialog = null
) {
parent::__construct($session, $router);
$this->contentActionsMenu = $contentActionsMenu;
Expand All @@ -118,6 +125,7 @@ public function __construct(
$this->ibexaDropdown = $ibexaDropdown;
$this->upperMenu = $upperMenu;
$this->deleteContentDialog = $deleteContentDialog;
$this->cancelContentDialog = $cancelContentDialog;
}

public function startCreatingContent(string $contentTypeName, ?string $language = null)
Expand Down Expand Up @@ -309,6 +317,8 @@ protected function specifyLocators(): array
new VisibleCSSLocator('moreTab', '.ibexa-tabs__tab--more'),
new VisibleCSSLocator('popupMenuItem', '.ibexa-popup-menu__item .ibexa-popup-menu__item-content'),
new VisibleCSSLocator('alertTitle', '.ibexa-alert__title'),
new VisibleCSSLocator('selectHideMode', '.form-check .ibexa-input--radio'),
new VisibleCSSLocator('cancelScheduleButton', '.ibexa-btn--schedule-hide-cancel'),
];
}

Expand Down Expand Up @@ -356,4 +366,44 @@ 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());
}
}

public function cancelScheduledHiding(): void
{
$this->getHTMLPage()->find($this->getLocator('cancelScheduleButton'))->click();
$this->dialog->verifyIsLoaded();
if ($this->cancelContentDialog !== null) {
$this->cancelContentDialog->confirmCanceling('Cancel scheduled hiding');
}
}
}
Loading