Overview
Payload Steps adds step definitions to Webship-js 2.0.x for the markup the platform itself renders, regardless of theme or distribution, so scenarios read as plain sentences instead of CSS selectors. It is a plugin for Webship-js: it ships one file of step definitions you drop into an existing test project, and it composes with the built-in steps rather than duplicating them.
Install
npm install --save-dev @webship-js/payload-steps
Then add its step file to cucumber.js beside the Webship-js steps:
require: [
'node_modules/webship-js/tests/step-definitions/**/*.js',
'node_modules/@webship-js/payload-steps/tests/step-definitions/*.js',
'tests/step-definitions/**/*.js',
]
Test users
The steps that log in use accounts that already exist on the site, by the handle a feature names (Given I am a logged in user with the "admin" user). The site build creates them; a feature never creates or deletes an account. They are listed in cucumber.js under worldParameters. These are the test accounts of the pack's own test site: put the accounts of your site in your project, and keep real passwords in environment variables.
{
"worldParameters": {
"users": {
"administrator": {
"email": "administrator@example.com",
"password": "dD.123123ddd"
},
"editor": {
"email": "editor@example.com",
"password": "dD.123123ddd"
},
"demo-author": {
"email": "demo-author@example.com",
"password": "password"
}
}
}
}
Steps
- Given I am a logged in user with the "editor" user
- When I log in as "editor" with the login form
- When I log in with the email "nobody@example.com" and the password "Wrong-password-1"
- Given I am not logged in
- Then the login should be refused with "The email or password provided is incorrect."
- When I log out
- Then I should be logged in
- Then I should not be logged in
- Then I should be on the admin login page
- Then the admin should not ask for its first user
- Then the admin should refuse this account
- Then the navigation should list "Users"
- Then the dashboard should list "Posts"
- Then I should not be allowed to open "/admin/collections/redirects"
- Then I should not be able to create a document in "Users"
- When I go to my account
- Then the "Roles" field should be read only
- When I choose the file "test-lighthouse.png" to upload
- Then the file details should show "320x200"
- Given I am on the "Posts" list
- Then the list should count 17 documents
- Then the list should show "Morning light over the harbour"
- Then the list should show the documents:
- Then the list should have 10 rows
- Then the "Morning light over the harbour" row should show "morning-light-over-the-harbour" in the "Slug" column
- Then the first row of the list should be "A draft about the new library"
- Then the list should be empty
- When I search the list for "harbour"
- When I clear the search of the list
- When I sort the list by "Title"
- When I filter the list where "Status" "equals" "Draft"
- Then the list should be filtered where "Status" "equals" "Draft"
- When I remove the filters of the list
- When I show the "Status" column
- Then the list should have the column "Status"
- When I go to page 2 of the list
- Then the list should be on page 2
- When I show 25 documents per page
- When I select "Bulk test post one" in the list
- When I select all documents on the page
- Then the selection should read "2 selected"
- When I publish the selected documents
- When I edit the selected documents, setting "Categories" to "News"
- When I save the edit of the selected documents as drafts
- When I open "Morning light over the harbour" from the list
- When I create a new document from the list
- When I create a new document in "Posts"
- When I open the document "Data step post" in "Posts"
- When I open the "Header" global
- When I set "Title" to "Editor test post"
- When I set these fields:
- Then "Title" should be set to "Editor test post"
- When I open the "Meta" tab
- When I write "A paragraph typed in the editor." in the rich text editor
- Then the rich text editor should contain "A paragraph typed in the editor."
- Then the "Categories" field should hold "Design"
- When I remove "Design" from the "Categories" field
- When I unlock the slug
- Then the "Title" field should show the error "This field is required."
- When I publish the document
- When I save the document
- When I unpublish the document
- When I revert the document to its published version
- Then the status of the document should be "Draft"
- Then the document should be saved automatically
- Then I should not be able to publish the document
- Then I should see the notification "Updated successfully."
- When I delete the document
- When I duplicate the document
- When I go to "Posts" in the navigation
- Then the admin should ask to leave without saving
- When I leave without saving
- When I add the "Content" block to "Layout"
- When I add a row to "Nav Items"
- Then "Layout" should have 2 rows
- Then the rows of "Layout" should be "Content" and "Call to Action"
- When I move row 1 of "Layout" down
- When I remove row 2 of "Layout"
- When I expand row 1 of "Nav Items"
- Then row 1 of "Nav Items" should be expanded
- When I collapse all rows of "Layout"
- When I set "Label" to "News" in row 3 of "Nav Items"
- Then "Label" should be set to "News" in row 3 of "Nav Items"
- When I open the versions of the document
- Then the document should have 3 versions
- Then a version should be marked "Currently Published"
- When I open the version marked "Currently Published"
- Then the version should change "Title" from "Version test post" to "Version test post, changed"
- When I restore this version
- When I open the live preview
- Then the live preview should show "Preview test post"
- Then the preview link should open "/posts/preview-test-post"
- Then the site navigation should list "Posts", "Contact" and "Search"
- Then the page should show posts 1 to 12 of 15
- Then the page should list the post "Morning light over the harbour"
- When I go to the next page of posts
- Then the title of the post should be "Digital Horizons: A Glimpse into Tomorrow"
- When I search the site for "harbour"
- Then the search should find "Morning light over the harbour"
- When I fill in the form with:
- When I send the form
- Then the form should confirm "The contact form has been submitted successfully."
- Then the "Email" field of the form should show "This field is required"
- Then I should see the page for an address the site does not have
- Given there is a document "Data step post" in "Posts"
- Given there is a published document "Published test post" in "Posts"
- Given there is a document "Table test post" in "Posts" with:
- Given there is no document "Editor test post" in "Posts"
- Then there should be a document "Editor test post" in "Posts"
Every assertion step reads both polarities from one definition: should see and should not see are the same step. Source and issues: github.com/webship/payload-steps.