Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-30884: Implement scenarios for Subtree editor #1068

Merged
merged 1 commit into from
Sep 24, 2019
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
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ matrix:
env:
- COMPOSE_FILE="doc/docker/base-dev.yml:doc/docker/selenium.yml"
- BEHAT_OPTS="--profile=adminui --suite=adminui"
- name: "Admin UI tests using different personas"
env:
- COMPOSE_FILE="doc/docker/base-dev.yml:doc/docker/selenium.yml"
- SETUP_BEHAT_OPTS="--profile=setup --suite=personas"
- BEHAT_OPTS="--profile=adminui --suite=personas"

notifications:
slack:
Expand All @@ -52,6 +57,9 @@ install:
# Prepare whole environment if needed
- if [ "${BEHAT_OPTS}" != "" ]; then ./.travis/prepare_ezplatform.sh ${INSTALL_EZ_INSTALL_TYPE}; fi

before_script:
- if [ "${SETUP_BEHAT_OPTS}" != "" ] ; then cd "$HOME/build/ezplatform"; docker-compose exec --user www-data app sh -c "bin/ezbehat $SETUP_BEHAT_OPTS" ; fi

script:
- if [ "${CHECK_CS}" == "1" ] ; then ./vendor/bin/php-cs-fixer fix -v --dry-run --show-progress=estimating ; fi
- if [ "${PHPUNIT_CONFIG}" != '' ]; then ./vendor/bin/phpunit -c "${PHPUNIT_CONFIG}"; fi
Expand Down
17 changes: 17 additions & 0 deletions behat_suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,20 @@ adminui:
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\TrashContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\UDWContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\DashboardContext

personas:
paths:
- '%paths.base%/vendor/ezsystems/ezplatform-admin-ui/features/personas'
contexts:
- EzSystems\EzPlatformAdminUi\Behat\Helper\UtilityContext
- EzSystems\EzPlatformAdminUi\Behat\Helper\Hooks
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\AuthenticationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NavigationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\ContentViewContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\ContentUpdateContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\ContentPreviewContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\RightMenuContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\LeftMenuContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\NotificationContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\TrashContext
- EzSystems\EzPlatformAdminUi\Behat\BusinessContext\UDWContext
69 changes: 69 additions & 0 deletions features/personas/SubtreeEditor.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@javascript @subtreeEditor
Feature: Verify that an Editor with Subtree limitations can perform all his tasks

Background:
Given I open Login page
And I login as "SubtreeEditor" with password "Passw0rd-42"
And I go to "Content structure" in "Content" tab

Scenario Outline: I can create and publish Content in locations I'm allowed
Given I navigate to content "<parentContentItemName>" of type "DedicatedFolder" in "<contentPath>"
And I start creating a new content "DedicatedFolder"
And I set content fields
| label | value |
| Name | <contentName> |
| Short name | <contentName> |
When I click on the edit action bar button "Publish"
Then success notification that "Content published." appears
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Is the dot here on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

And I should be on content container page "<contentName>" of type "DedicatedFolder" in "<newContentPath>"

Examples:
| parentContentItemName | contentPath | contentName | newContentPath |
| FolderParent | root/FolderGrandParent | NewContent1 | root/FolderGrandParent/FolderParent |
| FolderChild1 | root/FolderGrandParent/FolderParent | NewContent2 | root/FolderGrandParent/FolderParent/FolderChild1 |

Scenario Outline: I can edit Content in locations I'm allowed
Given I open UDW and go to "<contentPath>"
When I click on the edit action bar button "Edit"
And I set content fields
| label | value |
| Name | <newFieldValue> |
| Short name | <newFieldValue> |
And I click on the edit action bar button "Publish"
Then success notification that "Content published." appears
And I should be on content container page "<newFieldValue>" of type "DedicatedFolder" in "<parentContentPath>"
And content attributes equal
| label | value |
| Name | <newFieldValue> |

Examples:
| contentPath | newFieldValue | parentContentPath |
| root/FolderGrandParent/FolderParent/FolderChild1/NewContent2 | NewContent2Edited | root/FolderGrandParent/FolderParent/FolderChild1 |
| root/FolderGrandParent/FolderParent/NewContent1 | NewContent1Edited | root/FolderGrandParent/FolderParent |

