-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* EZP-28172 Behat Covering of Content Types - squash changes to one commit * EZP-28172 Behat Covering of Content Types - fixes after review * EZP-28172 Behat Covering of Content Types - fixes after review * EZP-28172 Behat Covering of Content Types - fixes after review
- Loading branch information
Showing
34 changed files
with
874 additions
and
102 deletions.
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. | ||
|
||
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.