Skip to content

Commit a206569

Browse files
committed
IBX-10333 Added scenario for hide later coverage
1 parent 9d5195c commit a206569

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

features/standard/ContentManagement.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,21 @@ Scenario: Content can be copied
133133
When I perform the "Reveal" action
134134
And I should be on Content view Page for "ContentManagement/TestArticleToHide"
135135
Then success notification that "Content item 'TestArticleToHide' revealed." appears
136+
137+
@IbexaOSS @IbexaHeadless @IbexaExperience @IbexaCommerce
138+
Scenario: Content can be hidden later
139+
Given a "folder" Content item named "ContentManagement" exists in root
140+
| name | short_name |
141+
| ContentManagement | ContentManagement |
142+
And a "article" Content item named "TestArticleToHideLater" exists in "ContentManagement"
143+
| title | short_title | intro |
144+
| TestArticleToHideLater | TestArticleToHideLater | TestArticleIntro |
145+
And I'm on Content view Page for "ContentManagement/TestArticleToHideLater"
146+
When I perform the "Hide" action
147+
And I select hide "later" for field options
148+
And I perform the "Confirm" action
149+
And I should be on Content view Page for "ContentManagement/TestArticleToHideLater"
150+
Then I should see the alert contains "This Content item will be hidden and won't be publicly available after" appear
151+
When I run the scheduled jobs
152+
And I clear the behat cache directory
153+
Then I should see the alert "This Content item or its Location is hidden." appear

src/lib/Behat/BrowserContext/ContentViewContext.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,38 @@ public function verifyUrlAliasExists(string $path, string $type): void
197197
sprintf('Url alias "%s" with type "%s" not found', $path, $type)
198198
);
199199
}
200+
201+
/**
202+
* @Given I select hide :hideOption for field options
203+
*/
204+
public function iSelectForFieldOptions(string $hideOption): void
205+
{
206+
$this->contentViewPage->verifyIsLoaded();
207+
$this->contentViewPage->selectHideOption($hideOption);
208+
}
209+
210+
/**
211+
* @Then I should see the alert contains :alertMessage appear
212+
*/
213+
public function iShouldSeeTheAlertContainsAppear(string $alertMessage): void
214+
{
215+
$this->contentViewPage->verifyIsLoaded();
216+
$this->contentViewPage->verifyMessageContains($alertMessage);
217+
}
218+
219+
/**
220+
* @When I run the scheduled jobs
221+
*/
222+
public function iRunTheScheduledJobs(): void
223+
{
224+
$this->contentViewPage->runScheduledJobs();
225+
}
226+
227+
/**
228+
* @When I clear the behat cache directory
229+
*/
230+
public function iClearTheBehatCacheDirectory(): void
231+
{
232+
$this->contentViewPage->clearBehatCacheDirectory();
233+
}
200234
}

src/lib/Behat/Page/ContentViewPage.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Ibexa\AdminUi\Behat\Component\UniversalDiscoveryWidget;
2525
use Ibexa\AdminUi\Behat\Component\UpperMenu;
2626
use Ibexa\Behat\Browser\Element\Condition\ElementExistsCondition;
27+
use Ibexa\Behat\Browser\Element\Criterion\ElementAttributeCriterion;
2728
use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion;
2829
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
2930
use Ibexa\Behat\Browser\Page\Page;
@@ -33,6 +34,8 @@
3334
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
3435
use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias;
3536
use PHPUnit\Framework\Assert;
37+
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
38+
use Symfony\Component\Filesystem\Filesystem;
3639

3740
class ContentViewPage extends Page
3841
{
@@ -337,6 +340,7 @@ protected function specifyLocators(): array
337340
new VisibleCSSLocator('addUrlAliasButton', '#ibexa-tab-location-view-urls [data-bs-target="#ibexa-modal--custom-url-alias"]'),
338341
new VisibleCSSLocator('customUrlAliasesTable', '#ibexa-tab-location-view-urls .ibexa-table'),
339342
new VisibleCSSLocator('alertTitle', '.ibexa-alert__title'),
343+
new VisibleCSSLocator('selectHideMode', '.form-check .ibexa-input--radio'),
340344
];
341345
}
342346

@@ -384,4 +388,35 @@ public function verifyMessage(string $expectedMessage): void
384388
{
385389
$this->getHTMLPage()->setTimeout(3)->find($this->getLocator('alertTitle'))->assert()->textEquals($expectedMessage);
386390
}
391+
392+
public function selectHideOption(string $viewMode): void
393+
{
394+
$this->getHTMLPage()
395+
->findAll($this->getLocator('selectHideMode'))
396+
->getByCriterion(new ElementAttributeCriterion('value', $viewMode))->click();
397+
}
398+
399+
public function verifyMessageContains(string $alertMessage): void
400+
{
401+
$this->getHTMLPage()->find($this->getLocator('alertTitle'))->assert()->textContains($alertMessage);
402+
}
403+
404+
public function runScheduledJobs(): void
405+
{
406+
shell_exec('bin/console ibexa:scheduled:run');
407+
}
408+
409+
public function clearBehatCacheDirectory(): void
410+
{
411+
$filesystem = new Filesystem();
412+
$cacheDir = getcwd() . \DIRECTORY_SEPARATOR . 'var' . \DIRECTORY_SEPARATOR . 'cache';
413+
414+
try {
415+
$filesystem->remove($cacheDir);
416+
$this->getHTMLPage()->setTimeout(5);
417+
$this->getSession()->reload();
418+
} catch (IOExceptionInterface $exception) {
419+
throw new \Exception('Error while clearing cache: ' . $exception->getMessage());
420+
}
421+
}
387422
}

0 commit comments

Comments
 (0)