Skip to content

Commit 14a7e6a

Browse files
committed
IBX-10333 Added scenario for hide later coverage
1 parent 1cc9228 commit 14a7e6a

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
@@ -177,4 +177,38 @@ public function iShouldSeeAlertAppears(string $alertMessage): void
177177
$this->contentViewPage->verifyIsLoaded();
178178
$this->contentViewPage->verifyMessage($alertMessage);
179179
}
180+
181+
/**
182+
* @Given I select hide :hideOption for field options
183+
*/
184+
public function iSelectForFieldOptions(string $hideOption): void
185+
{
186+
$this->contentViewPage->verifyIsLoaded();
187+
$this->contentViewPage->selectHideOption($hideOption);
188+
}
189+
190+
/**
191+
* @Then I should see the alert contains :alertMessage appear
192+
*/
193+
public function iShouldSeeTheAlertContainsAppear(string $alertMessage): void
194+
{
195+
$this->contentViewPage->verifyIsLoaded();
196+
$this->contentViewPage->verifyMessageContains($alertMessage);
197+
}
198+
199+
/**
200+
* @When I run the scheduled jobs
201+
*/
202+
public function iRunTheScheduledJobs(): void
203+
{
204+
$this->contentViewPage->runScheduledJobs();
205+
}
206+
207+
/**
208+
* @When I clear the behat cache directory
209+
*/
210+
public function iClearTheBehatCacheDirectory(): void
211+
{
212+
$this->contentViewPage->clearBehatCacheDirectory();
213+
}
180214
}

src/lib/Behat/Page/ContentViewPage.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Ibexa\AdminUi\Behat\Component\UniversalDiscoveryWidget;
2323
use Ibexa\AdminUi\Behat\Component\UpperMenu;
2424
use Ibexa\Behat\Browser\Element\Condition\ElementExistsCondition;
25+
use Ibexa\Behat\Browser\Element\Criterion\ElementAttributeCriterion;
2526
use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion;
2627
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
2728
use Ibexa\Behat\Browser\Page\Page;
@@ -31,6 +32,8 @@
3132
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
3233
use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias;
3334
use PHPUnit\Framework\Assert;
35+
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
36+
use Symfony\Component\Filesystem\Filesystem;
3437

3538
class ContentViewPage extends Page
3639
{
@@ -309,6 +312,7 @@ protected function specifyLocators(): array
309312
new VisibleCSSLocator('moreTab', '.ibexa-tabs__tab--more'),
310313
new VisibleCSSLocator('popupMenuItem', '.ibexa-popup-menu__item .ibexa-popup-menu__item-content'),
311314
new VisibleCSSLocator('alertTitle', '.ibexa-alert__title'),
315+
new VisibleCSSLocator('selectHideMode', '.form-check .ibexa-input--radio'),
312316
];
313317
}
314318

@@ -356,4 +360,35 @@ public function verifyMessage(string $expectedMessage): void
356360
{
357361
$this->getHTMLPage()->setTimeout(3)->find($this->getLocator('alertTitle'))->assert()->textEquals($expectedMessage);
358362
}
363+
364+
public function selectHideOption(string $viewMode): void
365+
{
366+
$this->getHTMLPage()
367+
->findAll($this->getLocator('selectHideMode'))
368+
->getByCriterion(new ElementAttributeCriterion('value', $viewMode))->click();
369+
}
370+
371+
public function verifyMessageContains(string $alertMessage): void
372+
{
373+
$this->getHTMLPage()->find($this->getLocator('alertTitle'))->assert()->textContains($alertMessage);
374+
}
375+
376+
public function runScheduledJobs(): void
377+
{
378+
shell_exec('bin/console ibexa:scheduled:run');
379+
}
380+
381+
public function clearBehatCacheDirectory(): void
382+
{
383+
$filesystem = new Filesystem();
384+
$cacheDir = getcwd() . \DIRECTORY_SEPARATOR . 'var' . \DIRECTORY_SEPARATOR . 'cache';
385+
386+
try {
387+
$filesystem->remove($cacheDir);
388+
$this->getHTMLPage()->setTimeout(5);
389+
$this->getSession()->reload();
390+
} catch (IOExceptionInterface $exception) {
391+
throw new \Exception('Error while clearing cache: ' . $exception->getMessage());
392+
}
393+
}
359394
}

0 commit comments

Comments
 (0)