Scenario: I can move Content to Trash in locations I'm allowed
Given I navigate to content "NewContent1Edited" of type "DedicatedFolder" in "root/FolderGrandParent/FolderParent"
When I send content to trash
Then I should be on content container page "FolderParent" of type "DedicatedFolder" in "root/FolderGrandParent"
And there's no "NewContent1Edited" "DedicatedFolder" on "FolderParent" Sub-items list

Scenario: I can move Content in locations I'm allowed
Given I navigate to content "ContentToMove" of type "DedicatedFolder" in "root/FolderGrandParent/FolderParent/FolderChild1"
When I click on the edit action bar button "Move"
And I select content "root/FolderGrandParent/FolderParent" through UDW
And I confirm the selection in UDW
Then success notification that "'ContentToMove' moved to 'FolderParent'" appears
And I should be on content container page "ContentToMove" of type "DedicatedFolder" in "root/FolderGrandParent/FolderParent"

Scenario Outline: I cannot edit, create or send to trash Content outside my permissions
When I open UDW and go to "<contentPath>"
Then the buttons are disabled
| buttonName |
| Create |
| Edit |
And the "Send to Trash" button is not visible

Examples:
| contentPath |
| root |
| root/FolderGrandParent |
14 changes: 13 additions & 1 deletion src/lib/Behat/BusinessContext/ContentViewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use Behat\Gherkin\Node\TableNode;
use EzSystems\BehatBundle\Helper\ArgumentParser;
use EzSystems\EzPlatformAdminUi\Behat\Helper\EzEnvironmentConstants;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Breadcrumb;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Dialog;
Expand All @@ -22,6 +23,16 @@

class ContentViewContext extends BusinessContext
{
private $argumentParser;

/**
* @injectService $argumentParser @EzSystems\BehatBundle\Helper\ArgumentParser
*/
public function __construct(ArgumentParser $argumentParser)
{
$this->argumentParser = $argumentParser;
}

/**
* @Given I start creating a new content :contentType
*/
Expand Down Expand Up @@ -60,7 +71,7 @@ public function iOpenUDWAndGoTo(string $itemPath): void

$udw = ElementFactory::createElement($this->utilityContext, UniversalDiscoveryWidget::ELEMENT_NAME);
$udw->verifyVisibility();
$udw->selectContent($itemPath);
$udw->selectContent($this->argumentParser->replaceRootKeyword($itemPath));
$udw->confirm();
}

