Overview
Mautic 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/mautic-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/mautic-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"
},
"marketer": {
"username": "marketer",
"password": "dD.123123ddd",
"email": "marketer@example.com"
},
"sales": {
"username": "sales",
"password": "dD.123123ddd",
"email": "sales@example.com"
}
}
}
}
Steps
- Given I am a logged in user with the "marketer" user
- When I log in as "marketer" 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 "Invalid login. Please verify credentials."
- Given I am not logged in
- When I log out
- Then I should be logged in as "marketer"
- Then I should not be logged in
- Then I should be on the login page
- Then I should not be allowed to open "/s/campaigns"
- When I ask for a password reset link for "sales"
- When I set the password of "sales" on the reset page
- When I set the password of "sales" on the reset page with the confirmation "Something-else-1"
- When I go to "Contacts" in the main menu
- Then the main menu should offer "Campaigns"
- When I go to "Users" in the settings menu
- Then the settings menu should offer "Users"
- Then the page heading should be "Contacts"
- Then the site should say "has been created!"
- Then the site should ask "Delete this contact?"
- When I answer the confirmation with "Delete"
- Then the dialog "Quick Add" should be open
- Then no dialog should be open
- When I press "Save" in the dialog
- When I search everything for "Haddad"
- Then the search results should list "Haddad, Lina"
- When I open the list of contacts
- When I search the list for "Haddad"
- Then the list should show "Lina Haddad"
- Then the list should have 2 items
- Then the row of "marketer" should show "Marketer"
- When I open "Lina Haddad" from the list
- When I choose "Delete" in the options of "Webship test contact"
- When I sort the list by "Points" in descending order
- Then the list should start with "Omar Saleh", "Lina Haddad"
- When I set "First Name" to "Webship test"
- When I set the following fields:
- When I add "webship-test-tag" to "Tags"
- Then "First Name" should be set to "Webship test"
- Then the field "Email" should show the error "is invalid."
- When I open the "Filters" tab
- When I save the form
- When I save and close the form
- When I cancel the form
- When I open the contact "Lina Haddad"
- Then the contact "Lina Haddad" should have 25 points
- Then the contact "Lina Haddad" should have the tag "newsletter"
- Then the contact "Lina Haddad" should be in the segment "Newsletter readers"
- Then the contact "Lina Haddad" should be at the company "Example Trading"
- Then the "Contact owner" of the contact "Lina Haddad" should be "Sales Test"
- Then the history of the contact "Lina Haddad" should show "Contact created"
- When I add the note "Webship test: called about the webinar" to the contact "Lina Haddad"
- Then the notes of the contact "Lina Haddad" should list "Webship test: called about the webinar"
- When I remove the tag "webship-test-tag" from the contact "Lina Haddad"
- When I send the contact "Lina Haddad" an email with the subject "Webship test: our webinar" saying "Thank you for joining."
- Then the contact "Lina Haddad" should have the tag "webship-test-onboarded" once the scheduled tasks have run
- When I add the filter "City" is equal to "Amman"
- Then the segment "Newsletter readers" should have 2 contacts
- When I add a "Text: Short answer" field to the form with:
- When I add the submit action "Adjust contact's points" to the form with:
- Then the form should hold the field "First name"
- When I open the public form "Newsletter sign-up"
- When I send the public form
- Then the public form should say "Thank you for signing up."
- Then the public form field "Email" should show the error "This is required."
- Then the results of the form "Newsletter sign-up" should list "webship-test-signup@example.com"
- When I upload the file "webship-test-notes.txt" to the asset
- Then the asset "Product brochure" should download as "product-brochure.txt"
- Then the page should load the tracking script
- When I open the campaign builder
- When I add the segment "Newsletter readers" as the source of the campaign
- When I add the action "Modify contact's tags" to the campaign with:
- When I close the campaign builder
- Then the campaign builder should show "Newsletter readers"
- Then the report should list "Newsletter sign-up" under "Title"
- Then the dashboard should show the widget "Contacts Created"
- Then an email with the subject "password reset" should be sent to "sales"
- Then no email should be sent to "nobody@example.com"
- Then the email with the subject "password reset" to "sales" should contain "You requested a password reset"
- When I open the link of the email with the subject "password reset" to "sales"
- Given there is no contact "Webship test contact"
- Given the contact "Lina Haddad" has no note "Webship test"
- Given the contact "Lina Haddad" has no tag "webship-test-tag"
- Then there should be a segment "Newsletter readers"
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/mautic-steps.