Overview
MediaWiki 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/mediawiki-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/mediawiki-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"
},
"reader": {
"username": "reader",
"password": "dD.123123ddd",
"email": "reader@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 log in with the user name "No such account here" and the password "Wrong-password-1"
- Then the login should be refused with "Incorrect username or password entered. Please try again."
- When I log out
- Then I should be logged in as "editor"
- Then I should be logged in
- When I try to create the account "Never created account" with the password "Unique-pass-2026-x" and the confirmation "Unique-pass-2026-y"
- Then the account creation should be refused with "The passwords you entered do not match."
- Given the page "Reading test page" has the text:
- Given the page "History test page" has the text "First version of the page." with the summary "First version"
- Given the page "Page made in the source editor" does not exist
- Given the page "Protected test page" is protected so that only autoconfirmed users can edit it
- Given the file "Test square.png" is uploaded from "tests/fixtures/blue-square.png"
- Given the account "reader" is not blocked
- When I open the page "Reading test page"
- Then I should see the page "Reading test page"
- Then the page text should contain "First version of the page."
- Then the page should have the section "Overview"
- Then the page should have these sections in order:
- Then the contents list should list "Overview"
- When I follow "Overview" in the contents list
- Then I should be at the section "Overview"
- Then the page should link to the page "Editing help"
- Then the page should link to the external site "https://example.org"
- When I follow the link to the page "Editing help"
- Then the reference "1" should read "Every page keeps its history."
- Then the page should be in the category "Test guides"
- When I follow the category "Test guides"
- Then the category should list the page "Reading test page"
- When I expand the category "Test guides" in the category tree
- Then the category tree should show "Editing guides" under "Test guides"
- When I open the talk page
- When I add the topic "A question about this page" with the text "Is this page complete?"
- Then the talk page should have the topic "A question about this page"
- Then the scripts of the page should all load
- When I type "Readi" in the search box
- Then the search suggestions should list "Reading test page"
- When I choose the suggestion "Reading test page"
- When I search for "readers"
- Then the search results should list the page "Reading test page"
- Then the search result "Reading test page" should mention "readers"
- Then the search should find 1 page
- When I edit the page "Editing test page"
- When I set the wikitext to:
- When I set the wikitext to "A page made in the source editor."
- When I add the wikitext "A line added at the end."
- When I preview the page
- Then the preview should show "A page made in the source editor."
- When I show my changes
- Then the changes should show "Second version of the page." added
- When I edit the page "Visual editor test page" in the visual editor
- When I type " Typed in the visual editor." in the visual editor
- Then the visual editor should be open
- When I save the page
- Then the edit should be saved
- When another account saves the page "Conflict test page" with the text "Changed by another account."
- Then I should see an edit conflict
- Then the edit conflict should keep my text "My own first line."
- Then editing the page "Protected test page" should be refused with "This page has been protected to prevent editing or other actions."
- When I open the history of the page "History test page"
- Then the history should list the revision "First version"
- Then the history should list 2 revisions
- When I compare the revisions "First version" and "Second version"
- When I undo the revision "Second version"
- When I watch the page
- Then I should be watching the page
- Then my watchlist should list the page "Reading test page"
- Then the recent changes should show a change to "Reading test page"
- When I open my preferences
- When I tick the preference "Mark all edits minor by default"
- When I save my preferences
- Then the preference "Mark all edits minor by default" should be ticked
- When I upload the file "tests/fixtures/blue-square.png" as "Test square.png"
- Then the upload should be held back with the warning "This file is a duplicate of the following file"
- Then I should see the file "Test square.png"
- When I protect the page "Protection test page" so that only autoconfirmed users can edit it
- Then the page "Protection test page" should be protected so that only autoconfirmed users can edit it
- When I delete the page "Deletion test page" with the reason "A test of the deletion"
- When I restore the page "Deletion test page" with the reason "Deleted by mistake"
- Then the page "Deletion test page" should not exist
- When I block the account "reader" for "1 day" with the reason "A test of the block"
- When I unblock the account "reader" with the reason "The test is over"
- Then the account "reader" should be blocked
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/mediawiki-steps.