Expand Down Expand Up @@ -124,6 +135,7 @@ public function verifyThereIsNoItemInSubItemListInRoot(string $itemName, string
public function verifyImOnContentItemPage(string $contentName, string $contentType, ?string $path = null)
{
$path = !$path ? $contentName : $path . '/' . $contentName;
$path = $this->argumentParser->replaceRootKeyword($path);
$spacedPath = str_replace('/', ' ', $path);

$contentPage = PageObjectFactory::createPage($this->utilityContext, ContentItemPage::PAGE_NAME, $contentName);
Expand Down
12 changes: 12 additions & 0 deletions src/lib/Behat/BusinessContext/NavigationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use EzSystems\BehatBundle\Helper\ArgumentParser;
use EzSystems\EzPlatformAdminUi\Behat\Helper\EzEnvironmentConstants;
use EzSystems\EzPlatformPageBuilder\Tests\Behat\PageObject\PageBuilderEditor;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Breadcrumb;
Expand All @@ -18,6 +19,16 @@
/** Context for general navigation actions */
class NavigationContext extends BusinessContext
{
private $argumentParser;

/**
* @injectService $argumentParser @EzSystems\BehatBundle\Helper\ArgumentParser
*/
public function __construct(ArgumentParser $argumentParser)
{
$this->argumentParser = $argumentParser;
}

/**
* @Given I open :pageName page
*/
Expand Down Expand Up @@ -87,6 +98,7 @@ public function iNavigateToContent(string $contentName, string $contentType, str
{
$contentPage = PageObjectFactory::createPage($this->utilityContext, ContentItemPage::PAGE_NAME, $contentName);
if ($path !== null) {
$path = $this->argumentParser->replaceRootKeyword($path);
$contentPage->navigateToPath($path);
}
$contentPage->goToSubItem($contentName, $contentType);
Expand Down
22 changes: 22 additions & 0 deletions src/lib/Behat/BusinessContext/RightMenuContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
*/
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use Behat\Gherkin\Node\TableNode;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\RightMenu;
use PHPUnit\Framework\Assert;

/** Context for actions on right menu */
class RightMenuContext extends BusinessContext
Expand All @@ -20,4 +22,24 @@ public function clickEditActionBar(string $button): void
$rightMenu = new RightMenu($this->utilityContext);
$rightMenu->clickButton($button);
}

/**
* @Given the buttons are disabled
*/
public function theButtonsAreDisabled(TableNode $buttons): void
{
$rightMenu = new RightMenu($this->utilityContext);
foreach ($buttons->getHash() as $button) {
Assert::assertFalse($rightMenu->isButtonActive($button['buttonName']));
}
}

/**
* @Given the :buttonName button is not visible
*/
public function buttonIsNotVisible(string $buttonName): void
{
$rightMenu = new RightMenu($this->utilityContext);
Assert::assertFalse($rightMenu->isButtonVisible($buttonName));
}
}
12 changes: 12 additions & 0 deletions src/lib/Behat/BusinessContext/UDWContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@
*/
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext;

use EzSystems\BehatBundle\Helper\ArgumentParser;
use EzSystems\EzPlatformAdminUi\Behat\Helper\EzEnvironmentConstants;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory;
use EzSystems\EzPlatformAdminUi\Behat\PageElement\UniversalDiscoveryWidget;

class UDWContext extends BusinessContext
{
private $argumentParser;

/**
* @injectService $argumentParser @EzSystems\BehatBundle\Helper\ArgumentParser
*/
public function __construct(ArgumentParser $argumentParser)
{
$this->argumentParser = $argumentParser;
}

/**
* @When I select content :pathToContent through UDW
*/
public function iSelectContent(string $pathToContent): void
{
$udw = ElementFactory::createElement($this->utilityContext, UniversalDiscoveryWidget::ELEMENT_NAME);
$udw->verifyVisibility();
$pathToContent = $this->argumentParser->replaceRootKeyword($pathToContent);
$udw->selectContent($pathToContent);
}

Expand Down
10 changes: 10 additions & 0 deletions src/lib/Behat/PageElement/RightMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ public function clickButton(string $buttonName): void
$this->context->getElementByText($buttonName, $this->fields['menuButton'])->click();
}

public function isButtonActive(string $buttonName): bool
{
return !$this->context->getElementByText($buttonName, $this->fields['menuButton'])->hasAttribute('disabled');
}

public function isButtonVisible(string $buttonName): bool
{
return $this->context->getElementByText($buttonName, $this->fields['menuButton']) !== null;
}

public function verifyVisibility(): void
{
$this->context->waitUntilElementIsVisible($this->fields['menuButton']);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/Behat/PageElement/UpperMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public function goToDashboard(): void
*/
public function goToSubTab(string $tabName): void
{
$this->context->waitUntil(5, function () use ($tabName) {
return $this->context->getElementByText($tabName, $this->fields['submenuButton']) !== null;
});

$this->context->getElementByText($tabName, $this->fields['submenuButton'])->click();
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Behat/PageObject/ContentItemPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function goToSubItem(string $contentName, string $contentType): void
public function navigateToPath(string $path): void
{
$pathArray = explode('/', $path);
$menuTab = ($pathArray[0] === EzEnvironmentConstants::get('ROOT_CONTENT_NAME')) ? 'Content structure' : $pathArray[0];
$menuTab = $pathArray[0] === EzEnvironmentConstants::get('ROOT_CONTENT_NAME') ? 'Content structure' : $pathArray[0];

$upperMenu = ElementFactory::createElement($this->context, UpperMenu::ELEMENT_NAME);
$upperMenu->goToTab('Content');
Expand Down