@webship-js/bbpress-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 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,516 @@
1
- # Temporary Holding Version
1
+ <p align="center"><img src="https://raw.githubusercontent.com/webship/bbpress-steps/2.0.x/assets/logo.svg" alt="bbPress logo" width="96"></p>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # bbpress-steps
4
+
5
+ [![Test](https://github.com/webship/bbpress-steps/actions/workflows/test.yml/badge.svg)](https://github.com/webship/bbpress-steps/actions/workflows/test.yml)
6
+
7
+ Cucumber step definitions for testing forums on WordPress with bbPress, 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/bbpress-steps` is an extension of
12
+ [`@webship-js/wordpress-steps`](https://github.com/webship/wordpress-steps): it
13
+ depends on it and loads it, so a project with forums installs this one pack and
14
+ has both. The WordPress pack gives the login by a handle of the users registry,
15
+ the administration screens, menus and notices, a setting by its label and the
16
+ rest of the site; this pack adds the forums:
17
+
18
+ - **the forum index and a forum**: the forums an account sees, under their
19
+ category, their counters and marks (a category, closed, private, hidden), the
20
+ topics of a forum in their order (super sticky, sticky, then by their last
21
+ post), their marks, replies, voices and authors, the pages of a list, the
22
+ forums' breadcrumbs and what the forums say in their notices;
23
+ - **a topic**: its posts by their number on the page (who wrote them, the
24
+ author's forum role, what they say and how it is formatted, their edit log),
25
+ whether it is open, closed, sticky, pending, spam or in the trash, its tags;
26
+ - **the forms**: a new topic, a reply and an edit, with the editor's toolbar
27
+ (bold, italics, a quote, code, struck through), the tags, the topic's type and
28
+ status, the reason of an edit, and the errors the forums answer with;
29
+ - **subscriptions and favorites**: subscribing to a topic or a forum, marking a
30
+ topic as a favorite, the lists of the profile, and removing a row from them;
31
+ - **the forum profile**: what it shows, the pages it offers, the forum role of an
32
+ account, and its edit form;
33
+ - **the forum search, topic tags and views**: the results (topics and replies),
34
+ opening one, the page of a tag, "Most popular topics" and "Topics with no
35
+ replies";
36
+ - **moderation**: close and open, stick (in its forum, or to the front of every
37
+ forum), unapprove and approve, spam, trash, restore and delete a topic or a
38
+ reply, merge a topic into another, split a topic at a reply, move a reply, move
39
+ a topic to another forum, and what the forums hide until a moderator asks;
40
+ - **the forum roles**: what a visitor, a spectator, a participant, a moderator, a
41
+ keymaster and a blocked account reach, by the steps above;
42
+ - **the forums in the administration**: the lists of forums, topics and replies
43
+ and the actions of their rows, the features of the forums' settings screen, the
44
+ repair tools, the forum role of an account on the users screen, and the
45
+ forums' screens by name ("Topics", "Forums settings", "Forum tools");
46
+ - **the notification e-mails**, read in the local mail catcher;
47
+ - **test content**: a topic and a reply a scenario starts from, posted by the
48
+ account that owns them, and their removal.
49
+
50
+ No step phrase names the platform: a scenario reads `When I start a new topic in
51
+ "General discussion"` and `Then the topic should be closed`.
52
+
53
+ CI builds a real site with [DDEV](https://ddev.com) on the runner (the latest
54
+ WordPress with the latest bbPress from the plugin directory, the accounts of the
55
+ suite, the test content), on a block theme and on a classic theme, and runs the
56
+ whole suite against it twice on every push and pull request, then the assertions
57
+ that must fail; see [The test site](#the-test-site) and
58
+ [`.github/workflows/test.yml`](.github/workflows/test.yml).
59
+
60
+ ## From nothing to a green run
61
+
62
+ What the machine needs: Docker, [DDEV](https://ddev.com), git, python3, and Node.js 24 or later with npm. PHP, WP-CLI, the database and the mail catcher run in DDEV's containers.
63
+
64
+ **1. The site.** The pack's own build script (the one CI runs) makes the site in a DDEV project of type `wordpress`: the latest WordPress, bbPress from the plugin directory, the theme WordPress installs with, the six accounts of [Test users](#test-users) and the test content (see [The test site](#the-test-site)). It takes about two minutes.
65
+
66
+ ```bash
67
+ git clone https://github.com/webship/bbpress-steps.git
68
+ SITE_DIR="$PWD/bbpress-site" bbpress-steps/.github/scripts/build-ddev-site.sh
69
+ ```
70
+
71
+ The forums answer at `https://bbpresssteps.ddev.site/forums/` and the mail catcher at `https://bbpresssteps.ddev.site:8026`. The accounts are `administrator`, `keymaster`, `moderator`, `participant`, `spectator` and `blocked`, each with the password `dD.123123ddd` (step 3 names them).
72
+
73
+ In the [Webship Workspace](https://github.com/webship/workspace), its bbPress plugin builds the same site instead, on top of its WordPress plugin, in a sites folder of the workspace (`dev/` here, the one `--with-needs` adds to a new workspace; `test/`, `sandboxes/` and `demos/` work the same):
74
+
75
+ ```bash
76
+ bash core/scripts/plugins.sh --require bbpress --with-needs
77
+ bash core/scripts/plugins.sh --activate bbpress --with-needs
78
+ bash core/scripts/plugins.sh --install bbpress
79
+ bash dev/cmd-bbpress-project.sh bbpsite --install --add-users --sample-content
80
+ ```
81
+
82
+ Those forums answer at `https://bbpsite.ddev.site/forums/` and the mail catcher at `https://bbpsite.ddev.site:8026`. `--sample-content` adds the forums and topics the features name. Its accounts are the plugin's, the same six with the workspace's shared password `dD.123123ddd` (step 3 names them); the workspace's own account is the installer's, one more keymaster of the forums.
83
+
84
+ **2. A test project.**
85
+
86
+ ```bash
87
+ mkdir bbpress-tests && cd bbpress-tests
88
+ npm init -y
89
+ npm install --save-dev webship-js @webship-js/bbpress-steps
90
+ npx init-webship-js
91
+ ```
92
+
93
+ `npx init-webship-js` writes `cucumber.js`, `playwright.config.ts`, the `tests/` folders with a first feature and the `npm test` scripts, and installs Chromium. npm usually runs it already when it installs webship-js; a second run changes nothing. npm installs `@webship-js/wordpress-steps` along with the pack.
94
+
95
+ **3. `cucumber.js`.** Replace the file with the wiring of the pack: the step files of webship-js and of the pack (which loads the WordPress pack's itself), the tags that keep the assertions that must fail out of a normal run, the address of the site and of its mail catcher, the account that removes test content, and the accounts (the JSON of [Test users](#test-users)). The first lines are the starter's own: a feature named on the command line runs alone.
96
+
97
+ ```javascript
98
+ // A feature file or a scenario (file:line) named on the command line runs alone:
99
+ // cucumber-js 12 would add it to the paths below, so `paths` is left empty then.
100
+ const OPTIONS_WITH_A_VALUE = new Set([
101
+ '-c', '--config', '-f', '--format', '--format-options', '--i18n-keywords',
102
+ '-i', '--import', '-l', '--loader', '--language', '--name', '--order',
103
+ '-p', '--profile', '--parallel', '--plugin', '--plugin-options',
104
+ '-r', '--require', '--require-module', '--retry', '--retry-tag-filter',
105
+ '--shard', '-t', '--tags', '--world-parameters',
106
+ ]);
107
+
108
+ function commandLinePaths() {
109
+ if (!/cucumber(-js|\.js)?$/.test(String(process.argv[1] || ''))) return [];
110
+ const args = process.argv.slice(2);
111
+ const paths = [];
112
+ for (let i = 0; i < args.length; i += 1) {
113
+ if (args[i].startsWith('-')) {
114
+ if (OPTIONS_WITH_A_VALUE.has(args[i])) i += 1;
115
+ } else {
116
+ paths.push(args[i]);
117
+ }
118
+ }
119
+ return paths;
120
+ }
121
+
122
+ const launchUrl = (process.env.LAUNCH_URL || 'https://bbpresssteps.ddev.site').replace(/\/+$/, '');
123
+
124
+ module.exports = {
125
+ default: {
126
+ requireModule: ['tsx/cjs'],
127
+ require: [
128
+ 'node_modules/webship-js/tests/step-definitions/**/*.js',
129
+ 'node_modules/@webship-js/bbpress-steps/tests/step-definitions/**/*.js',
130
+ 'tests/step-definitions/**/*.js',
131
+ ],
132
+ paths: commandLinePaths().length ? [] : ['tests/features/**/*.feature'],
133
+ // Work in progress and the assertions that must fail stay out of a normal run.
134
+ tags: process.env.CUCUMBER_TAGS || 'not @wip and not @must-fail',
135
+ format: ['@cucumber/pretty-formatter', 'json:tests/reports/cucumber_report.json'],
136
+ worldParameters: {
137
+ launchUrl,
138
+ // The mail catcher of the site (the notification steps read it): the Mailpit of the DDEV project.
139
+ mailUrl: `${launchUrl}:8026`,
140
+ // Where the forums start, and the account that removes test content for the Given steps.
141
+ forums: { root: '/forums/', moderator: 'moderator' },
142
+ // The waits webship-js adds around each page, scenario and step (milliseconds).
143
+ minWaitTime: { page: 3000, before_scenario: 0, after_scenario: 0, before_step: 0, after_step: 0 },
144
+ // "admin" is the handle the WordPress pack's features give the administrator.
145
+ users: {
146
+ admin: { username: 'administrator', password: 'dD.123123ddd', email: 'administrator@example.com' },
147
+ keymaster: { username: 'keymaster', password: 'dD.123123ddd', email: 'keymaster@example.com' },
148
+ moderator: { username: 'moderator', password: 'dD.123123ddd', email: 'moderator@example.com' },
149
+ participant: { username: 'participant', password: 'dD.123123ddd', email: 'participant@example.com' },
150
+ spectator: { username: 'spectator', password: 'dD.123123ddd', email: 'spectator@example.com' },
151
+ blocked: { username: 'blocked', password: 'dD.123123ddd', email: 'blocked@example.com' },
152
+ },
153
+ },
154
+ },
155
+ };
156
+ ```
157
+
158
+ On a site from the Webship Workspace (step 1) the accounts are the same; its address goes in `LAUNCH_URL` (step 5), and `mailUrl` follows it. No console noise of the browser needs to be ignored: the forums' pages log no error. The scenarios of a page the forums answer with "not found" or the administration with "forbidden" carry `@js-off`, because the browser logs "Failed to load resource" for it.
159
+
160
+ **4. A first feature**, `tests/features/first-run.feature`:
161
+
162
+ ```gherkin
163
+ Feature: First run
164
+ Scenario: A visitor reads a topic of the forums
165
+ Given I am an anonymous user
166
+ And I am on the forum index
167
+ Then the forum index should list the forum "General discussion" in the category "Community"
168
+ When I open the topic "Welcome to the forums" in "General discussion"
169
+ Then the topic should have 3 posts
170
+ And post 1 should be by "keymaster"
171
+ And I should not be able to reply
172
+
173
+ Scenario: The moderator has the moderator tools
174
+ Given I am a logged in user with the "moderator" user
175
+ When I open the topic "A community garden in spring" in "General discussion"
176
+ Then I should see the moderator tools
177
+ And the author of the last post should be a "Moderator"
178
+ ```
179
+
180
+ **5. Run it.** Set `LAUNCH_URL` to the address of the site: `https://bbpresssteps.ddev.site` for the build script's site, `https://bbpsite.ddev.site` for the Workspace's.
181
+
182
+ ```bash
183
+ LAUNCH_URL=https://bbpresssteps.ddev.site npm test
184
+ ```
185
+
186
+ A green first run prints every step, then the summary (the starter feature of `npx init-webship-js` and the two scenarios above, passed) and the HTML report it wrote:
187
+
188
+ ```
189
+ 3 scenarios (3 passed)
190
+ 13 steps (13 passed)
191
+ 0m09.000s (executing steps: 0m09.000s)
192
+ [webship-js] HTML report → …/bbpress-tests/tests/reports/cucumber_report.html
193
+ ```
194
+
195
+ From there, copy the features of [`tests/features/`](tests/features/) (they also ship in the package, under `node_modules/@webship-js/bbpress-steps/tests/features/`): together they use every step of the pack. They read no file of their own, and they run as they are on the site of either way of step 1. One feature runs alone when it is named: `LAUNCH_URL=… npx cucumber-js tests/features/moderation.feature`.
196
+
197
+ ### What the suite tests
198
+
199
+ The features of this repository run every step of the pack against the test site, twice in a row in CI on every change, then the assertions that must fail:
200
+
201
+ - **`accessibility.feature`**: an accessibility audit of the pages a visitor reads (a category, a forum, a topic and its second page, a view, a profile): no critical violation, a declared language, one main heading.
202
+ - **`forum-index.feature`**: the public forums under their category, the counters and marks of the index, a category and its forums, a forum's list in its order (the super sticky topic, the sticky one, the closed one), the row of a topic (author, replies, voices), a forum of two pages, a visitor asked to log in before posting, a closed forum.
203
+ - **`topics.feature`**: a topic read by a visitor (its posts, their authors and forum roles, its tags), a topic of two pages, a closed topic, a participant starting a topic with tags and a moderator replying, the refusals of an empty topic and an empty reply, the editor's toolbar, an edit with its reason in the edit log.
204
+ - **`subscriptions-and-favorites.feature`**: a favorite marked and unmarked, a subscription to a topic and to a forum removed from the profile, a spectator who may not reply but may mark a favorite, the lists of the profile.
205
+ - **`profiles.feature`**: a profile read by a visitor, its pages, the forum role of each of the six accounts, an account editing its own profile and putting it back, an account kept out of another's.
206
+ - **`search-and-tags.feature`**: a search that finds a topic and a reply and opens one, a search with no match, the pages of the results, a search that shows an account only what it may read, the page of a topic tag, the two views.
207
+ - **`moderation.feature`**: what a participant and a moderator are offered, a topic closed and opened, stuck in its forum and to the front of every forum, unapproved and approved, spammed, trashed, restored and deleted, a reply hidden and deleted, a topic split, a reply moved, the topics merged again, a reply moved into a topic of its own, a topic moved to another forum and edited with a reason.
208
+ - **`forum-roles.feature`**: the private forum for a participant, the hidden one for a moderator and a keymaster, neither for a visitor, a spectator who writes nothing, a blocked account that gets no forum at all, the keymaster posting in a closed forum, the administration by role.
209
+ - **`administration.feature`**: the forums' screens by name, the lists of forums, topics and replies, a moderator working on a topic from the topics list (close, stick, unapprove, spam, trash, restore, delete), a forum closed from the forums list, the forums' settings, a feature turned off and on again, the repair tools, the forum roles on the users screen and one changed and put back.
210
+ - **`notifications.feature`**: the mail a subscriber of a topic gets of a reply (and its author does not), the mail a subscriber of a forum gets of a new topic, no mail when nobody follows.
211
+
212
+ Every scenario that makes a topic removes it again (deleted for good, with its replies), a setting or a forum role it changes it puts back, and a favorite or a subscription it adds it removes: the suite leaves the site as it found it.
213
+
214
+ The accessibility audit leaves out the pages that carry a search field of the forums (the forum index, the search page, the page of a topic tag, the lists of a profile) and the topic and reply forms: on bbPress 2.6.22 the search field's label is hidden from every reader and the editor has no label, which the audit reports as critical (`label`). A site that fixes them in its theme can audit those pages with webship-js's own step, `Then the page should have no critical accessibility violations`.
215
+
216
+ Not tested: threaded replies (the setting is off, as the plugin sets it), anonymous posting (off by default; the suite would have to post as a guest), the visual editor of a post (the forums print the plain editor with its toolbar), per-forum moderators, the forums' widgets, shortcodes and blocks on other pages of the site, the importers of Tools > Forums, the forums' feeds, and Akismet's spam check (it needs an account).
217
+
218
+ ## Requirements
219
+
220
+ - Node.js 24 or later
221
+ - A webship-js 2.0 test project (webship-js 2.0.16 or later)
222
+ - A site on WordPress with bbPress 2.6, and accounts on it for the suite
223
+
224
+ ## Install
225
+
226
+ ```bash
227
+ npm install --save-dev @webship-js/bbpress-steps
228
+ ```
229
+
230
+ npm installs `@webship-js/wordpress-steps` with it. List only this pack's step files in `cucumber.js`: it loads the WordPress pack's itself. A project that also lists the WordPress pack's glob is fine while npm installed one copy of it (Node loads a file once); a second, nested copy (the project pins another release line of the WordPress pack) would register every WordPress step twice, so drop that glob then.
231
+
232
+ ## What is included
233
+
234
+ | File | Steps | Covers |
235
+ | --- | --- | --- |
236
+ | `bbpress-forums.steps.js` | 17 | The forum index (the forums it lists, under their category, their counters and marks), a forum (opening it, its topics, their marks, replies, voices and authors, its total, its first topic), the pages of a list, the forums' breadcrumbs and notices, whether the account may start a topic or reply, and a page the forums do not let it open. |
237
+ | `bbpress-topics.steps.js` | 23 | A topic (opening it, its posts, their authors and forum roles, their text and format, their edit log, its state and tags) and the forms: a new topic, the title, the editor and its toolbar, the tags, the type and status, the reason of an edit, submitting, the errors, a reply, editing a post, the links a post offers. |
238
+ | `bbpress-moderation.steps.js` | 12 | The moderation links of a topic and of a reply (close, open, stick, unstick, to the front, unapprove, approve, spam, unspam, trash, restore, delete), merge, split, move a reply, move a topic, the state of a post, what the forums hide, the moderator tools. |
239
+ | `bbpress-profile.steps.js` | 12 | Subscribing to a topic or a forum, marking a favorite, the lists of the account's profile and removing a row from them, emptying them, the forum profile (opening it, its pages, what it shows, the forum role of an account), saving its edit form. |
240
+ | `bbpress-search.steps.js` | 7 | The forum search, its count, what its results show, the kind of a result, opening one, the page of a topic tag, a view of the forums. |
241
+ | `bbpress-admin.steps.js` | 9 | The forums, topics and replies lists of the administration, the state of a row, the actions of a row, the trash, the features of the forums' settings, the repair tools, the forum role of an account on the users screen (read and changed). |
242
+ | `bbpress-mail.steps.js` | 3 | The forums' notifications in the mail catcher: sent, not sent, and what one says. |
243
+ | `bbpress-content.steps.js` | 4 | Test content: no topic of a title, a topic by an account (with its text as a doc string), a reply by an account. |
244
+ | `bbpress-defaults.js` | | Loads the WordPress pack's steps, adds the forums' screens to its named administration screens, and keeps per scenario the moment it began and the topics its Given steps made. It registers no step. |
245
+ | `bbpress-helpers.js` | | Shared plumbing: the forums' root, what a page lists (forums, topics, posts, notices), the way to a forum and a topic, the links of a post, the session of another account, the mail catcher. It registers no step. |
246
+
247
+ Text, links, fields, buttons, dialogs, the status code and the headers of a page and the accessibility audit are webship-js's own steps (`I should see "..."`, `I fill in "Biographical Info" with "..."`, `I check "Notify me of follow-up replies via email"`); the login, the administration's screens, menus, notices and settings are the WordPress pack's (`I am a logged in user with the "moderator" user`, `I go to the "Topics" admin screen`, `the admin menu should list "Forums"`, `I should see a success notice "Settings saved."`, `the "Forum Root" setting should be "forums"`, `I save the settings`). This pack adds only what the forums decide.
248
+
249
+ ## How the steps find things and wait
250
+
251
+ - **By what a person reads.** A forum is found by the name the index shows (without the "Private: " the site puts before a private forum), a topic by its title in the forum's list, a post by its number on the page, a link of a post by its text, a field by its label, a feature of the settings by the name of its row. What the forums print the same way on every theme is the fallback, all of it inside `#bbpress-forums`: the rows of a list (`ul#bbp-forum-<id>`, `ul#bbp-topic-<id>`) and the classes the forums set on them (`status-category`, `bbp-forum-status-closed`, `bbp-forum-visibility-private`, `sticky`, `super-sticky`, `status-closed`), a post's header and body (`#post-<id>`, `.post-<id>` with `status-…`), its author and role (`.bbp-author-name`, `.bbp-author-role`), its links (`.bbp-admin-links a.bbp-topic-close-link`, …), the forms (`form#new-post`, `#bbp_topic_title`, `#bbp_reply_content`), the notices (`.bbp-template-notice`).
252
+ - **No fixed sleeps.** The steps wait on the forums' own signals:
253
+ - the pages of the forums are rendered on the server: a step that opens one waits for the page to be quiet, then reads the rows;
254
+ - a form of the forums loads a page: a step that submits waits for that page, then for the forums' answer on it, the new topic's own page, the reply under its address (`…/#post-<id>`), or the error notice above the form;
255
+ - a moderation link loads the page again, and the forums say what they did through the post itself: its status (a class of the post) and the link, which turns into its opposite; the step checks that turn;
256
+ - "Subscribe" and "Favorite" are answered in place: the forums mark the link's wrapper (`is-subscribed`, `is-favorite`) and turn its text, and the step waits for that mark; the `×` of a profile's list removes its row the same way;
257
+ - a screen of the administration keeps a timer running (its heartbeat) and is whole when it arrives: the list steps read it at once, and a row action is followed to the list and its notice;
258
+ - the mail in the mail catcher, polled until it arrives. The forums send it in the request that takes the post, so its absence is read at once.
259
+ - **Test content, made the way a person makes it.** `Given there is a topic "…" in "…" by "participant"` logs that account in (once in a run; later steps take its session over), posts through the forum's own form, and gives the scenario's own session back. `Given there is no topic "…"` is the work of the account `worldParameters.forums.moderator` names, in the topics list of the administration: to the trash, then deleted for good.
260
+ - **Failures say what was found.** `Expected the topic to have 5 post(s), but it has 3 ("Viewing 3 posts - 1 through 3 (of 3 total)").` with a hint on where to look.
261
+
262
+ ## Accounts
263
+
264
+ The suite never creates or deletes an account. Accounts are configuration: list the ones the site has in `worldParameters.users`, by a handle the scenarios use, each with its `username` and `password`, and its `email` for the notification steps (a handle stands for its address there). Each account logs in through the site's login screen (the WordPress pack's step).
265
+
266
+ ```javascript
267
+ users: {
268
+ admin: { username: 'administrator', password: process.env.WP_ADMIN_PASSWORD, email: 'administrator@example.com' },
269
+ moderator: { username: 'moderator', password: process.env.WP_MODERATOR_PASSWORD, email: 'moderator@example.com' },
270
+ participant: { username: 'participant', password: process.env.WP_PARTICIPANT_PASSWORD, email: 'participant@example.com' },
271
+ },
272
+ ```
273
+
274
+ The Given steps that make and remove test content need one more thing: `worldParameters.forums.moderator`, the handle of an account that may moderate every forum and open the topics list of the administration (a moderator or a keymaster; `moderator` by default). `worldParameters.forums.root` is where the forums start (`/forums/`, as the plugin sets it).
275
+
276
+ ## Test users
277
+
278
+ The accounts this repository's suite logs in as, exactly as `cucumber.js` lists them in `worldParameters.users` (the default values; the `WP_<HANDLE>_USER`, `WP_<HANDLE>_PASSWORD` and `WP_<HANDLE>_EMAIL` variables replace them). The build script creates them, each named after its forum role, with one password; the Workspace's bbPress plugin creates the same six.
279
+
280
+ ```json
281
+ {
282
+ "admin": { "username": "administrator", "password": "dD.123123ddd", "email": "administrator@example.com" },
283
+ "keymaster": { "username": "keymaster", "password": "dD.123123ddd", "email": "keymaster@example.com" },
284
+ "moderator": { "username": "moderator", "password": "dD.123123ddd", "email": "moderator@example.com" },
285
+ "participant": { "username": "participant", "password": "dD.123123ddd", "email": "participant@example.com" },
286
+ "spectator": { "username": "spectator", "password": "dD.123123ddd", "email": "spectator@example.com" },
287
+ "blocked": { "username": "blocked", "password": "dD.123123ddd", "email": "blocked@example.com" }
288
+ }
289
+ ```
290
+
291
+ `admin` is the site's administrator (the installer's account in the build script) and, as every administrator, a keymaster of the forums. The other five are subscribers of the site, each with the forum role it is named after: `keymaster` runs the forums (their lists, settings and tools in the administration), `moderator` moderates every topic and reply and reads the hidden forums, `participant` starts topics and replies and reads the private forums, `spectator` reads the public forums, and `blocked` gets no forum at all. They are placeholder credentials of a throwaway test site, not of any real one.
292
+
293
+ ## The test site
294
+
295
+ [`.github/scripts/build-ddev-site.sh`](.github/scripts/build-ddev-site.sh) builds the site the suite of this repository runs against, in a DDEV project of type `wordpress` with PHP 8.4 and Node.js 24 (`WORDPRESS_VERSION`, `BBPRESS_VERSION`, `PHP_VERSION` and `THEME` choose others):
296
+
297
+ - the latest WordPress, with pretty addresses, and the theme it installs with (a block theme), or the classic theme `THEME` names;
298
+ - bbPress from the plugin directory, its settings left as the plugin sets them but for two a suite cannot work with: no wait between two posts of an account (the flood protection), and no time limit on editing one's own post;
299
+ - the six accounts of [Test users](#test-users), each with its forum role;
300
+ - the test content, written by [`site/forum-site.php`](site/forum-site.php) with the forums' own functions, so the counters of every forum and topic are the ones the forums keep:
301
+
302
+ | Forum | What it holds |
303
+ | --- | --- |
304
+ | Community (a category) | General discussion and Help and support |
305
+ | General discussion | "Forum rules" (super sticky), "Welcome to the forums" (sticky, two replies), "A community garden in spring", "The spring meetup is over" (closed) |
306
+ | Help and support | "How do I change my password?", "Where do the avatars come from?", "A long conversation" (seventeen replies: two pages) |
307
+ | Showcase | sixteen topics (two pages with the super sticky one) |
308
+ | Archive (closed) | "The forums opened" |
309
+ | Members lounge (private) | "Members only: the next meetup" |
310
+ | Staff room (hidden) | "Staff only: the moderation notes" |
311
+
312
+ Topic tags: `rules`, `welcome`, `garden`, `spring`, `meetup`, `account`, `howto`, `showcase`.
313
+
314
+ CI builds it twice, see [`.github/workflows/test.yml`](.github/workflows/test.yml): on the block theme WordPress installs with and PHP 8.4 (with the assertions that must fail), and on a classic theme (Twenty Twenty-One) and PHP 8.2.
315
+
316
+ After a run that was stopped half way, `RESET_ONLY=1 SITE_DIR="$PWD/bbpress-site" bbpress-steps/.github/scripts/build-ddev-site.sh` puts the forums back as the build left them: the topics and replies of the run go, the favorites and subscriptions of the accounts too.
317
+
318
+ ## Steps
319
+
320
+ One example of each step; the JSDoc block above each definition holds five.
321
+
322
+ ### `bbpress-forums.steps.js` (17)
323
+
324
+ - `Given I am on the forum index`
325
+ - `Then the forum index should list the forum "Showcase"`
326
+ - `Then the forum "Showcase" should have 16 topics in the list`
327
+ - `Then the forum "Archive" should be closed in the list`
328
+ - `When I open the forum "General discussion"`
329
+ - `Then I should be in the forum "General discussion"`
330
+ - `Then the forum should list the topic "Welcome to the forums"`
331
+ - `Then the topic "Welcome to the forums" should be sticky in the list`
332
+ - `Then the topic "Welcome to the forums" should have 2 replies in the list`
333
+ - `Then the forum should have 4 topics`
334
+ - `Then the first topic of the forum should be "Forum rules"`
335
+ - `When I go to page 2`
336
+ - `Then I should be on page 2`
337
+ - `Then the forum breadcrumbs should be "Home", "Forums" and "Showcase"`
338
+ - `Then the forums should say "You must be logged in to reply to this topic."`
339
+ - `Then I should be able to start a topic`
340
+ - `Then I should not be allowed to open "/forums/forum/staff-room/"`
341
+
342
+ ### `bbpress-topics.steps.js` (23)
343
+
344
+ - `When I open the topic "Welcome to the forums" in "General discussion"`
345
+ - `Then I should be reading the topic "Welcome to the forums"`
346
+ - `Then the topic should have 3 posts`
347
+ - `Then post 1 should be by "keymaster"`
348
+ - `Then the author of post 1 should be a "Keymaster"`
349
+ - `Then post 1 should read "Say hello and tell us what you are working on."`
350
+ - `Then the last post should show "bold words" in bold`
351
+ - `Then the edit log of post 1 should show "Reason: Clearer title"`
352
+ - `Then the topic should be closed`
353
+ - `Then the topic should be tagged "welcome"`
354
+ - `When I start a new topic in "General discussion"`
355
+ - `When I write the topic title "Webship test topic"`
356
+ - `When I write "Webship test: the first post of the topic." in the editor`
357
+ - `When I add "bold words" to the editor with the "b" button`
358
+ - `Then the editor should contain "Webship test: the first post of the topic."`
359
+ - `When I tag the topic with "webship, test"`
360
+ - `When I choose the topic type "Sticky"`
361
+ - `When I give the edit reason "Clearer title"`
362
+ - `When I submit the post`
363
+ - `Then the editor should show the error "Your topic needs a title."`
364
+ - `When I reply to the topic with "Webship test reply."`
365
+ - `When I edit post 1`
366
+ - `Then post 1 should offer the link "Edit"`
367
+
368
+ ### `bbpress-moderation.steps.js` (12)
369
+
370
+ - `When I close the topic`
371
+ - `When I stick the topic to the front`
372
+ - `When I delete the topic permanently`
373
+ - `When I merge the topic into "Webship test topic"`
374
+ - `When I split the topic from post 3 into "Webship test split"`
375
+ - `When I move the topic to "Help and support"`
376
+ - `When I unapprove the last post`
377
+ - `When I delete the last post permanently`
378
+ - `Then the last post should be pending`
379
+ - `When I move the last post to a new topic "Webship test: moved reply"`
380
+ - `When I show the hidden posts`
381
+ - `Then I should see the moderator tools`
382
+
383
+ ### `bbpress-profile.steps.js` (12)
384
+
385
+ - `When I subscribe to the topic`
386
+ - `When I favorite the topic`
387
+ - `Then the topic should be subscribed to`
388
+ - `Then my favorites should list "Welcome to the forums"`
389
+ - `When I remove "Welcome to the forums" from my favorites`
390
+ - `Given I have no favorites`
391
+ - `When I open the forum profile of "participant"`
392
+ - `When I open "Topics Started" in the forum profile`
393
+ - `Then the forum profile should offer the page "Subscriptions"`
394
+ - `Then the forum profile should show "Forum Role: Participant"`
395
+ - `Then the forum role of "moderator" should be "Moderator"`
396
+ - `When I save my forum profile`
397
+
398
+ ### `bbpress-search.steps.js` (7)
399
+
400
+ - `When I search the forums for "marigolds"`
401
+ - `Then the search should find 2 matches`
402
+ - `Then the search results should show "A community garden in spring"`
403
+ - `Then the search result "A community garden in spring" should be a topic in "General discussion"`
404
+ - `When I open the search result "A community garden in spring"`
405
+ - `When I open the topic tag "spring"`
406
+ - `When I open the forum view "Most popular topics"`
407
+
408
+ ### `bbpress-admin.steps.js` (9)
409
+
410
+ - `Then the topics list should include "Welcome to the forums"`
411
+ - `Then the topic "The spring meetup is over" should be closed in the topics list`
412
+ - `When I close the topic "Webship test topic" from the topics list`
413
+ - `When I restore the topic "Webship test topic" from the topics trash`
414
+ - `When I turn the forum feature "Favorites" off`
415
+ - `Then the forum feature "Favorites" should be on`
416
+ - `When I run the forum repair tool "Recount topics in each forum"`
417
+ - `Then the users screen should show the forum role "Moderator" for "moderator"`
418
+ - `When I change the forum role of "spectator" to "Participant"`
419
+
420
+ ### `bbpress-mail.steps.js` (3)
421
+
422
+ - `Then a forum notification with the subject "Webship test topic" should be sent to "participant"`
423
+ - `Then no forum notification should be sent to "moderator"`
424
+ - `Then the forum notification with the subject "Webship test topic" to "participant" should contain "moderator wrote:"`
425
+
426
+ ### `bbpress-content.steps.js` (4)
427
+
428
+ - `Given there is no topic "Webship test topic"`
429
+ - `Given there is a topic "Webship test topic" in "General discussion" by "participant"`
430
+ - `Given there is a topic "Webship test topic" in "General discussion" by "participant" with:`
431
+ - `Given "moderator" replied to the topic "Webship test topic" with "Webship test reply of the moderator."`
432
+
433
+ ## Phrases shared with other packs
434
+
435
+ The phrases of a forum (a forum and its topics, a topic and its posts, a reply, the editor, moderation, the
436
+ test content) are the ones of the other forum packs, so a scenario of a forum reads the same on every system (one
437
+ `cucumber.js` profile per system; the platform packs are not meant to be loaded together). Loaded beside each of
438
+ the 40 other packs, these phrases of this pack also match one of theirs:
439
+
440
+ | Phrase of this pack | Also in |
441
+ | --- | --- |
442
+ | `I should not be allowed to open "…"` | aspnet-core, discourse, django, django-cms, payload, phpbb, spring-boot, strapi, wagtail |
443
+ | `I open the search result "…"` | docusaurus, hubspot-cms, joomla, nextcloud, phpbb |
444
+ | `I reply to the topic with "…"` | discourse, phpbb |
445
+ | `I should be reading the topic "…"` | discourse, phpbb |
446
+ | `I write "…" in the editor` | ghost, phpbb |
447
+ | `post 1 should be by "…"` | discourse, phpbb |
448
+ | `post 1 should read "…"` | discourse, phpbb |
449
+ | `the editor should contain "…"` | ghost, phpbb |
450
+ | `the search results should show "…"` | discourse, phpbb |
451
+ | `the topic should have 3 posts` | discourse, phpbb |
452
+ | `there is a topic "…" in "…" by "…"` | discourse, phpbb |
453
+ | `there is a topic "…" in "…" by "…" with:` | discourse, phpbb |
454
+ | `there is no topic "…"` | discourse, phpbb |
455
+ | `"…" replied to the topic "…" with "…"` | discourse |
456
+ | `I close the topic` | discourse |
457
+ | `I delete the last post permanently` | phpbb |
458
+ | `I delete the topic permanently` | phpbb |
459
+ | `I edit post 1` | phpbb |
460
+ | `I go to page 2` | phpbb |
461
+ | `I move the topic to "…"` | phpbb |
462
+ | `I open the forum "…"` | phpbb |
463
+ | `I open the topic "…"` | discourse |
464
+ | `I open the topic "…" in "…"` | phpbb |
465
+ | `I should be in the forum "…"` | phpbb |
466
+ | `I should be on page 2` | phpbb |
467
+ | `I should not be able to reply` | phpbb |
468
+ | `I should see the moderator tools` | phpbb |
469
+ | `I split the topic from post 3 into "…"` | phpbb |
470
+ | `I start a new topic in "…"` | phpbb |
471
+ | `I submit the post` | phpbb |
472
+ | `I subscribe to the topic` | phpbb |
473
+ | `the editor should show the error "…"` | phpbb |
474
+ | `the first topic of the forum should be "…"` | phpbb |
475
+ | `the forum should have 4 topics` | phpbb |
476
+ | `the forum should list the topic "…"` | phpbb |
477
+ | `the search should find 2 matches` | phpbb |
478
+ | `the topic should be closed` | discourse |
479
+ | `the topic should be open` | phpbb |
480
+ | `the topic should be subscribed to` | phpbb |
481
+
482
+ The session phrases every platform pack has (`I am a logged in user with the "…" user`, `I log out`, `I should be
483
+ logged in`) are not in this table: here they are the WordPress pack's, which this pack loads.
484
+
485
+ None of this pack's phrases matches a step of webship-js, of the WordPress pack it loads, or of the other
486
+ extension of that pack (WooCommerce), so a site with a shop and forums loads both extensions in one profile. None
487
+ matches a phrase of the component pack (Bootstrap), of the Diffy pack or of the Shopify pack either, which can be
488
+ loaded beside this one.
489
+
490
+ ## Testing this package
491
+
492
+ ```bash
493
+ npm ci
494
+ npm run test:examples # every step's JSDoc examples match it and nothing else; every feature step resolves
495
+ npm run test:paths # a feature named on the command line runs alone
496
+ npx cucumber-js --dry-run
497
+ SITE_DIR="$PWD/../bbpress-site" .github/scripts/build-ddev-site.sh
498
+ npx cucumber-js # the whole suite
499
+ npm run test:must-fail # the assertions that must fail, each with its message and a hint
500
+ THEME=twentytwentyone PHP_VERSION=8.2 SITE_DIR="$PWD/../bbpress-site-classic" .github/scripts/build-ddev-site.sh
501
+ npx cucumber-js
502
+ ```
503
+
504
+ The second build makes a project of the same name: remove the first one before it (`ddev delete -Oy bbpresssteps`).
505
+
506
+ ## How the steps were written
507
+
508
+ Every step was written from a round of manual testing of the real local site in the browser first: each page it touches was opened as the account the step works as, its lists, labels and messages noted, and the signal it gives while it works found (the class a moderation link leaves on a post, the mark of a subscription, the address a reply lands on). The failures of the first runs went back to the browser before the step changed: a forum's address that answers "not found" until the rewrite rules are written again, a private forum whose heading says "Private:" twice, a pending topic a moderator does not see in its forum until it follows "(+1 hidden)", a spammed topic that lives in a view of its own in the administration, a row in the trash whose title carries a hidden "(Child of …)", an edit that leaves no line in the log when only the topic's status changed, and the author of a closed topic who still gets the reply form although the forums refuse what it sends.
509
+
510
+ ## License
511
+
512
+ MIT, see [LICENSE](LICENSE).
513
+
514
+ ## Logo
515
+
516
+ The logo in this README is the bbPress mark the plugin itself ships (`includes/admin/assets/icons/logo.svg` of bbPress 2.6.22, GPL-2.0-or-later), with its fill set to black; it stays under that licence, and is not part of the npm package. Simple Icons, the source of the other packs' logos, has none for bbPress. The bbPress name and logo belong to their owner; this pack is not affiliated with or endorsed by them.
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@webship-js/bbpress-steps",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.1",
4
+ "description": "Cucumber step definitions for forums on WordPress with bbPress, a plugin for webship-js (Playwright and Cucumber): the forum index, a forum and its topics, a topic and its posts, the topic and reply forms (tags, formatting, an edit with its reason), subscriptions and favorites, the forum profile, the forum search, topic tags and views, moderation (close, stick, approve, spam, trash, merge, split, move), what each forum role may do, the forums' administration screens and settings, and the notification e-mails. It brings @webship-js/wordpress-steps along for the login and the administration area.",
5
+ "main": "tests/step-definitions/bbpress-defaults.js",
6
+ "files": [
7
+ "tests/step-definitions/",
8
+ "tests/features/",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
12
+ "scripts": {
13
+ "test": "cucumber-js --config cucumber.js",
14
+ "test:dry": "cucumber-js --config cucumber.js --dry-run",
15
+ "test:examples": "node tests/check-examples.js",
16
+ "test:paths": "node tests/check-paths.js",
17
+ "test:must-fail": "node tests/check-must-fail.js",
18
+ "test:chromium": "BROWSER=chromium cucumber-js --config cucumber.js",
19
+ "test:firefox": "BROWSER=firefox cucumber-js --config cucumber.js",
20
+ "test:webkit": "BROWSER=webkit cucumber-js --config cucumber.js",
21
+ "test:headed": "HEADLESS=false cucumber-js --config cucumber.js",
22
+ "generate-reports": "generate-reports",
23
+ "test:fast": "SLOW_MO=0 cucumber-js --config cucumber.js"
24
+ },
25
+ "keywords": [
26
+ "webship-js",
27
+ "bbpress",
28
+ "wordpress",
29
+ "forum",
30
+ "forums",
31
+ "moderation",
32
+ "cucumber",
33
+ "cucumber-js",
34
+ "playwright",
35
+ "bdd",
36
+ "gherkin",
37
+ "step-definitions",
38
+ "e2e-testing"
39
+ ],
40
+ "author": "Webship.co",
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/webship/bbpress-steps.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/webship/bbpress-steps/issues"
48
+ },
49
+ "homepage": "https://github.com/webship/bbpress-steps#readme",
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "engines": {
54
+ "node": ">= 24.0"
55
+ },
56
+ "dependencies": {
57
+ "@webship-js/wordpress-steps": "^2.2.4"
58
+ },
59
+ "peerDependencies": {
60
+ "webship-js": "^2.0.16"
61
+ },
62
+ "devDependencies": {
63
+ "tsx": "^4.23.0",
64
+ "webship-js": "^2.0.16"
65
+ },
66
+ "overrides": {
67
+ "@cucumber/cucumber": "^12"
68
+ }
69
+ }