@webship-js/mediawiki-steps 0.0.0-stage → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +550 -2
- package/package.json +63 -4
- package/tests/features/README.md +26 -0
- package/tests/features/accessibility.feature +16 -0
- package/tests/features/account-creation.feature +28 -0
- package/tests/features/administration.feature +49 -0
- package/tests/features/categories.feature +28 -0
- package/tests/features/edit-conflict.feature +15 -0
- package/tests/features/history.feature +30 -0
- package/tests/features/preferences.feature +15 -0
- package/tests/features/reading.feature +84 -0
- package/tests/features/search.feature +34 -0
- package/tests/features/session.feature +43 -0
- package/tests/features/source-editor.feature +42 -0
- package/tests/features/talk-page.feature +19 -0
- package/tests/features/upload.feature +20 -0
- package/tests/features/visual-editor.feature +18 -0
- package/tests/features/watchlist.feature +24 -0
- package/tests/fixtures/blue-square.png +0 -0
- package/tests/step-definitions/README.md +41 -0
- package/tests/step-definitions/mediawiki-admin.steps.js +241 -0
- package/tests/step-definitions/mediawiki-editing.steps.js +413 -0
- package/tests/step-definitions/mediawiki-files.steps.js +93 -0
- package/tests/step-definitions/mediawiki-helpers.js +768 -0
- package/tests/step-definitions/mediawiki-history.steps.js +135 -0
- package/tests/step-definitions/mediawiki-pages.steps.js +710 -0
- package/tests/step-definitions/mediawiki-search.steps.js +234 -0
- package/tests/step-definitions/mediawiki-session.steps.js +287 -0
- package/tests/step-definitions/mediawiki-watchlist.steps.js +265 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Webship.co
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,551 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center"><img src="https://raw.githubusercontent.com/webship/mediawiki-steps/2.0.x/assets/logo.svg" alt="MediaWiki logo" width="96"></p>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# mediawiki-steps
|
|
4
|
+
|
|
5
|
+
[](https://github.com/webship/mediawiki-steps/actions/workflows/test.yml)
|
|
6
|
+
|
|
7
|
+
Cucumber step definitions for testing wikis that run on MediaWiki, with
|
|
8
|
+
[webship-js](https://webship.co/docs/webship-js/2.0.x), a BDD browser automation
|
|
9
|
+
harness built on Playwright and Cucumber-js.
|
|
10
|
+
|
|
11
|
+
`@webship-js/mediawiki-steps` covers what every wiki of the release shows, with
|
|
12
|
+
the extensions a default wiki uses (WikiEditor, VisualEditor, CategoryTree,
|
|
13
|
+
Cite):
|
|
14
|
+
|
|
15
|
+
- **reading**: a page by its title, its sections in order, its contents list
|
|
16
|
+
(and a section reached from it), its links (to a page, to a page not written
|
|
17
|
+
yet, to another site), its references, its categories;
|
|
18
|
+
- **search**: the search box with its suggestions (they load late, and the
|
|
19
|
+
steps wait for them), choosing a suggestion, a full search and its results
|
|
20
|
+
page;
|
|
21
|
+
- **the source editor**: the wikitext, the edit summary, a minor edit, the
|
|
22
|
+
preview, the changes, saving, and an edit conflict with another account;
|
|
23
|
+
- **the visual editor**: opening it, typing, saving through its dialog;
|
|
24
|
+
- **the history**: the revisions by their summary and author, comparing two,
|
|
25
|
+
undoing one;
|
|
26
|
+
- **the talk page** and its topics, **categories** and the **category tree**,
|
|
27
|
+
the **watchlist**, **recent changes** and the **preferences**;
|
|
28
|
+
- **file uploads** (Special:Upload) and the duplicate warning;
|
|
29
|
+
- **the administrator's pages**: protecting a page, deleting and restoring it,
|
|
30
|
+
blocking and unblocking an account, and the refusals a protected page and a
|
|
31
|
+
blocked account get;
|
|
32
|
+
- **login and logout**, and the refusals of the account creation form;
|
|
33
|
+
- **test pages**: a scenario makes the pages and files it needs through the
|
|
34
|
+
wiki's API and deletes them after it, whatever happens in it.
|
|
35
|
+
|
|
36
|
+
No step phrase names the platform: a scenario reads `When I edit the page
|
|
37
|
+
"Editing test page" in the visual editor` and `Then the history should list the
|
|
38
|
+
revision "First version" by "editor"`.
|
|
39
|
+
|
|
40
|
+
CI builds a real wiki with [DDEV](https://ddev.com) on the runner (the release
|
|
41
|
+
tarball, installed with its own installer, at the current release 1.46.2 and the
|
|
42
|
+
long-term-support release 1.43.11), and runs the whole suite against it twice on
|
|
43
|
+
every push and pull request, then the assertions that must fail and the reading
|
|
44
|
+
steps on a second bundled skin; see
|
|
45
|
+
[`.github/workflows/test.yml`](.github/workflows/test.yml).
|
|
46
|
+
|
|
47
|
+
## From nothing to a green run
|
|
48
|
+
|
|
49
|
+
What the machine needs: Docker, [DDEV](https://ddev.com), git, python3, and
|
|
50
|
+
Node.js 24 or later with npm. PHP, the database, the job runner and the release
|
|
51
|
+
download run in DDEV's containers.
|
|
52
|
+
|
|
53
|
+
**1. The wiki.** The pack's own build script (the one CI runs) makes the wiki in
|
|
54
|
+
a DDEV project of type `php` with the wiki at the docroot: the release tarball
|
|
55
|
+
(1.46.2 by default, `MEDIAWIKI_VERSION` picks another), installed with its own
|
|
56
|
+
command-line installer, the four extensions above, uploads on, the job queue run
|
|
57
|
+
by a service of the container, and the three accounts of
|
|
58
|
+
[Test users](#test-users). It takes about two minutes.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/webship/mediawiki-steps.git
|
|
62
|
+
SITE_DIR="$PWD/mediawiki-wiki" mediawiki-steps/.github/scripts/build-ddev-site.sh
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The wiki answers at `https://mediawikisteps.ddev.site`. Its accounts are
|
|
66
|
+
`administrator`, `editor` and `reader`, each with the password `dD.123123ddd`
|
|
67
|
+
(step 3 names them).
|
|
68
|
+
|
|
69
|
+
In the [Webship Workspace](https://github.com/webship/workspace), its MediaWiki
|
|
70
|
+
plugin builds the same wiki instead, in a sites folder of the workspace (`dev/`
|
|
71
|
+
here, the one `--with-needs` adds to a new workspace; `test/`, `sandboxes/` and
|
|
72
|
+
`demos/` work the same):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
bash core/scripts/plugins.sh --require mediawiki --with-needs
|
|
76
|
+
bash core/scripts/plugins.sh --activate mediawiki --with-needs
|
|
77
|
+
bash core/scripts/plugins.sh --install mediawiki
|
|
78
|
+
bash dev/cmd-mediawiki-project.sh mwsite --install --add-users --visual-editor
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
That wiki answers at `https://mwsite.ddev.site`. `--visual-editor` turns the
|
|
82
|
+
visual editor on (the visual editor feature needs it). Its accounts are the
|
|
83
|
+
plugin's, the same three with the workspace's shared password `dD.123123ddd`:
|
|
84
|
+
`administrator`, `editor` and `reader`. The workspace's own account is the
|
|
85
|
+
installer's; the suite does not use it.
|
|
86
|
+
|
|
87
|
+
**2. A test project.**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
mkdir mediawiki-tests && cd mediawiki-tests
|
|
91
|
+
npm init -y
|
|
92
|
+
npm install --save-dev webship-js @webship-js/mediawiki-steps
|
|
93
|
+
npx init-webship-js
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`npx init-webship-js` writes `cucumber.js`, `playwright.config.ts`, the `tests/`
|
|
97
|
+
folders with a first feature and the `npm test` scripts, and installs Chromium.
|
|
98
|
+
npm usually runs it already when it installs webship-js; a second run changes
|
|
99
|
+
nothing.
|
|
100
|
+
|
|
101
|
+
**3. `cucumber.js`.** Replace the file with the wiring of the pack: the step
|
|
102
|
+
files of webship-js and of the pack, the tags that keep the assertions that must
|
|
103
|
+
fail out of a normal run, the address of the wiki, and the accounts (the JSON of
|
|
104
|
+
[Test users](#test-users)). The first lines are the starter's own: a feature
|
|
105
|
+
named on the command line runs alone (step 5).
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
// A feature file or a scenario (file:line) named on the command line runs alone:
|
|
109
|
+
// cucumber-js 12 would add it to the paths below, so `paths` is left empty then.
|
|
110
|
+
const OPTIONS_WITH_A_VALUE = new Set([
|
|
111
|
+
'-c', '--config', '-f', '--format', '--format-options', '--i18n-keywords',
|
|
112
|
+
'-i', '--import', '-l', '--loader', '--language', '--name', '--order',
|
|
113
|
+
'-p', '--profile', '--parallel', '--plugin', '--plugin-options',
|
|
114
|
+
'-r', '--require', '--require-module', '--retry', '--retry-tag-filter',
|
|
115
|
+
'--shard', '-t', '--tags', '--world-parameters',
|
|
116
|
+
]);
|
|
117
|
+
|
|
118
|
+
function commandLinePaths() {
|
|
119
|
+
if (!/cucumber(-js|\.js)?$/.test(String(process.argv[1] || ''))) return [];
|
|
120
|
+
const args = process.argv.slice(2);
|
|
121
|
+
const paths = [];
|
|
122
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
123
|
+
if (args[i].startsWith('-')) {
|
|
124
|
+
if (OPTIONS_WITH_A_VALUE.has(args[i])) i += 1;
|
|
125
|
+
} else {
|
|
126
|
+
paths.push(args[i]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return paths;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = {
|
|
133
|
+
default: {
|
|
134
|
+
requireModule: ['tsx/cjs'],
|
|
135
|
+
require: [
|
|
136
|
+
'node_modules/webship-js/tests/step-definitions/**/*.js',
|
|
137
|
+
'node_modules/@webship-js/mediawiki-steps/tests/step-definitions/**/*.js',
|
|
138
|
+
'tests/step-definitions/**/*.js',
|
|
139
|
+
],
|
|
140
|
+
paths: commandLinePaths().length ? [] : ['tests/features/**/*.feature'],
|
|
141
|
+
// Work in progress and the assertions that must fail stay out of a normal run.
|
|
142
|
+
tags: 'not @wip and not @must-fail',
|
|
143
|
+
format: ['@cucumber/pretty-formatter', 'json:tests/reports/cucumber_report.json'],
|
|
144
|
+
worldParameters: {
|
|
145
|
+
launchUrl: process.env.LAUNCH_URL || 'https://mediawikisteps.ddev.site',
|
|
146
|
+
// The account the test-page steps work as, through the wiki's API (a handle of `users`).
|
|
147
|
+
wikiAdmin: 'administrator',
|
|
148
|
+
minWaitTime: { page: 3000, before_scenario: 0, after_scenario: 0, before_step: 0, after_step: 0 },
|
|
149
|
+
users: {
|
|
150
|
+
administrator: { username: 'administrator', password: 'dD.123123ddd', email: 'administrator@example.com' },
|
|
151
|
+
editor: { username: 'editor', password: 'dD.123123ddd', email: 'editor@example.com' },
|
|
152
|
+
reader: { username: 'reader', password: 'dD.123123ddd', email: 'reader@example.com' },
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
On a wiki from the Webship Workspace (step 1) the accounts are the same; its
|
|
160
|
+
address goes in `LAUNCH_URL` (step 5).
|
|
161
|
+
|
|
162
|
+
**4. A first feature**, `tests/features/first-run.feature`:
|
|
163
|
+
|
|
164
|
+
```gherkin
|
|
165
|
+
Feature: First run
|
|
166
|
+
Scenario: A visitor reads a page with its sections
|
|
167
|
+
Given the page "First run page" has the text "A first page.\n== Overview ==\nIts words."
|
|
168
|
+
And I am an anonymous user
|
|
169
|
+
When I open the page "First run page"
|
|
170
|
+
Then I should see the page "First run page"
|
|
171
|
+
And the page should have the section "Overview"
|
|
172
|
+
|
|
173
|
+
Scenario: The editor logs in
|
|
174
|
+
Given I am an anonymous user
|
|
175
|
+
When I log in as "editor" with the login form
|
|
176
|
+
Then I should be logged in as "editor"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The first scenario makes the page "First run page" through the wiki's API, as
|
|
180
|
+
`administrator`, and deletes it again after the scenario.
|
|
181
|
+
|
|
182
|
+
**5. Run it.** Set `LAUNCH_URL` to the address of the wiki:
|
|
183
|
+
`https://mediawikisteps.ddev.site` for the build script's wiki,
|
|
184
|
+
`https://mwsite.ddev.site` for the Workspace's.
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
LAUNCH_URL=https://mediawikisteps.ddev.site npm test
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
A green first run prints every step, then the summary (the starter feature of
|
|
191
|
+
`npx init-webship-js` and the two scenarios above, passed) and the HTML report
|
|
192
|
+
it wrote:
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
3 scenarios (3 passed)
|
|
196
|
+
10 steps (10 passed)
|
|
197
|
+
0m09.000s (executing steps: 0m09.000s)
|
|
198
|
+
[webship-js] HTML report → …/mediawiki-tests/tests/reports/cucumber_report.html
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
One feature runs alone when the command line names it (a scenario too, with
|
|
202
|
+
its line):
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
LAUNCH_URL=https://mediawikisteps.ddev.site npx cucumber-js tests/features/first-run.feature
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
From there, copy the features of [`tests/features/`](tests/features/) (they
|
|
209
|
+
also ship in the package, under
|
|
210
|
+
`node_modules/@webship-js/mediawiki-steps/tests/features/`): together they use
|
|
211
|
+
every step of the pack. Each makes its own test pages, and the upload features
|
|
212
|
+
read `tests/fixtures/blue-square.png` from the project or, when the project has
|
|
213
|
+
none, from the pack. They run as they are on the wiki of either way of step 1.
|
|
214
|
+
|
|
215
|
+
### What the suite tests
|
|
216
|
+
|
|
217
|
+
The features of this repository run every step of the pack against the test
|
|
218
|
+
wiki, twice in a row in CI on every change, then the assertions that must fail:
|
|
219
|
+
each account logging in through the form and taking its session over, "Keep me
|
|
220
|
+
logged in", a refused login and logging out; the account creation form refusing
|
|
221
|
+
two different passwords, a name in use, a short and a common password (and never
|
|
222
|
+
sending a form it would accept); a page read as a visitor with its sections in
|
|
223
|
+
order, its contents list leading to a section, its links (a page, a page not
|
|
224
|
+
written yet, another site) followed, its reference and its category; the search
|
|
225
|
+
box suggesting and opening a page, a full search that finds one page and
|
|
226
|
+
highlights the word, and one that finds nothing; a page made in the source
|
|
227
|
+
editor with a preview and a summary, a minor edit checked with "Show changes",
|
|
228
|
+
an edit conflict with another account; a page changed in the visual editor;
|
|
229
|
+
two revisions compared and a change undone; a talk page with two topics; a
|
|
230
|
+
category with its pages and subcategories and the category tree opened and
|
|
231
|
+
closed; a page watched and unwatched, the watchlist and recent changes; a
|
|
232
|
+
preference ticked, saved and put back; an image uploaded, and a duplicate held
|
|
233
|
+
back; a page protected for autoconfirmed users (the new account refused, the
|
|
234
|
+
confirmed editor not) and for administrators (until the protection is removed),
|
|
235
|
+
a page deleted and restored, an account blocked (and refused) and unblocked; and
|
|
236
|
+
the landmarks of a page.
|
|
237
|
+
|
|
238
|
+
Every page and file a scenario makes is deleted after it, and a block it makes
|
|
239
|
+
is lifted: the suite leaves the wiki as it found it. A preference it changes it
|
|
240
|
+
puts back.
|
|
241
|
+
|
|
242
|
+
Not tested: the mail of the wiki (password reset, e-mail confirmation), page
|
|
243
|
+
moves and redirects, templates and the parser functions, user rights changes,
|
|
244
|
+
the extensions the build does not turn on, the mobile skin, and wikis in another
|
|
245
|
+
language than English (the steps read the English texts of the wiki's messages
|
|
246
|
+
in a few places, named in the hints).
|
|
247
|
+
|
|
248
|
+
## Requirements
|
|
249
|
+
|
|
250
|
+
- Node.js 24 or later
|
|
251
|
+
- A webship-js 2.0 test project (webship-js 2.0.16 or later)
|
|
252
|
+
- A wiki on MediaWiki 1.43 or later, with the VisualEditor and CategoryTree
|
|
253
|
+
extensions for their steps, uploads on for the upload steps, and accounts on
|
|
254
|
+
it for the suite (an administrator among them)
|
|
255
|
+
- On nginx, the rule MediaWiki documents for its REST API
|
|
256
|
+
(`location /rest.php/ { try_files $uri $uri/ /rest.php?$query_string; }`):
|
|
257
|
+
the search suggestions and the visual editor use it
|
|
258
|
+
|
|
259
|
+
## Install
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
npm install --save-dev @webship-js/mediawiki-steps
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## How the steps find things and wait
|
|
266
|
+
|
|
267
|
+
- **By what a person reads.** A page is opened and found by its title, a section
|
|
268
|
+
by its heading, a link by the page it leads to, a revision by its edit
|
|
269
|
+
summary, a field by its label, a preference by its label, an option of a list
|
|
270
|
+
by its text. The wiki's stable hooks are the fallback: its configuration on
|
|
271
|
+
every page (`mw.config`: the page's name, the signed-in account, the action,
|
|
272
|
+
`wgPostEdit` after a save), the ids of its forms (`#wpTextbox1`, `#wpSummary`,
|
|
273
|
+
`#wpSave`), the classes of its messages and of its lists.
|
|
274
|
+
- **No fixed sleeps.** The steps wait on the wiki's own signals:
|
|
275
|
+
- its module loader: `mw.loader.using()` resolved for the modules a page
|
|
276
|
+
asked for, the skin's search module, the editors' modules;
|
|
277
|
+
- its hooks: `ve.activationComplete` when the visual editor is ready,
|
|
278
|
+
`postEdit` and `ve.deactivationComplete` after its save;
|
|
279
|
+
- the answer of the request a widget sends: the search suggestions
|
|
280
|
+
(`rest.php/v1/search/title`, or `action=opensearch` on other skins), the
|
|
281
|
+
category tree (`action=categorytree`), the watch star (`action=watch`), the
|
|
282
|
+
checks of the account creation form (`list=users`, `validatepassword`);
|
|
283
|
+
- the filters app of the watchlist and recent changes
|
|
284
|
+
(`body.mw-rcfilters-ui-initialized`);
|
|
285
|
+
- the category counts after a test page is made: a page is listed in its
|
|
286
|
+
category at once, but the counts the category tree reads are written by a
|
|
287
|
+
job of the wiki, so the step waits until the counts (`categoryinfo`) match
|
|
288
|
+
the members (`categorymembers`).
|
|
289
|
+
- **The visual editor's welcome dialog** opens over the first editor each
|
|
290
|
+
account opens, and makes the page behind it inert: the editing steps close it
|
|
291
|
+
with "Start editing".
|
|
292
|
+
- **Leaving an editor with changes** asks "Leave site?": a step that opens
|
|
293
|
+
another page accepts it, as a person who opens another page means to leave.
|
|
294
|
+
- **A cut request says so.** When the browser shows its own error page
|
|
295
|
+
(`chrome-error://`, a network change on the machine aborted the request), the
|
|
296
|
+
step says that the request was cut before the wiki answered, with a hint to
|
|
297
|
+
run the scenario again, instead of blaming the scenario.
|
|
298
|
+
- **Failures say what was found.** `The page has no section "History". Its
|
|
299
|
+
sections: "Overview", "Editing", …` with a hint on where to look.
|
|
300
|
+
|
|
301
|
+
## Accounts
|
|
302
|
+
|
|
303
|
+
The suite never creates or deletes an account: the account creation steps send
|
|
304
|
+
the form only when the wiki will refuse it. Accounts are configuration: list the
|
|
305
|
+
ones the wiki has in `worldParameters.users`, by a handle the scenarios use, each
|
|
306
|
+
with its `username` and `password`. `worldParameters.wikiAdmin` names the handle
|
|
307
|
+
of an administrator: the test-page steps make, protect and delete the test pages
|
|
308
|
+
and files as that account, through the wiki's API, in a session of their own (the
|
|
309
|
+
browser's session is never touched).
|
|
310
|
+
|
|
311
|
+
The wiki allows 5 failed logins of one account from one address in 5 minutes (a
|
|
312
|
+
successful login clears the count): the refusal scenarios try a name that no
|
|
313
|
+
other scenario logs in with.
|
|
314
|
+
|
|
315
|
+
## Test users
|
|
316
|
+
|
|
317
|
+
The accounts this repository's suite logs in as, exactly as `cucumber.js` lists
|
|
318
|
+
them in `worldParameters.users` (the default values; the `<HANDLE>_USERNAME`,
|
|
319
|
+
`<HANDLE>_PASSWORD` and `<HANDLE>_EMAIL` variables replace them). The build
|
|
320
|
+
script creates them with the maintenance script `createAndPromote`; the
|
|
321
|
+
Workspace's MediaWiki plugin creates the same three.
|
|
322
|
+
|
|
323
|
+
```json
|
|
324
|
+
{
|
|
325
|
+
"administrator": { "username": "administrator", "password": "dD.123123ddd", "email": "administrator@example.com" },
|
|
326
|
+
"editor": { "username": "editor", "password": "dD.123123ddd", "email": "editor@example.com" },
|
|
327
|
+
"reader": { "username": "reader", "password": "dD.123123ddd", "email": "reader@example.com" }
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
`administrator` is in the sysop and bureaucrat groups (in the build script it is
|
|
332
|
+
also the installer's account, which adds interface-admin); `editor` is in the
|
|
333
|
+
"confirmed" group, which gives at once the rights an account otherwise earns
|
|
334
|
+
with age and edits ("autoconfirmed"): it edits the pages protected for
|
|
335
|
+
autoconfirmed users; `reader` is in no group: a new account, refused those
|
|
336
|
+
pages. The wiki names the accounts with an upper-case first letter
|
|
337
|
+
("Administrator"); the steps do too. They are placeholder credentials of a
|
|
338
|
+
throwaway test wiki, not of any real one.
|
|
339
|
+
|
|
340
|
+
## A test wiki
|
|
341
|
+
|
|
342
|
+
[`.github/scripts/build-ddev-site.sh`](.github/scripts/build-ddev-site.sh)
|
|
343
|
+
builds the wiki the suite of this repository runs against, in a DDEV project of
|
|
344
|
+
type `php` (DDEV has no project type of its own for it) with PHP 8.4 and Node.js
|
|
345
|
+
24, the wiki at the docroot:
|
|
346
|
+
|
|
347
|
+
- the release tarball from the release server (`MEDIAWIKI_VERSION`, 1.46.2 by
|
|
348
|
+
default; CI also builds 1.43.11, the long-term-support line, on PHP 8.3);
|
|
349
|
+
- its own installer (`maintenance/run.php install`) on the project's database,
|
|
350
|
+
with WikiEditor, VisualEditor, CategoryTree and Cite, and every bundled skin
|
|
351
|
+
(Vector 2022 the default);
|
|
352
|
+
- uploads on;
|
|
353
|
+
- the rule MediaWiki documents for nginx, so `rest.php/v1/…` reaches the REST
|
|
354
|
+
API (without it, the server answers those addresses with the main page and the
|
|
355
|
+
search box waits for ever);
|
|
356
|
+
- the job queue run by a service of the web container (`runJobs --wait`, as a
|
|
357
|
+
DDEV `web_extra_daemons` entry), as MediaWiki recommends for a wiki, and
|
|
358
|
+
`$wgJobRunRate = 0`;
|
|
359
|
+
- the object cache and the sessions in the database (the installer picks the
|
|
360
|
+
PHP process cache, which the maintenance scripts cannot see and a restart
|
|
361
|
+
empties);
|
|
362
|
+
- a new account earns the "autoconfirmed" rights after 4 days and 10 edits, as
|
|
363
|
+
on large public wikis, and a "confirmed" group gives them at once;
|
|
364
|
+
- the three accounts.
|
|
365
|
+
|
|
366
|
+
Run again with `ACCOUNTS_ONLY=1` and the same `SITE_DIR`, it gives the accounts
|
|
367
|
+
back their password, address and groups and lifts any block on them (after a run
|
|
368
|
+
that was stopped half way).
|
|
369
|
+
|
|
370
|
+
`WIKI_SKIN=monobook CUCUMBER_TAGS=@reading npx cucumber-js` runs the reading
|
|
371
|
+
steps on another bundled skin (the steps ask for it with `useskin=` on every
|
|
372
|
+
page they open).
|
|
373
|
+
|
|
374
|
+
## Steps
|
|
375
|
+
|
|
376
|
+
84 steps in 8 files, every one with five examples in its JSDoc (`npm run test:examples` checks them).
|
|
377
|
+
|
|
378
|
+
| File | Steps | Covers |
|
|
379
|
+
| --- | --- | --- |
|
|
380
|
+
| `mediawiki-session.steps.js` | 9 | The session: logging in by a handle or through the form, refusals, logging out, who is signed in, the account creation refusals. |
|
|
381
|
+
| `mediawiki-pages.steps.js` | 27 | Test pages and files made and deleted through the API, opening a page, its title and text, sections and contents list, links, references, categories, the category tree, talk pages, the page's scripts. |
|
|
382
|
+
| `mediawiki-search.steps.js` | 7 | The search box and its suggestions, choosing one, a full search and its results page. |
|
|
383
|
+
| `mediawiki-editing.steps.js` | 17 | The source editor (wikitext, preview, changes, saving with a summary or as a minor edit), the visual editor, edit conflicts, the refusal of a page the account may not edit. |
|
|
384
|
+
| `mediawiki-history.steps.js` | 5 | The history: its revisions, comparing two, undoing one. |
|
|
385
|
+
| `mediawiki-watchlist.steps.js` | 8 | The watch star, the watchlist, recent changes, the preferences. |
|
|
386
|
+
| `mediawiki-files.steps.js` | 3 | The upload form, its warnings, the page of a file. |
|
|
387
|
+
| `mediawiki-admin.steps.js` | 8 | Protecting a page, deleting and restoring it, blocking and unblocking an account. |
|
|
388
|
+
| `mediawiki-helpers.js` | | Shared plumbing: the addresses of the wiki, the waits on its module loader, hooks and job queue, the users registry and the session cache, the messages of a page, the cut request, the client of the wiki's API for the test data. It registers no step. |
|
|
389
|
+
|
|
390
|
+
Text, links, fields, buttons, the status code of a page and the accessibility checks are webship-js's own steps (`I should see "..."`, `I fill in "..." with "..."`, `I press "..."`, `the page should have a main landmark`); this pack adds what the wiki decides.
|
|
391
|
+
|
|
392
|
+
### `mediawiki-session.steps.js` (9)
|
|
393
|
+
|
|
394
|
+
- `Given I am a logged in user with the "editor" user`
|
|
395
|
+
- `When I log in as "editor" with the login form`
|
|
396
|
+
- `When I log in with the user name "No such account here" and the password "Wrong-password-1"`
|
|
397
|
+
- `Then the login should be refused with "Incorrect username or password entered. Please try again."`
|
|
398
|
+
- `When I log out`
|
|
399
|
+
- `Then I should be logged in as "editor"`
|
|
400
|
+
- `Then I should be logged in`
|
|
401
|
+
- `When I try to create the account "Never created account" with the password "Unique-pass-2026-x" and the confirmation "Unique-pass-2026-y"`
|
|
402
|
+
- `Then the account creation should be refused with "The passwords you entered do not match."`
|
|
403
|
+
|
|
404
|
+
### `mediawiki-pages.steps.js` (27)
|
|
405
|
+
|
|
406
|
+
- `Given the page "Reading test page" has the text:`
|
|
407
|
+
- `Given the page "History test page" has the text "First version of the page." with the summary "First version"`
|
|
408
|
+
- `Given the page "Page made in the source editor" does not exist`
|
|
409
|
+
- `Given the page "Protected test page" is protected so that only autoconfirmed users can edit it`
|
|
410
|
+
- `Given the file "Test square.png" is uploaded from "tests/fixtures/blue-square.png"`
|
|
411
|
+
- `Given the account "reader" is not blocked`
|
|
412
|
+
- `When I open the page "Reading test page"`
|
|
413
|
+
- `Then I should see the page "Reading test page"`
|
|
414
|
+
- `Then the page text should contain "First version of the page."`
|
|
415
|
+
- `Then the page should have the section "Overview"`
|
|
416
|
+
- `Then the page should have these sections in order:`
|
|
417
|
+
- `Then the contents list should list "Overview"`
|
|
418
|
+
- `When I follow "Overview" in the contents list`
|
|
419
|
+
- `Then I should be at the section "Overview"`
|
|
420
|
+
- `Then the page should link to the page "Editing help"`
|
|
421
|
+
- `Then the page should link to the external site "https://example.org"`
|
|
422
|
+
- `When I follow the link to the page "Editing help"`
|
|
423
|
+
- `Then the reference "1" should read "Every page keeps its history."`
|
|
424
|
+
- `Then the page should be in the category "Test guides"`
|
|
425
|
+
- `When I follow the category "Test guides"`
|
|
426
|
+
- `Then the category should list the page "Reading test page"`
|
|
427
|
+
- `When I expand the category "Test guides" in the category tree`
|
|
428
|
+
- `Then the category tree should show "Editing guides" under "Test guides"`
|
|
429
|
+
- `When I open the talk page`
|
|
430
|
+
- `When I add the topic "A question about this page" with the text "Is this page complete?"`
|
|
431
|
+
- `Then the talk page should have the topic "A question about this page"`
|
|
432
|
+
- `Then the scripts of the page should all load`
|
|
433
|
+
|
|
434
|
+
### `mediawiki-search.steps.js` (7)
|
|
435
|
+
|
|
436
|
+
- `When I type "Readi" in the search box`
|
|
437
|
+
- `Then the search suggestions should list "Reading test page"`
|
|
438
|
+
- `When I choose the suggestion "Reading test page"`
|
|
439
|
+
- `When I search for "readers"`
|
|
440
|
+
- `Then the search results should list the page "Reading test page"`
|
|
441
|
+
- `Then the search result "Reading test page" should mention "readers"`
|
|
442
|
+
- `Then the search should find 1 page`
|
|
443
|
+
|
|
444
|
+
### `mediawiki-editing.steps.js` (17)
|
|
445
|
+
|
|
446
|
+
- `When I edit the page "Editing test page"`
|
|
447
|
+
- `When I set the wikitext to:`
|
|
448
|
+
- `When I set the wikitext to "A page made in the source editor."`
|
|
449
|
+
- `When I add the wikitext "A line added at the end."`
|
|
450
|
+
- `When I preview the page`
|
|
451
|
+
- `Then the preview should show "A page made in the source editor."`
|
|
452
|
+
- `When I show my changes`
|
|
453
|
+
- `Then the changes should show "Second version of the page." added`
|
|
454
|
+
- `When I edit the page "Visual editor test page" in the visual editor`
|
|
455
|
+
- `When I type " Typed in the visual editor." in the visual editor`
|
|
456
|
+
- `Then the visual editor should be open`
|
|
457
|
+
- `When I save the page`
|
|
458
|
+
- `Then the edit should be saved`
|
|
459
|
+
- `When another account saves the page "Conflict test page" with the text "Changed by another account."`
|
|
460
|
+
- `Then I should see an edit conflict`
|
|
461
|
+
- `Then the edit conflict should keep my text "My own first line."`
|
|
462
|
+
- `Then editing the page "Protected test page" should be refused with "This page has been protected to prevent editing or other actions."`
|
|
463
|
+
|
|
464
|
+
### `mediawiki-history.steps.js` (5)
|
|
465
|
+
|
|
466
|
+
- `When I open the history of the page "History test page"`
|
|
467
|
+
- `Then the history should list the revision "First version"`
|
|
468
|
+
- `Then the history should list 2 revisions`
|
|
469
|
+
- `When I compare the revisions "First version" and "Second version"`
|
|
470
|
+
- `When I undo the revision "Second version"`
|
|
471
|
+
|
|
472
|
+
### `mediawiki-watchlist.steps.js` (8)
|
|
473
|
+
|
|
474
|
+
- `When I watch the page`
|
|
475
|
+
- `Then I should be watching the page`
|
|
476
|
+
- `Then my watchlist should list the page "Reading test page"`
|
|
477
|
+
- `Then the recent changes should show a change to "Reading test page"`
|
|
478
|
+
- `When I open my preferences`
|
|
479
|
+
- `When I tick the preference "Mark all edits minor by default"`
|
|
480
|
+
- `When I save my preferences`
|
|
481
|
+
- `Then the preference "Mark all edits minor by default" should be ticked`
|
|
482
|
+
|
|
483
|
+
### `mediawiki-files.steps.js` (3)
|
|
484
|
+
|
|
485
|
+
- `When I upload the file "tests/fixtures/blue-square.png" as "Test square.png"`
|
|
486
|
+
- `Then the upload should be held back with the warning "This file is a duplicate of the following file"`
|
|
487
|
+
- `Then I should see the file "Test square.png"`
|
|
488
|
+
|
|
489
|
+
### `mediawiki-admin.steps.js` (8)
|
|
490
|
+
|
|
491
|
+
- `When I protect the page "Protection test page" so that only autoconfirmed users can edit it`
|
|
492
|
+
- `Then the page "Protection test page" should be protected so that only autoconfirmed users can edit it`
|
|
493
|
+
- `When I delete the page "Deletion test page" with the reason "A test of the deletion"`
|
|
494
|
+
- `When I restore the page "Deletion test page" with the reason "Deleted by mistake"`
|
|
495
|
+
- `Then the page "Deletion test page" should not exist`
|
|
496
|
+
- `When I block the account "reader" for "1 day" with the reason "A test of the block"`
|
|
497
|
+
- `When I unblock the account "reader" with the reason "The test is over"`
|
|
498
|
+
- `Then the account "reader" should be blocked`
|
|
499
|
+
|
|
500
|
+
## Phrases shared with other packs
|
|
501
|
+
|
|
502
|
+
The session phrases are the ones every platform pack has, so a feature reads
|
|
503
|
+
the same on every system (one cucumber.js profile per system; the platform packs
|
|
504
|
+
are not meant to be loaded together). Loaded beside each of the 24 published
|
|
505
|
+
packs, these phrases of this pack also match one of theirs:
|
|
506
|
+
|
|
507
|
+
| Phrase of this pack | Also in |
|
|
508
|
+
| --- | --- |
|
|
509
|
+
| `I am a logged in user with the "editor" user` | codeigniter, django-cms, drupal-core, joomla, laravel, odoo, symfony, typo3, wordpress |
|
|
510
|
+
| `I log in as "editor" with the login form` | codeigniter, laravel, symfony |
|
|
511
|
+
| `I log out` | codeigniter, django-cms, drupal-core, laravel, odoo, symfony, typo3, wordpress |
|
|
512
|
+
| `I should be logged in` / `I should be logged in as "editor"` | backdrop-cms, codeigniter, django-cms, drupal-core, laravel, odoo, symfony, typo3, wordpress |
|
|
513
|
+
| `I preview the page` | django-cms, ghost |
|
|
514
|
+
| `the preview should show "…"` | craft-cms, ghost |
|
|
515
|
+
| `I search for "…"` | drupal-core, wordpress |
|
|
516
|
+
| `I save the page` | typo3 |
|
|
517
|
+
| `the account "reader" should be blocked` | backdrop-cms |
|
|
518
|
+
|
|
519
|
+
None matches a webship-js step, and none matches a phrase of the component
|
|
520
|
+
packs (Bootstrap), which can be loaded beside this one.
|
|
521
|
+
|
|
522
|
+
## Testing this package
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
npm ci
|
|
526
|
+
npm run test:examples # every step's JSDoc examples match it and nothing else; every feature step resolves
|
|
527
|
+
npm run test:paths # a feature named on the command line runs alone
|
|
528
|
+
npx cucumber-js --dry-run
|
|
529
|
+
SITE_DIR="$PWD/../mediawiki-wiki" .github/scripts/build-ddev-site.sh
|
|
530
|
+
npx cucumber-js # the whole suite
|
|
531
|
+
npm run test:must-fail # the assertions that must fail, each with its message and a hint
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## How the steps were written
|
|
535
|
+
|
|
536
|
+
Every step was written from a round of manual testing of a real local wiki in
|
|
537
|
+
the browser first: each screen it touches was opened, its roles, labels and
|
|
538
|
+
messages noted, and the signal it gives while it loads or saves found. The
|
|
539
|
+
failures of the first runs went back to the browser before the step changed.
|
|
540
|
+
|
|
541
|
+
## License
|
|
542
|
+
|
|
543
|
+
MIT, see [LICENSE](LICENSE).
|
|
544
|
+
|
|
545
|
+
## Logo
|
|
546
|
+
|
|
547
|
+
The logo is the MediaWiki logo the release ships
|
|
548
|
+
(`resources/assets/mediawiki_compact.svg` of MediaWiki 1.46.2), unmodified: by
|
|
549
|
+
Serhio Magpie, under the Creative Commons Attribution-ShareAlike 4.0 licence. It
|
|
550
|
+
names the software these steps test; MediaWiki and its logo are trademarks of
|
|
551
|
+
the Wikimedia Foundation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webship-js/mediawiki-steps",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Cucumber step definitions for MediaWiki, a plugin for webship-js (Playwright and Cucumber): reading a page with its contents list, sections, links, references and categories; the search box with its suggestions and the results page; the source editor (summary, minor edit, preview, changes, edit conflicts) and the visual editor; the history (compare, undo), talk pages, the category tree, the watchlist, recent changes and preferences; file uploads; protecting, deleting, restoring and blocking; login, logout and account creation refusals.",
|
|
5
|
+
"main": "tests/step-definitions/mediawiki-session.steps.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"tests/step-definitions/",
|
|
8
|
+
"tests/features/",
|
|
9
|
+
"tests/fixtures/",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "cucumber-js --config cucumber.js",
|
|
15
|
+
"test:dry": "cucumber-js --config cucumber.js --dry-run",
|
|
16
|
+
"test:examples": "node tests/check-examples.js",
|
|
17
|
+
"test:paths": "node tests/check-paths.js",
|
|
18
|
+
"test:must-fail": "node tests/check-must-fail.js",
|
|
19
|
+
"test:chromium": "BROWSER=chromium cucumber-js --config cucumber.js",
|
|
20
|
+
"test:firefox": "BROWSER=firefox cucumber-js --config cucumber.js",
|
|
21
|
+
"test:webkit": "BROWSER=webkit cucumber-js --config cucumber.js",
|
|
22
|
+
"test:headed": "HEADLESS=false cucumber-js --config cucumber.js",
|
|
23
|
+
"generate-reports": "generate-reports",
|
|
24
|
+
"test:fast": "SLOW_MO=0 cucumber-js --config cucumber.js"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"webship-js",
|
|
28
|
+
"mediawiki",
|
|
29
|
+
"wiki",
|
|
30
|
+
"visualeditor",
|
|
31
|
+
"cucumber",
|
|
32
|
+
"cucumber-js",
|
|
33
|
+
"playwright",
|
|
34
|
+
"bdd",
|
|
35
|
+
"testing",
|
|
36
|
+
"e2e",
|
|
37
|
+
"gherkin"
|
|
38
|
+
],
|
|
39
|
+
"author": "Webship.co",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/webship/mediawiki-steps.git"
|
|
44
|
+
},
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/webship/mediawiki-steps/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/webship/mediawiki-steps#readme",
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">= 24.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"webship-js": "^2.0.16"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"tsx": "^4.23.0",
|
|
60
|
+
"webship-js": "^2.0.16"
|
|
61
|
+
},
|
|
62
|
+
"overrides": {
|
|
63
|
+
"@cucumber/cucumber": "^12"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Features
|
|
2
|
+
|
|
3
|
+
Reference features for the test wiki that `.github/scripts/build-ddev-site.sh`
|
|
4
|
+
builds (or the Webship Workspace's builder, with `--install --add-users
|
|
5
|
+
--visual-editor`): the release with WikiEditor, VisualEditor, CategoryTree and
|
|
6
|
+
Cite, uploads on, and the three accounts of `cucumber.js` (`administrator`,
|
|
7
|
+
`editor`, `reader`). Each scenario makes the pages and files it needs and deletes
|
|
8
|
+
them after it, so a feature runs as it is on any such wiki.
|
|
9
|
+
|
|
10
|
+
| Feature | Covers |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `session` | Each account logging in through the form, a session taken over, "Keep me logged in", a refused login, logging out. |
|
|
13
|
+
| `account-creation` | The account creation form refusing two different passwords, a name in use, a short and a common password. No account is created. |
|
|
14
|
+
| `reading` | A page read as a visitor: its sections in order, its contents list leading to a section, its links followed, its reference, its category. |
|
|
15
|
+
| `search` | The search box suggesting and opening a page, a full search that finds one page and highlights the word, a search that finds nothing. |
|
|
16
|
+
| `source-editor` | A page made in the source editor with a preview and a summary; a minor edit checked with "Show changes". |
|
|
17
|
+
| `edit-conflict` | An edit conflict with another account. |
|
|
18
|
+
| `visual-editor` | A page changed in the visual editor and saved with a summary. |
|
|
19
|
+
| `history` | Two revisions compared, a change undone. |
|
|
20
|
+
| `talk-page` | A talk page with two topics. |
|
|
21
|
+
| `categories` | A category with its pages and subcategories, the category tree opened and closed. |
|
|
22
|
+
| `watchlist` | A page watched and unwatched, the watchlist and recent changes. |
|
|
23
|
+
| `preferences` | A preference ticked, saved and put back. |
|
|
24
|
+
| `upload` | An image uploaded, and a duplicate held back. |
|
|
25
|
+
| `administration` | A page protected for autoconfirmed users and for administrators, deleted and restored; an account blocked and unblocked. |
|
|
26
|
+
| `accessibility` | The landmarks, the skip link, the one main heading and the language of a page. |
|