Overview
Wagtail 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/wagtail-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/wagtail-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": {
"username": "administrator",
"password": "dD.123123ddd",
"email": "administrator@example.com"
},
"editor": {
"username": "editor",
"password": "dD.123123ddd",
"email": "editor@example.com"
},
"moderator": {
"username": "moderator",
"password": "dD.123123ddd",
"email": "moderator@example.com"
},
"member": {
"username": "member",
"password": "dD.123123ddd",
"email": "member@example.com"
}
}
}
}
Steps
- Given I am a logged in user with the "editor" user
- When I log in as "editor" with the login form
- When I try to log in as "member" with the login form
- When I log in with the username "nobody" and the password "Wrong-password-1"
- Then the login should be refused with "Your username and password didn't match. Please try again."
- Given I am not logged in
- When I log out
- Then I should be logged in as "editor"
- Then I should be logged in
- Then I should be on the login page
- Then I should not be allowed to open "/admin/users/"
- When I ask for a password reset link for "editor"
- When I set the password of "editor" on the reset page
- Given I am on the dashboard
- Then the dashboard should show the panel "Awaiting your review"
- Then the panel "Awaiting your review" should list "Southern Cornbread"
- Then the site summary should count 34 pages
- When I open "Bread types" from the "Breads" menu
- When I open "Images" from the main menu
- Then the main menu should offer "Settings"
- Then the "Settings" menu should offer "Users"
- Then I should see the success message "Page 'Webship test page' has been published."
- When I search the admin for "bread"
- Then the admin search should find the page "Anadama"
- When I go to the page explorer of "Breads"
- Then the page explorer should list "About"
- Then the page explorer should count 7 pages
- When I search the page explorer for "bread"
- Then the page "About" should have the status "live"
- Then the page "Contact Us" should be shown as locked
- When I explore the child pages of "Breads"
- When I add a "Standard page" under the home page
- Then the home page should offer the page type "Standard page"
- When I edit the page "About"
- When I open the page tree
- When I open the home page in the page tree
- Then the page tree should show "Breads"
- When I set "Title" to "Webship test page"
- When I set these fields:
- Then "Title" should be set to "Webship test page"
- When I save the draft
- When I publish the page
- When I unpublish the page
- When I submit the page for moderation
- When I choose "Publish" in the editor
- Then the editor should offer "Publish"
- When I delete the page "Webship test page"
- Then the status panel should say "Draft"
- When I schedule the page to go live at "2030-01-01 09:00"
- When I lock the page
- Then the preview should show "Webship test page"
- Then the edits should be saved by themselves
- Then the "Slug" field should have the error "This field is required."
- When I add a "Heading block" block to "Page body"
- When I set "Heading text" to "Our oven" in block 1 of "Page body"
- When I move block 2 of "Page body" up
- When I remove block 1 of "Page body"
- Then "Page body" should have 2 blocks
- Then the blocks of "Page body" should be "Heading block", "Paragraph block"
- When I open the history of the page "Webship test page"
- Then the history should list "Published"
- Then the newest entry of the history should be "Draft saved"
- When I compare the live version with the current draft
- Then the comparison should show "Introduction" changed from "First" to "Second"
- When I revert the page to the live version
- When I approve the page "Webship test page"
- Then my page "Webship test page" should be "Awaiting Moderators approval"
- Then the page "Webship test page" should be awaiting my review
- When I upload the image "webship-test-loaf.png" with the title "Webship test loaf"
- When I go to the image library
- When I search the image library for "loaf"
- When I filter the image library by the collection "Other"
- Then the image library should list "Webship test loaf"
- When I edit the image "Webship test loaf"
- When I set the focal point of the image to the area from 55% 40% to 75% 65%
- Then the focal point of the image "Webship test loaf" should be centred at 65% 52%
- Then the image "Webship test loaf" should be in the collection "Other"
- When I delete the image "Webship test loaf"
- When I add the collection "Webship test collection"
- Then the collections should list "Webship test collection"
- When I delete the collection "Webship test collection"
- When I go to the "Bread types" snippets
- When I add to the "Bread types" snippets:
- Then the "Bread types" snippets should list "Webship test bread type"
- Then the "Bread types" snippets should count 17
- When I delete "Webship test bread type" from the "Bread types" snippets
- Given there is no "Webship test bread type" in the "Bread types" snippets
- When I send the form of this page with:
- Then the form of this page should not be sent for "Subject"
- When I go to the submissions of the form "Contact Us"
- Then the submissions should list "Webship test message"
- Then the submissions should have the columns "Submission date", "Subject", "Your Name", "Your Email", "Purpose", "Body"
- When I delete the submission "Webship test message"
- Then the users list should show "administrator" with the access level "Admin"
- Then the group "Editors" should be allowed to "Edit" the pages under "Root"
- Then the group "Editors" should have the permission "Can add footer text"
- When I add a temporary redirect from "/webship-test-old-bread" to the page "Breads"
- Then the redirects should list "/webship-test-old-bread" to "Breads"
- Then "/webship-test-old-bread" should redirect to "/breads/"
- When I delete the redirect "/webship-test-old-bread"
- When I open the "Locked pages" report
- Then the report should list "Contact Us"
- Then the report row "Contact Us" should show "Locked by admin" in the "Locking status" column
- When I search the site for "bread"
- Then the search results should list "Anadama"
- Then I should see the quick actions of the admin
- When I choose "Edit this page" from the quick actions
- Then an email with the subject "Password reset" should be sent to "editor"
- Then no email should be sent to "nobody@example.com"
- Then the email with the subject "has been rejected" to "editor" should contain "Please add a photo."
- When I open the link of the email with the subject "Password reset" to "editor"
- Given there is no page "Webship test page"
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/wagtail-steps.