Overview
Spring Boot 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/spring-boot-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/spring-boot-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"
},
"user": {
"username": "user",
"password": "dD.123123ddd"
}
}
}
}
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 "user" and the password "Wrong-password-1"
- Given I am not logged in
- Given I am on the login page
- When I go to the login page
- Then the login should be refused with "Invalid credentials"
- Then I should be on the login page
- Then I should see the login form
- When I log out
- When I go to the logout page
- Then I should be asked to confirm the logout
- When I confirm the logout
- Then I should be logged in
- Then I should be logged in as "administrator"
- When my session expires
- Then the login should have started a new session
- Then the session cookie should be HttpOnly
- When I close the browser and open it again
- Then I should be back on the page I asked for
- Then the remember-me cookie should last 14 days
- Then I should not be allowed to open "/owners/new"
- When I press "Update Owner" with a forged token
- When a page of another site sends a form to "/owners/1/edit"
- Then every form that posts on this page should carry a CSRF token
- Then the form of the "Update Owner" button should carry a CSRF token
- Then the "Telephone" field should have the error "Telephone must be a 10-digit number"
- Then the "Last Name" field should have no error
- Then the form should show the errors:
- Then the form should show no errors
- Then I should see the success message "Owner Values Updated"
- Then I should see the 404 error page
- Then I should see the default error page
- Then the default error page should say "Not Found" with the status 404
- Then the page should not show debug information
- When a program asks for "/oups"
- Then the program should get the error "Internal Server Error" with the status 500
- Then the error answer should not carry a stack trace
- Then the health endpoint should report "UP"
- Then the health endpoint should show the component "db"
- Then the health endpoint should show no components
- Then the health component "db" should report "UP"
- Then the health group "liveness" should report "UP"
- Then the info endpoint should show "build.name" as "petclinic"
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/spring-boot-steps.