Overview
phpBB 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/phpbb-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/phpbb-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"
},
"moderator": {
"username": "moderator",
"password": "dD.123123ddd",
"email": "moderator@example.com"
},
"member": {
"username": "member",
"password": "dD.123123ddd",
"email": "member@example.com"
},
"newmember": {
"username": "newmember",
"password": "dD.123123ddd",
"email": "newmember@example.com"
}
}
}
}
Steps
- Given I am a logged in user with the "member" user
- When I 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 "You have specified an incorrect password."
- Given I am not logged in
- When I log out
- Then I should be logged in as "member"
- Then I should be logged in
- Then I should be on the login page
- Then I should not be allowed to open "/mcp.php"
- When I ask for a password reset link for "member"
- When I set the password of "member" on the reset page
- When I open the registration form
- When I try to register with the username "member", the email "someone@example.com" and the passwords "dD.123123ddd" and "dD.123123ddd"
- Then the registration should be refused with "The username you entered is already in use, please select an alternative."
- Given I am on the board index
- Then the board index should list the forum "General discussion"
- Then the forum "Help and support" on the board index should have 27 topics
- Then the forum "Archive" on the board index should be locked
- When I open the forum "General discussion"
- When I try to open the forum at "/viewforum.php?f=9"
- Then I should be in the forum "General discussion"
- Then the forum should list the topic "Weekend baking thread"
- Then the topic "Board rules" in the forum should be an announcement
- Then the topic "Weekend baking thread" in the forum should have 12 replies
- Then the forum should have 27 topics
- When I go to page 2
- Then I should be on page 2
- When I sort the topics by "Subject" in "Ascending" order
- Then the first topic of the forum should be "A walk along the river"
- Then the breadcrumbs should be "Board index", "Community" and "General discussion"
- Then the board should say "You are not authorised to read this forum."
- Then the board statistics should show "Total members" as "5"
- When I open the topic "Weekend baking thread" in "General discussion"
- Then I should be reading the topic "Weekend baking thread"
- Then the topic should have 13 posts
- Then post 1 should be by "member"
- Then post 1 should read "What is in your oven this weekend?"
- Then the last post should quote "What is in your oven this weekend?"
- Then the last post should show the attachment "webship-test-picture.png"
- Then the topic should be locked
- Then the topic should have the poll "Which season do you like best?"
- When I vote for "Summer" in the poll
- Then the poll should show 1 vote for "Summer"
- When I bookmark the topic
- When I remove the bookmark of the topic
- Then the topic should be bookmarked
- When I start a new topic in "General discussion"
- When I start a reply to the topic
- When I quote post 1 in a reply
- When I edit the last post
- When I write the subject "Webship test topic" in the editor
- When I write "Webship test: the first post of a topic." in the editor
- Then the editor should have the subject "Re: Weekend baking thread"
- When I preview the post
- Then the preview should show "Webship test: the first post of a topic."
- When I submit the post
- Then the editor should show the error "You must specify a subject when posting a new topic."
- When I attach the file "tests/fixtures/webship-test-picture.png" in the editor
- Then the attachment should be refused with "Invalid file extension"
- Then the editor should list the attachment "webship-test-picture.png"
- When I reply to the topic with "Webship test reply."
- When I quick reply with "Webship test quick reply."
- Then I should see the quick reply
- Then I should not be able to start a topic
- When I delete the last post
- When I go to my inbox
- Then my messages should list "Welcome to the board"
- Then the message "Webship test message" should be unread
- When I open the message "Welcome to the board"
- Then the message should be from "administrator"
- When I send the message "Webship test message" to "moderator" with "Webship test: a private message."
- When I try to send the message "Webship test message" to "webship-test-nobody" with "Webship test."
- When I reply to the message with "Webship test: an answer."
- When I delete the message "Webship test message"
- Then I should have 1 unread message
- Given "member" has no message "Webship test message"
- Given "moderator" sent the message "Webship test message" to "member" with "Webship test: a word from the moderator."
- When I search for "sourdough"
- When I search the posts for "sourdough"
- Then the search should find 2 matches
- Then the search results should show "Weekend baking thread"
- Then the search results should highlight "sourdough"
- When I open the search result "Weekend baking thread"
- When I open the quick link "Your posts"
- Then the search page should be "Your posts"
- When I go to the user control panel
- When I open "Edit signature" under "Profile" in the user control panel
- Then the control panel should show the page "Edit signature"
- Then the control panel should offer the tab "Moderation queue"
- When I set the setting "Location" to "Webship test town"
- Then the setting "Location" should be "Webship test town"
- When I save the settings
- When I set my signature to "Webship test signature."
- Then my signature should be "Webship test signature."
- When I save the post as a draft
- Then my drafts should list "Webship test draft"
- When I load the draft "Webship test draft"
- When I go to the members list
- Then the members list should list "member"
- When I open the profile of "member"
- Then the profile should show "Username: member"
- When I open the notifications menu
- Then the notifications menu should list "Private Message from moderator"
- Then the board statistic "Board version" should be "3.3"
- Then the forum administration should list "Community"
- When I open "Community" in the forum administration
- Then I should see the link to the moderator control panel
- When I report post 2 as "off topic"
- Then the open reports should list "Re: Webship test topic"
- When I close the report of "Re: Webship test topic"
- Then the approval queue should list the topic "Webship test topic of a new member"
- When I approve the topic "Webship test topic of a new member"
- When I lock the topic
- When I move the topic to "Help and support"
- When I split the topic from post 2 into "Webship test topic, split"
- When I delete the topic
- Then I should see the moderator tools
- Then the moderator log should show "Locked topic"
- Then an email with the subject "Account password reset" should be sent to "member"
- Then no email should be sent to "nobody@example.com"
- Then the email with the subject "Account password reset" to "member" should contain "Hello member"
- When I open the link of the email with the subject "Account password reset" to "member"
- Given there is no topic "Webship test topic"
- Given there is a topic "Webship test topic" in "General discussion" by "member"
- Given there is a topic "Webship test topic" in "General discussion" by "member" with:
- Given "moderator" replied to the topic "Webship test topic" in "General discussion" with "Webship test reply of the moderator."
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/phpbb-steps.