Skip to content

Commit

Permalink
Merge pull request #900 from mnocon/ezee-2718-adjust-tests
Browse files Browse the repository at this point in the history
EZEE-2718: Adjust tests for redirects
  • Loading branch information
Łukasz Serwatka authored Mar 15, 2019
2 parents 610b534 + 3f2f0f3 commit 308701e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion features/ContentCreation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Scenario: Content can be moved to trash from non-root location
Scenario Outline: Content can be moved to trash from root location
Given I navigate to content "<itemName>" of type "<itemType>" in root path
When I send content to trash
Then there's no "<itemType>" "<itemName>" on Sub-items list of root
Then I should be redirected to root in default view
And going to trash there is "<itemType>" "<itemName>" on list

Examples:
Expand Down
18 changes: 18 additions & 0 deletions src/lib/Behat/BusinessContext/NavigationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use EzSystems\EzPlatformAdminUi\Behat\Helper\EzEnvironmentConstants;
use EzSystems\EzPlatformPageBuilder\Tests\Behat\PageObject\PageBuilderEditor;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Breadcrumb;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\UpperMenu;
Expand Down Expand Up @@ -121,4 +122,21 @@ public function verifyIfBreadcrumbShowsPathUnderRoot(string $path): void
$path = sprintf('%s/%s', EzEnvironmentConstants::get('ROOT_CONTENT_NAME'), $path);
$this->verifyIfBreadcrumbShowsPath($path);
}

/**
* @Then I should be redirected to root in default view
*/
public function iShouldBeRedirectedToRootInDefaultView(): void
{
if (EzEnvironmentConstants::get('ROOT_CONTENT_TYPE') === 'Landing page') {
$previewType = PageObjectFactory::getPreviewType(EzEnvironmentConstants::get('ROOT_CONTENT_TYPE'));
$pageEditor = PageObjectFactory::createPage($this->utilityContext, PageBuilderEditor::PAGE_NAME, $previewType);
$pageEditor->pagePreview->setTitle(EzEnvironmentConstants::get('ROOT_CONTENT_NAME'));
$pageEditor->waitUntilLoaded();
$pageEditor->verifyIsLoaded();
} else {
$contentItemPage = PageObjectFactory::createPage($this->utilityContext, ContentItemPage::PAGE_NAME, EzEnvironmentConstants::get('ROOT_CONTENT_NAME'));
$contentItemPage->verifyIsLoaded();
}
}
}
14 changes: 14 additions & 0 deletions src/lib/Behat/BusinessContext/TrashContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\LeftMenu;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\RightMenu;
use EzSystems\EzPlatformAdminUi\Behat\Helper\EzEnvironmentConstants;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\UpperMenu;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\TrashPage;
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentItemPage;
use PHPUnit\Framework\Assert;

class TrashContext extends BusinessContext
Expand Down Expand Up @@ -45,6 +48,17 @@ public function iEmptyTrash(): void
public function goingToTrashThereIsItemOnList(string $itemType, string $itemName): void
{
$leftMenu = ElementFactory::createElement($this->utilityContext, LeftMenu::ELEMENT_NAME);

if (!$leftMenu->isVisible()) {
// we're not in Content View
$upperMenu = ElementFactory::createElement($this->utilityContext, UpperMenu::ELEMENT_NAME);
$upperMenu->goToTab('Content');
$upperMenu->goToSubTab('Content structure');

$contentPage = PageObjectFactory::createPage($this->utilityContext, ContentItemPage::PAGE_NAME, EzEnvironmentConstants::get('ROOT_CONTENT_NAME'));
$contentPage->verifyIsLoaded();
}

$leftMenu->clickButton('Trash');

$trash = PageObjectFactory::createPage($this->utilityContext, TrashPage::PAGE_NAME);
Expand Down
7 changes: 0 additions & 7 deletions src/lib/Behat/Helper/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ class Hooks extends RawMinkContext
{
use KernelDictionary;

/** @BeforeScenario
*/
public function restartSessionBeforeScenario()
{
$this->getSession()->restart();
}

/** @BeforeScenario
*/
public function setInstallTypeBeforeScenario()
Expand Down
5 changes: 5 additions & 0 deletions src/lib/Behat/PageElement/LeftMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public function verifyVisibility(): void
{
Assert::assertTrue($this->context->findElement($this->fields['menuSelector'])->isVisible());
}

public function isVisible(): bool
{
return $this->context->isElementVisible($this->fields['menuSelector']);
}
}

0 comments on commit 308701e

Please sign in to comment.