Skip to content
Merged
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"
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"
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

@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"
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"
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
42 changes: 42 additions & 0 deletions src/lib/Behat/BrowserContext/ContentViewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,46 @@ 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();
}

/**
* @When I cancel scheduled hiding of the content item
*/
public function iCancelScheduledHidingOfTheContentItem(): void
{
$this->contentViewPage->cancelScheduledHiding();
}
}
43 changes: 43 additions & 0 deletions src/lib/Behat/Page/ContentViewPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -337,6 +340,8 @@ 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'),
new VisibleCSSLocator('cancelScheduleButton', '.ibexa-btn--schedule-hide-cancel'),
];
}

Expand Down Expand Up @@ -384,4 +389,42 @@ 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();
$this->dialog->confirm();
}
}
Loading