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

[Behat] Add Textline fieldtype BDD tests #552

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
247 changes: 247 additions & 0 deletions Features/Stories/FieldTypes/TextlineFieldType.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
Feature: Test the validations done on fields from PlatformUI - text line fieldtype
In order to validate the text line fieldtype
As an Editor user
I need to be able to create and update content with text line fieldtypes

Background:
Given I am logged in as an 'Administrator' in PlatformUI

##
# Validate the existence of expected fields from a field type when creating a content
##
@javascript @common
Scenario: A Content item of an Content Type that has a Text Line Field Definition must have a Text Line Field
Given a Content Type with an "text line" 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.

Given a Content Type with a "Text Line" Field Definition exists ?
I would write our domain names with the first letter uppercased. Also, a Content Type is made of Field Definitions, not Fields

When I create a content of this type
Then I should see a "text line" field
Copy link
Member

Choose a reason for hiding this comment

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

Maybe specify "input field" (form domain).


@javascript @common
Scenario: When editing Content item, the label of a Text Line Field must be the corresponding Field Definition name
Copy link
Member

Choose a reason for hiding this comment

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

Could be merged with the one above (it's about rendering the field editing form). But if this feature is common to any fieldtype, it must go in the ContentEdit feature (ping @dpobel)

Given a Content Type with an "text line" with field definition name "Test text" exists
Copy link
Contributor

Choose a reason for hiding this comment

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

Given a Content Type with a "Text Line" Field Definition named "Test text" exists ?

Copy link
Member

Choose a reason for hiding this comment

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

We don't need to specify the label or name in the feature, it is an implementation detail (we want the field definition's "name" to be shown).

When I create a content of this type
Then I should see a "Test text" label related with the "text line" field
Copy link
Contributor

Choose a reason for hiding this comment

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

Then the "Text line" Field should be labeled with "Test text" ?


@javascript @common
Scenario: The label of a required text line field of a Content must be marked as required
Copy link
Member

Choose a reason for hiding this comment

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

Might go into content edit instead. The fact that the input is flagged as required is specific to TextLine.

Given a Content Type with a required "text line" with field definition name "Required" exists
When I create a content of this type
Then the "Required" field should be marked as required

##
# Creating Content using a Content Type that has a text line Field Type
##
@javascript @common
Scenario: A Content item with a Text Line Field can be published
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove it, or merge it with Content editing (or "publishing") feature.

Given a Content Type with an "text line" Field exists
When I create a content of this type
And I set "Test text" as the Field Value
And I publish the content
Then the Content is successfully published

@javascript @common
Scenario: Creating a text line Field with an empty value works
Copy link
Member

@bdunogier bdunogier May 17, 2016

Choose a reason for hiding this comment

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

Not sure that we need a specific scenario for empty value. But we probably want one per fieldtype that validates that publishing valid content works, and actually saves the content.

We could have a global feature, with a generic phrasing (publishing/creating content of a FieldType works), that we execute for each FieldType. It would use a Context for each FieldType, that covers the specifics of each of them.

Given a Content Type with an "text line" Field exists
When I create a content of this type
And I set an empty value as the Field Value
And I publish the content
Then the Content is successfully published

@javascript @edge
Scenario: Creating a required text line Field fails validation when using an empty value
Given a Content Type with a required "text line" Field exists
When I create a content of this type
And I set an empty value as the Field Value
And I publish the content
Then Publishing fails with validation error message "This field is required"
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually the publishing does not fail, it is prevented


@javascript @common
Copy link
Member

@bdunogier bdunogier May 17, 2016

Choose a reason for hiding this comment

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

This one, and the one below, should be phrased to cover the part specific to PlatformUI (client side validation). The details, such as the value of max or min length, must be abstracted.

Scenario: Creating a valid text line Field works when using a value within limited character scope
Given a Content Type with an "text line" Field exists with Properties:
| Validator | Value |
| minimum length validator | 2 |
| maximum length validator | 4 |
When I create a content of this Type
And I set "LOL" as the Field Value
And I publish the content
Then the Content is successfully published

