Overview
Symfony 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/symfony-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/symfony-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": "jane_admin",
"password": "kitten",
"name": "Jane Doe",
"email": "jane_admin@example.com"
},
"user": {
"username": "john_user",
"password": "kitten",
"name": "John Doe",
"email": "john_user@example.com"
}
}
}
}
Steps
- Given I am a logged in user with the "administrator" user
- When I log in as "administrator" with the login form
- When I log in with the username "jane_admin" and the password "wrong-password"
- When I log out
- Then I should be logged in
- Then I should be logged in as "administrator"
- Then I should see the login form
- When I open "Account" from the user menu
- Then the user menu should offer "Account"
- Then the user menu should name "administrator"
- Then the navigation should have the item "Search"
- Then the navigation should show "Homepage" as the current page
- When I choose the language "Español"
- Then the language chooser should offer "Deutsch"
- Then the current language should be "English"
- Then the page should be written from right to left
- Then the page should list 10 posts
- Then I should see the post "Pellentesque vitae velit ex"
- When I open the post "Pellentesque vitae velit ex"
- Then the post "Lorem ipsum dolor sit amet consectetur adipiscing elit" should be written by "Jane Doe"
- Then the post "A post of the webship-js suite" should have the tag "lorem"
- When I filter the posts by the tag "lorem"
- Then every post should have the tag "lorem"
- When I go to page 2 of the list
- When I go to the next page of the list
- Then the list should be on page 2
- Then the list should have 3 pages
- Then the list should have no previous page
- When I publish the comment "A comment of the webship-js suite."
- Then the post should have 5 comments
- Then I should see the comment "A comment of the webship-js suite." by "user"
- When I type "vulputate" in the "Search for..." field
- Then I should see the 404 error page
- Then the page should not show debug information
- When a page of another site sends a form to "/en/login"
- Then I should see the debug toolbar
- Then the debug toolbar should show the status code 200
- Then the debug toolbar should show the route "blog_index"
- Then the debug toolbar should show the account "administrator"
- Then the debug toolbar should show 0 logged errors
- Then the debug toolbar should show at most 10 database queries
- When I open the profiler of the page
- Then the profiler should show the "GET" request to "/en/blog/"
- When I open the "Logs" panel of the profiler
- When I fill in "Password" with the password of "user"
- Then the "Fullname" field should hold the name of "administrator"
- Then the "Content" field should have the error "Post content is too short (10 characters minimum)"
- Then the "Title" field should have no error
- Then the "Title" field should block submission as required
- Then the form should have the error "The CSRF token is invalid. Please try to resubmit the form."
- When I press "Save changes" with a forged token
- Then I should see the success message "Post created successfully!"
- When I close the message "Post created successfully!"
- When I show the value of the "Password" field
- Then the "Password" field should show its value
- When I add the tag "lorem" to the "Tags" field
- When I remove the tag "lorem" from the "Tags" field
- Then the "Tags" field should have the tags "lorem"
- When I set the "Published at" date to "2030-01-01 10:00"
- Then an email with the subject "Your post received a comment!" should be sent to "administrator"
- Then no email should be sent to "user"
- Then the email with the subject "Your post received a comment!" to "administrator" should contain "has received a new comment"
- When I open the "this link" link of the email to "administrator"
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/symfony-steps.