Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

[Behat] Added checkbox fieldtype BDD tests #557

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 24 additions & 4 deletions Features/Context/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ protected function getThisFieldIdent()
{
$fieldManager = $this->getFieldTypeManager();
$identifier = $fieldManager->getThisFieldTypeIdentifier();

// check if we are editing a field for draft or published content
if ($fieldManager->getFieldContentState() == FieldType::CONTENT_PUBLISHED) {
$contentId = $fieldManager->getThisContentId();
Expand Down Expand Up @@ -140,6 +139,26 @@ public function uncheckFieldValue()
}
}

/**
* @Given a Content of this type exists with checkbox Field Value checked
*/
public function createAContentOfThisTypeWithCheckboxChecked()
{
$this->createAContentOfThisType();
$this->checkFieldValue();
$this->publishContent();
}

/**
* @Given a Content of this type exists with checkbox Field Value unchecked
*/
public function createAContentOfThisTypeWithCheckboxUnchecked()
{
$this->createAContentOfThisType();
$this->uncheckFieldValue();
$this->publishContent();
}

/**
* @When I publish the content
* @And I publish the content
Expand All @@ -148,6 +167,7 @@ public function publishContent()
{
if ($this->platformStatus == self::WAITING_FOR_PUBLISHING) {
$this->clickEditActionBar('Publish');
$this->platformStatus = self::NOT_WAITING;
} else {
throw new \Exception('Cannot publish content, application in wrong state');
}
Expand Down Expand Up @@ -204,9 +224,8 @@ public function failsWithMessage($message)
*/
public function seeFieldtOfType($type, $label = null)
{
if ($this->platformStatus == self::WAITING_FOR_PUBLISHING) {
$this->clickEditActionBar('Publish');
}
$this->publishContent();

$verification = new WebAssert($this->getSession());
// for view we need the internal field identifier...
$internalName = $this->getFieldTypeManager()->getFieldTypeInternalIdentifier($type);
Expand Down Expand Up @@ -239,6 +258,7 @@ public function seeFieldtWithValue($value)
if ($this->platformStatus == self::WAITING_FOR_PUBLISHING) {
$this->clickEditActionBar('Publish');
}

$verification = new WebAssert($this->getSession());
$verification->elementTextContains('css', '.ez-fieldview-value-content', $value);
}
Expand Down
70 changes: 70 additions & 0 deletions Features/Stories/FieldTypes/CheckBoxFieldType.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

Feature: Test the validations done on fields from Editorial Interface - Checkbox fieldtype
In order to validate the checkbox fieldtype
As an Editor user
I need to be able to create and update content with checkbox fieldtypes

Background:
Given I am logged in as an Editor in PlatformUI

##
# Validate the existence of expected fields from a field type when creating a content
##
##
@javascript @common
Scenario: A Content of a Content Type that has a checkbox fieldtype must have a Checkbox field
Given a Content Type with an "checkbox" Field exists
When I create a content of this type
Then I should see a "checkbox" field

@javascript @common
Scenario: When editing a Content the label of a checkbox field must have the same name than field type from the respective Content Type
Given a Content Type with an "checkbox" with field definition name "Do you agree?" exists
When I create a content of this type
Then I should see a "Do you agree?" label related with the "checkbox" field

@javascript @edge
Scenario: The label of a required checkbox field of a Content must be marked as required
Given a Content Type with a required "checkbox" with field definition name "Do you agree?" exists
When I create a content of this type
Then the "Do you agree?" field should be marked as required

##
# Creating Content using a Content Type that has a Checkbox Field Type
##
@javascript @common
Scenario: Publishing a valid checkbox Field works
Given a Content Type with an "checkbox" Field exists
When I create a content of this type
And I check the Field Value
And I publish the content
Then the Content is successfully published

##
# Update Content using a Content Type that has a Checkbox Field Type
##
@javascript @notWorking @edge
Scenario: Updating a Checkbox field using a valid checkbox Field works
Given a Content Type with an "checkbox" Field exists
And a Content of this type exists with checkbox Field Value checked
When I edit this content
And I uncheck the Field Value
And I publish the content
Then the Content is successfully published

##
# Viewing content that has a Checkbox fieldtype
##
@javascript @common
Scenario: Viewing a Content that has a Checkbox fieldtype should show the expected value when the checkbox is checked
Given a Content Type with an "checkbox" Field exists
Copy link
Contributor

Choose a reason for hiding this comment

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

an or a?

And a Content of this type exists with checkbox Field Value checked
When I view this Content
Then I should see a field with value "Yes"

@javascript @common
Scenario: Viewing a Content that has a Checkbox fieldtype should show the expected value when the checkbox is unchecked
Given a Content Type with an "checkbox" Field exists
And a Content of this type exists with checkbox Field Value unchecked
When I view this Content
Then I should see a field with value "No"
4 changes: 4 additions & 0 deletions behat_suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ platformui:
fieldtype_integer:
paths: [ vendor/ezsystems/platform-ui-bundle/Features/Stories/FieldTypes/IntegerFieldType.feature ]
contexts: [ EzSystems\PlatformUIBundle\Features\Context\Fields ]
# fieldtype specific tests - definition, validation, publishing, etc
fieldtype_checkbox:
paths: [ vendor/ezsystems/platform-ui-bundle/Features/Stories/FieldTypes/CheckBoxFieldType.feature ]
contexts: [ EzSystems\PlatformUIBundle\Features\Context\Fields ]
# user features
user:
paths: [ vendor/ezsystems/platform-ui-bundle/Features/Users/users.feature ]
Expand Down