@javascript @edge
Scenario: Creating an invalid text line Field fails validation when using a value smaller than minimum character limit allowed
Given a Content Type with an "text line" Field exists with Properties:
| Validator | Value |
| minimum length validator | 2 |
| maximum length validator | 4 |
When I create a content of this Type
And I set "X" as the Field Value
And I publish the content
Then Publishing fails with validation error message "The value should have at least 2 characters"

@javascript @edge @broken
Scenario: Creating an invalid content type with a text line Field fails validation when using a maximum bigger than the minimum character limit
Given I am on the "Content types" page
And I click on the "Content" link
When I click at "Create a content type" button
And I fill form with:
| Field | Value |
| Name | Test |
| Identifier | test |
And I add a field type "Text line" with:
| Field | Value |
| Name | Text |
| Identifier | text |
| Minimum length | 4 |
| Maximum length | 2 |
And I click at "OK" button
Then Publishing fails with validation error message "Form did not validate. Please review errors below."
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit bothered by Publishing, a Content Type is not really published (even if we have a draft status for content types, but that's a more internal detail, AFAIK, this is not exposed to the user). Here I would write something like:
Then the Content Type is not stored (I'm unsure whether the error message should be tested)


@javascript @edge @broken
Scenario: Creating a valid content type with a text line Field works when using a minimum equal to the maximum character limit
Given I am on the "Content types" page
And I click in the "Content" Content type group
When I click at "Create a content type" button
And I fill form with:
| Field | Value |
| Name | Test |
| Identifier | test |
And I add a field type "Text line" with:
| Field | Value |
| Name | Text |
| Identifier | text |
| Minimum length | 4 |
| Maximum length | 4 |
And I click at "OK" button
Then the Content is successfully published with the message "The Content type draft was successfully updated and published. Related Content has also been updated."
Copy link
Contributor

Choose a reason for hiding this comment

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

This scenario publishes a Content Type, not a Content. Also, in this case, I think you should not test the message.


@javascript @edge @broken
Scenario: Creating an invalid content type with a text line Field fails when using a negative minimum character limit
Given I am on the "Content types" page
And I click in the "Content" Content type group
When I click at "Create a content type" button
And I fill form with:
| Field | Value |
| Name | Test |
| Identifier | test |
And I add a field type "Text line" with:
| Field | Value |
| Name | Text |
| Identifier | text |
| Minimum length | -1 |
| Maximum length | 4 |
And I click at "OK" button
Then Publishing fails with validation error message "Form did not validate. Please review errors below."

@javascript @edge @broken
Scenario: Creating an invalid content type with a text line Field fails when using a maximum character limit equal to zero
Given I am on the "Content types" page
And I click in the "Content" Content type group
When I click at "Create a content type" button
And I fill form with:
| Field | Value |
| Name | Test |
| Identifier | test |
And I add a field type "Text line" with:
| Field | Value |
| Name | Text |
| Identifier | text |
| Minimum length | 0 |
| Maximum length | 0 |
And I click at "OK" button
Then Publishing fails with validation error message "Form did not validate. Please review errors below."

@javascript @edge @broken
Scenario: Creating an invalid content type with a text line Field fails when using a negative maximum character limit
Copy link
Member

Choose a reason for hiding this comment

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

Overall, I'd separate ContentType from Content (edit or form rendering or whatever). Not sure yet if this would then belong in RepositoryForms or in PlatformUI.

Given I am on the "Content types" page
And I click in the "Content" Content type group
When I click at "Create a content type" button
And I fill form with:
| Field | Value |
| Name | Test |
| Identifier | test |
And I add a field type "Text line" with:
| Field | Value |
| Name | Text |
| Identifier | text |
| Minimum length | 0 |
| Maximum length | -1 |
And I click at "OK" button
Then Publishing fails with validation error message "Form did not validate. Please review errors below."

##
# Update Content using a Content Type that has a text line Field Type
##
@javascript @common
Scenario: Updating a text line field using a text line Field works
Copy link
Member

Choose a reason for hiding this comment

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

That's a bit similar to the above suggestion, where we would verify that content can be entered for all of the FieldTypes (common feature + dedicated contexts). We can do the same for ContentType.

Given a Content Type with an "text line" Field exists
And a Content of this type exists
When I edit this content
And I set "Test text update" as the Field Value
And I publish the content
Then the Content is successfully published

@javascript @edge
Scenario: Updating a text line Field with an empty value works
Given a Content Type with an "text line" Field exists
And a Content of this type exists
When I edit this content
And I set an empty value as the Field Value
And I publish the content
Then the Content is successfully published

@javascript @common
Scenario: Updating a valid text line Field works when using a value within limited character scope
Given a Content Type with an "text line" Field exists with Properties:
| Validator | Value |
| minimum length validator | 2 |
| maximum length validator | 4 |
When I edit this content
Copy link
Contributor

Choose a reason for hiding this comment

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

which Content (item) ?

And I set "LOL" as the Field Value
And I publish the content
Then the Content is successfully published

@javascript @edge
Scenario: Updating a text line Field fails validation when using a value smaller than minimum character limit allowed
Given a Content Type with an "text line" Field exists with Properties:
| Validator | Value |
| minimum length validator | 2 |
| maximum length validator | 4 |
When I edit this content
And I set "X" as the Field Value
And I publish the content
Then Publishing fails with validation error message "The value should have at least 2 characters"

@javascript @edge @broken
Scenario: Updating a text line Field fails validation when using a value bigger than maximum character limit allowed
Given a Content Type with an "text line" Field exists with Properties:
| Validator | Value |
| minimum length validator | 2 |
| maximum length validator | 4 |
When I edit this content
And I set "Hipopotomonstrosesquipedaliofobia" as the Field Value
And I publish the content
Then Publishing fails with validation error message "The value should have at most 4 characters"

@javascript @common
Scenario: Updating a required text line Field fails validation when using an empty value
Given a Content Type with a required "text line" Field exists
And a Content of this type exists
When I edit this content
And I set an empty value as the Field Value
And I publish the content
Then Publishing fails with validation error message "This field is required"

##
# Viewing content that has a text line fieldtype
##
@javascript @common
Scenario: Viewing a Content that has a text line fieldtype should show the expected value when the value is plausible
Given a Content Type with an "text line" Field exists
And a Content of this type exists with "text line" Field Value set to "Test text"
When I view this Content
Then I should see a field with value "Test text"

@javascript @common
Scenario: Viewing a Content that has a text line fieldtype should return "This field is empty" when the value is empty
Given a Content Type with an "text line" Field exists
And a Content of this type exists with "text line" Field Value set to empty
Copy link
Contributor

Choose a reason for hiding this comment

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

nope, in this scenario, the Field should be empty.

When I view this Content
Then I should see a field with value "This field is empty"
3 changes: 3 additions & 0 deletions behat_suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ platformui:
fieldtype_integer:
paths: [ vendor/ezsystems/platform-ui-bundle/Features/Stories/FieldTypes/IntegerFieldType.feature ]
contexts: [ EzSystems\PlatformUIBundle\Features\Context\Fields ]
fieldtype_textline:
paths: [ vendor/ezsystems/platform-ui-bundle/Features/Stories/FieldTypes/TextlineFieldType.feature ]
contexts: [ EzSystems\PlatformUIBundle\Features\Context\Fields ]
# user features
user:
paths: [ vendor/ezsystems/platform-ui-bundle/Features/Users/users.feature ]
Expand Down
2 changes: 1 addition & 1 deletion bin/travis/runbehat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

cd $HOME/build/ezplatform

php bin/behat -vv --profile=platformui --tags='~@edge'
php bin/behat -vv --profile=platformui --tags='~@edge && ~@broken'