-
Notifications
You must be signed in to change notification settings - Fork 57
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-28172 Behat Covering of Content Types #312
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6146016
EZP-28172 Behat Covering of Content Types - squash changes to one commit
m-tyrala 79c5a92
EZP-28172 Behat Covering of Content Types - fixes after review
m-tyrala e845397
EZP-28172 Behat Covering of Content Types - fixes after review
m-tyrala 9613378
EZP-28172 Behat Covering of Content Types - fixes after review
m-tyrala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Feature: Content types management | ||
As an administrator | ||
In order to customize my eZ installation | ||
I want to manage my Content types structure. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First two steps of every scenario can be extracted to a Background section:
|
||
Background: | ||
Given I am logged as "admin" | ||
And I go to "Content Types" in "Admin" tab | ||
|
||
@javascript @common | ||
Scenario: Changes can be discarded while creating new Content Type Group | ||
When I start creating new "Content Type Group" | ||
And I set "Name" to "Test CTG" | ||
And I click on the edit action bar button "Discard changes" | ||
Then I should be on "Content Type Groups" page | ||
And I should see "Content Type Groups" list | ||
And there's no "Test CTG" on "Content Type Groups" list | ||
|
||
@javascript @common | ||
Scenario: New Content Type Group can be added | ||
When I start creating new "Content Type Group" | ||
And I set "Name" to "Test CTG" | ||
And I click on the edit action bar button "Create" | ||
Then I should be on "Content Type Group" "Test CTG" page | ||
|
||
@javascript @common | ||
Scenario: I can navigate to Admin / Content Types through breadcrumb | ||
Given I go to "Test CTG" "Content Type Group" page | ||
When I click on "Content Types" on breadcrumb | ||
Then I should be on "Content Type Groups" page | ||
And I should see "Content Type Groups" list | ||
|
||
@javascript @common | ||
Scenario: Changes can be discarded while editing Content Type Group | ||
Given there's "Test CTG" on "Content Type Groups" list | ||
When I start editing "Content Type Group" "Test CTG" | ||
And I set "Name" to "Test CTG edited" | ||
And I click on the edit action bar button "Discard changes" | ||
Then I should be on "Content Type Groups" page | ||
And I should see "Content Type Groups" list | ||
And there's "Test CTG" on "Content Type Groups" list | ||
And there's no "Test CTG edited" on "Content Type Groups" list | ||
|
||
@javascript @common | ||
Scenario: Content Type Group can be edited | ||
Given there's "Test CTG" on "Content Type Groups" list | ||
When I start editing "Content Type Group" "Test CTG" | ||
And I set "Name" to "Test CTG edited" | ||
And I click on the edit action bar button "Save" | ||
Then I should be on "Content Type Group" "Test CTG edited" page | ||
And notification that "Content type group" "Test CTG" is updated appears | ||
|
||
@javascript @common | ||
Scenario: Content type group can be deleted | ||
Given there's empty "Test CTG edited" on "Content Type Groups" list | ||
When I delete "Content Type Group" "Test CTG edited" | ||
Then there's no "Test CTG edited" on "Content Type Groups" list | ||
And notification that "Content type group" "Test CTG edited" is deleted appears | ||
|
||
@javascript @common | ||
Scenario: Non-empty Content type group cannot be deleted | ||
Given there's non-empty "Content" on "Content Type Groups" list | ||
Then "Content Type Group" "Content" cannot be selected |
175 changes: 175 additions & 0 deletions
175
src/lib/Behat/BusinessContext/AdministrationContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext; | ||
|
||
use Behat\Mink\Exception\ElementNotFoundException; | ||
use EzSystems\EzPlatformAdminUi\Behat\PageElement\Dialog; | ||
use EzSystems\EzPlatformAdminUi\Behat\PageElement\ElementFactory; | ||
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentTypeGroupsPage; | ||
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; | ||
|
||
/** Context for common actions (creating, editing, deleting, etc) in Admin pages (Content Types, Languages, etc.) */ | ||
class AdministrationContext extends BusinessContext | ||
{ | ||
private $itemCreateMapping = [ | ||
'Content Type Group' => ContentTypeGroupsPage::PAGE_NAME, | ||
'Content Type' => '', | ||
'Language' => '', | ||
'Role' => '', | ||
'Section' => '', | ||
'User' => '', | ||
]; | ||
private $emptyHeaderMapping = [ | ||
'Content Type Groups' => 'Content Types count', | ||
'Sections' => 'Assigned Content items', | ||
]; | ||
|
||
/** | ||
* @Then I should see :pageName list | ||
* @Then I should see :pageName :parameter list | ||
* | ||
* @param string $pageName | ||
*/ | ||
public function iSeeList(string $pageName, string $parameter = null): void | ||
{ | ||
$contentTypeGroupsPage = PageObjectFactory::createPage($this->utilityContext, $pageName, $parameter); | ||
$contentTypeGroupsPage->verifyElements(); | ||
} | ||
|
||
/** | ||
* @When I start creating new :newItemType | ||
* | ||
* @param string $newItemType | ||
*/ | ||
public function iStartCreatingNew(string $newItemType): void | ||
{ | ||
if (!array_key_exists($newItemType, $this->itemCreateMapping)) { | ||
throw new \InvalidArgumentException(sprintf('Unrecognized item type name: %s', $newItemType)); | ||
} | ||
PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$newItemType]) | ||
->adminList->clickPlusButton(); | ||
} | ||
|
||
/** | ||
* @Then there's :listElementName on :page list | ||
* @Then there's :listElementName on :parameter :page list | ||
*/ | ||
public function isElementOnTheList(string $listElementName, string $page): void | ||
{ | ||
$isElementOnTheList = PageObjectFactory::createPage($this->utilityContext, $page) | ||
->adminList->isElementOnList($listElementName); | ||
|
||
if (!$isElementOnTheList) { | ||
throw new ElementNotFoundException( | ||
$this->utilityContext->getSession(), | ||
sprintf('Element "%s" is not on the %s list.', $listElementName, $page) | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* @Then there's no :listElementName on :page list | ||
* @Then there's no :listElementName on :parameter :page list | ||
*/ | ||
public function isElementNotOnTheList(string $listElementName, string $page, string $parameter = null): void | ||
{ | ||
$isElementOnTheList = PageObjectFactory::createPage($this->utilityContext, $page, $parameter) | ||
->adminList->isElementOnList($listElementName); | ||
|
||
if ($isElementOnTheList) { | ||
throw new ElementNotFoundException( | ||
$this->utilityContext->getSession(), | ||
sprintf('Element "%s" is on the %s list.', $listElementName, $page) | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Check if item is or is not empty, according to $empty param. | ||
* | ||
* @param string $itemName | ||
* @param string $page | ||
* @param string $shouldBeEmpty | ||
*/ | ||
private function verifyContentsStatus(string $itemName, string $page, string $shouldBeEmpty): void | ||
{ | ||
$emptyContainerCellValue = '0'; | ||
|
||
$contentsCount = PageObjectFactory::createPage($this->utilityContext, $page) | ||
->adminList->getListItemAttribute($itemName, $this->emptyHeaderMapping[$page]); | ||
|
||
$msg = ''; | ||
if ($shouldBeEmpty) { | ||
$msg = ' non'; | ||
} | ||
|
||
if (($contentsCount !== $emptyContainerCellValue) === $shouldBeEmpty) { | ||
throw new ElementNotFoundException( | ||
$this->utilityContext->getSession(), | ||
sprintf('No%s empty %s on the %s list.', $msg, $itemName, $page)); | ||
} | ||
} | ||
|
||
/** | ||
* @Given there's empty :itemName on :page list | ||
*/ | ||
public function isEmptyElementOnTheList(string $itemName, string $page): void | ||
{ | ||
$this->verifyContentsStatus($itemName, $page, true); | ||
} | ||
|
||
/** | ||
* @Given there's non-empty :itemName on :page list | ||
*/ | ||
public function isNonEmptyElementOnTheList(string $itemName, string $page): void | ||
{ | ||
$this->verifyContentsStatus($itemName, $page, false); | ||
} | ||
|
||
/** | ||
* @Then :itemType :itemName cannot be selected | ||
*/ | ||
public function itemCannotBeSelected(string $itemType, string $itemName): void | ||
{ | ||
$isListElementSelectable = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) | ||
->adminList->isListElementSelectable($itemName); | ||
|
||
if ($isListElementSelectable) { | ||
throw new \Exception(sprintf('Element %s shoudn\'t be selectable.', $itemName)); | ||
} | ||
} | ||
|
||
/** | ||
* @Given I go to :itemName :itemType page | ||
*/ | ||
public function iGoToListItem(string $itemName, string $itemType): void | ||
{ | ||
PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) | ||
->adminList->clickListElement($itemName); | ||
} | ||
|
||
/** | ||
* @When I start editing :itemType :itemName | ||
*/ | ||
public function iStartEditingItem(string $itemType, string $itemName): void | ||
{ | ||
PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]) | ||
->adminList->clickEditButton($itemName); | ||
} | ||
|
||
/** | ||
* @When I delete :itemType :itemName | ||
*/ | ||
public function iDeleteItem(string $itemType, string $itemName): void | ||
{ | ||
$contentTypeGroups = PageObjectFactory::createPage($this->utilityContext, $this->itemCreateMapping[$itemType]); | ||
$contentTypeGroups->adminList->selectListElement($itemName); | ||
$contentTypeGroups->adminList->clickTrashButton(); | ||
ElementFactory::createElement($this->utilityContext, Dialog::ELEMENT_NAME) | ||
->confirm(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
namespace EzSystems\EzPlatformAdminUi\Behat\BusinessContext; | ||
|
||
use EzSystems\EzPlatformAdminUi\Behat\PageObject\ContentStructurePage; | ||
use EzSystems\EzPlatformAdminUi\Behat\PageObject\PageObjectFactory; | ||
use PHPUnit\Framework\Assert; | ||
|
||
class ContentViewContext extends BusinessContext | ||
{ | ||
/** | ||
* @Given I start creating a new Landing Page :name | ||
*/ | ||
public function startCreatingNewLandingPage(string $name): void | ||
{ | ||
$contentStructurePage = PageObjectFactory::createPage($this->utilityContext, ContentStructurePage::PAGE_NAME); | ||
$contentStructurePage->createLandingPage($name, 'Test Desc'); | ||
} | ||
|
||
/** | ||
* @Then I (should) see :title title/topic | ||
*/ | ||
public function iSeeTitle(string $title): void | ||
{ | ||
$contentStructurePage = PageObjectFactory::createPage($this->utilityContext, ContentStructurePage::PAGE_NAME); | ||
Assert::assertEquals($title, $contentStructurePage->getPageHeaderTitle()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 😄 We should close https://jira.ez.no/browse/EZP-28693 after it's merged, for clarity