@webship-js/django-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,593 @@
1
- # Temporary Holding Version
1
+ <p align="center"><img src="https://raw.githubusercontent.com/webship/django-steps/2.0.x/assets/logo.svg" alt="Django 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
+ # django-steps
4
+
5
+ [![Test](https://github.com/webship/django-steps/actions/workflows/test.yml/badge.svg)](https://github.com/webship/django-steps/actions/workflows/test.yml)
6
+
7
+ Cucumber step definitions for testing the Django admin, 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/django-steps` covers what the admin of every Django project shows,
12
+ whatever its models:
13
+
14
+ - **the session**: the admin login by a handle of the users registry or through
15
+ the form, its refusal, logging out, who is signed in;
16
+ - **the index**: its apps and models, what an account may do with each (add,
17
+ change, view), the recent actions, the breadcrumbs, the navigation sidebar and
18
+ its filter, the colour theme;
19
+ - **the change list**: its columns and cells, the search and its count, the
20
+ filters of the sidebar and their counts, sorting by a column, the date
21
+ drill-down, the pages and "Show all", selecting rows (on a page, across all
22
+ pages), running an action, and the "Delete selected" confirmation;
23
+ - **the add and change forms**: every kind of field by its label (a text, a
24
+ list, a box, a date and time with the "Today" and "Now" shortcuts, an
25
+ autocomplete field, a two-list selector), read-only fields, the sections and
26
+ the ones that fold, the inline rows (in a table or stacked: add, remove, fill,
27
+ read), the three save buttons, the messages after saving, the errors of a
28
+ refused form, and the view-only form;
29
+ - **deleting**: the delete confirmation with the related objects it takes,
30
+ confirming or going back, the refusal when a protected relation keeps the
31
+ object, and **the history** of an object's changes;
32
+ - **the password change** and its refusals;
33
+ - **users and groups**: an account's status and groups, a group's permissions,
34
+ and the pages an account is refused;
35
+ - **test objects**: a scenario makes the objects it needs through the admin's own
36
+ forms and the steps delete them after it, whatever happens in it.
37
+
38
+ No step phrase names the platform: a scenario reads `When I choose "Science" in
39
+ the "Category" autocomplete` and `Then the delete confirmation should list
40
+ "Choice: Yes"`.
41
+
42
+ CI builds a real site with [DDEV](https://ddev.com) on the runner (a plain
43
+ project made with `django-admin startproject`, the polls app of the official
44
+ tutorial, PostgreSQL 16), at the current release line, Django 6.1, and the
45
+ long-term-support line, Django 5.2, and runs the whole suite against it twice on
46
+ every push and pull request, then the assertions that must fail; see
47
+ [`.github/workflows/test.yml`](.github/workflows/test.yml).
48
+
49
+ ## From nothing to a green run
50
+
51
+ What the machine needs: Docker, [DDEV](https://ddev.com), git, python3, and
52
+ Node.js 24 or later with npm. Python, Django, PostgreSQL and the site's server
53
+ run in DDEV's containers.
54
+
55
+ **1. The site.** The pack's own build script (the one CI runs) makes the site in
56
+ a generic DDEV project (DDEV has no project type for Django): Python 3.13 in the
57
+ web image, a project made with `django-admin startproject mysite`, the polls app
58
+ of the official tutorial registered in the admin, its sample data, PostgreSQL 16,
59
+ the site served by the web container, and the three accounts of
60
+ [Test users](#test-users). It takes about two minutes the first time
61
+ (`DJANGO_VERSION=5.2` builds the long-term-support line).
62
+
63
+ ```bash
64
+ git clone https://github.com/webship/django-steps.git
65
+ SITE_DIR="$PWD/django-site" django-steps/.github/scripts/build-ddev-site.sh
66
+ ```
67
+
68
+ The site answers at `https://djangosteps.ddev.site`, its admin at `/admin/`.
69
+ Its accounts are `administrator`, `editor` and `viewer`, each with the password
70
+ `dD.123123ddd` (step 3 names them).
71
+
72
+ In the [Webship Workspace](https://github.com/webship/workspace), its Django
73
+ plugin builds the same site instead, in a sites folder of the workspace (`dev/`
74
+ here, the one `--with-needs` adds to a new workspace; `test/`, `sandboxes/` and
75
+ `demos/` work the same):
76
+
77
+ ```bash
78
+ bash core/scripts/plugins.sh --require django --with-needs
79
+ bash core/scripts/plugins.sh --activate django --with-needs
80
+ bash core/scripts/plugins.sh --install django
81
+ bash dev/cmd-django-project.sh djsite --install --add-users --polls
82
+ ```
83
+
84
+ That site answers at `https://djsite.ddev.site`. `--polls` adds the polls app
85
+ and its sample data (the features of this pack need them). Its accounts are the
86
+ plugin's, the same three with the workspace's shared password `dD.123123ddd`:
87
+ `administrator`, `editor` and `viewer`. The workspace's own account is a
88
+ superuser too; the suite does not use it.
89
+
90
+ **2. A test project.**
91
+
92
+ ```bash
93
+ mkdir django-tests && cd django-tests
94
+ npm init -y
95
+ npm install --save-dev webship-js @webship-js/django-steps
96
+ npx init-webship-js
97
+ rm tests/features/check-homepage.feature
98
+ ```
99
+
100
+ `npx init-webship-js` writes `cucumber.js`, `playwright.config.ts`, the `tests/`
101
+ folders with a first feature and the `npm test` scripts, and installs Chromium.
102
+ npm usually runs it already when it installs webship-js; a second run changes
103
+ nothing. Its first feature opens the site's home page, which a plain project does
104
+ not have (the browser logs its 404): the last line removes it.
105
+
106
+ **3. `cucumber.js`.** Replace the file with the wiring of the pack: the step
107
+ files of webship-js and of the pack, the tags that keep the assertions that must
108
+ fail out of a normal run, the address of the site, the browser messages that are
109
+ no error of the site, and the accounts (the JSON of [Test users](#test-users)).
110
+ The first lines are the starter's own: a feature named on the command line runs
111
+ alone (step 5).
112
+
113
+ ```javascript
114
+ // A feature file or a scenario (file:line) named on the command line runs alone:
115
+ // cucumber-js 12 would add it to the paths below, so `paths` is left empty then.
116
+ const OPTIONS_WITH_A_VALUE = new Set([
117
+ '-c', '--config', '-f', '--format', '--format-options', '--i18n-keywords',
118
+ '-i', '--import', '-l', '--loader', '--language', '--name', '--order',
119
+ '-p', '--profile', '--parallel', '--plugin', '--plugin-options',
120
+ '-r', '--require', '--require-module', '--retry', '--retry-tag-filter',
121
+ '--shard', '-t', '--tags', '--world-parameters',
122
+ ]);
123
+
124
+ function commandLinePaths() {
125
+ if (!/cucumber(-js|\.js)?$/.test(String(process.argv[1] || ''))) return [];
126
+ const args = process.argv.slice(2);
127
+ const paths = [];
128
+ for (let i = 0; i < args.length; i += 1) {
129
+ if (args[i].startsWith('-')) {
130
+ if (OPTIONS_WITH_A_VALUE.has(args[i])) i += 1;
131
+ } else {
132
+ paths.push(args[i]);
133
+ }
134
+ }
135
+ return paths;
136
+ }
137
+
138
+ module.exports = {
139
+ default: {
140
+ requireModule: ['tsx/cjs'],
141
+ require: [
142
+ 'node_modules/webship-js/tests/step-definitions/**/*.js',
143
+ 'node_modules/@webship-js/django-steps/tests/step-definitions/**/*.js',
144
+ 'tests/step-definitions/**/*.js',
145
+ ],
146
+ paths: commandLinePaths().length ? [] : ['tests/features/**/*.feature'],
147
+ // Work in progress and the assertions that must fail stay out of a normal run.
148
+ tags: 'not @wip and not @must-fail',
149
+ format: ['@cucumber/pretty-formatter', 'json:tests/reports/cucumber_report.json'],
150
+ worldParameters: {
151
+ launchUrl: process.env.LAUNCH_URL || 'https://djangosteps.ddev.site',
152
+ // Where the admin is on the site, and the account the test-object steps work as (a superuser of `users`).
153
+ adminPath: '/admin/',
154
+ dataAdmin: 'administrator',
155
+ // No error of the site: the 5.2 admin's unload listener, and a request lost when the machine's network changed.
156
+ javascript: { mode: 'warn', levels: ['error'], ignore: 'Permissions policy violation: unload is not allowed|net::ERR_NETWORK_CHANGED', beforeScenario: false, afterScenario: true },
157
+ minWaitTime: { page: 3000, before_scenario: 0, after_scenario: 0, before_step: 0, after_step: 0 },
158
+ users: {
159
+ administrator: { username: 'administrator', password: 'dD.123123ddd', email: 'administrator@example.com' },
160
+ editor: { username: 'editor', password: 'dD.123123ddd', email: 'editor@example.com' },
161
+ viewer: { username: 'viewer', password: 'dD.123123ddd', email: 'viewer@example.com' },
162
+ },
163
+ },
164
+ },
165
+ };
166
+ ```
167
+
168
+ On a site from the Webship Workspace (step 1) the accounts are the same; its
169
+ address goes in `LAUNCH_URL` (step 5).
170
+
171
+ **4. A first feature**, `tests/features/first-run.feature`:
172
+
173
+ ```gherkin
174
+ Feature: First run
175
+ Scenario: The editor logs in to the admin
176
+ Given I am not logged in
177
+ When I log in as "editor" with the login form
178
+ Then I should be logged in as "editor"
179
+
180
+ Scenario: The editor finds questions in the list
181
+ Given I am a logged in user with the "editor" user
182
+ And I am on the "Questions" list
183
+ When I search the list for "train"
184
+ Then the search should find 2 results of 24
185
+ ```
186
+
187
+ The second scenario reads the sample questions of the polls app that both ways of
188
+ step 1 make.
189
+
190
+ **5. Run it.** Set `LAUNCH_URL` to the address of the site:
191
+ `https://djangosteps.ddev.site` for the build script's site,
192
+ `https://djsite.ddev.site` for the Workspace's.
193
+
194
+ ```bash
195
+ LAUNCH_URL=https://djangosteps.ddev.site npm test
196
+ ```
197
+
198
+ A green first run prints every step, then the summary (the two scenarios above,
199
+ passed) and the HTML report it wrote:
200
+
201
+ ```
202
+ 2 scenarios (2 passed)
203
+ 7 steps (7 passed)
204
+ 0m03.000s (executing steps: 0m03.000s)
205
+ [webship-js] HTML report → …/django-tests/tests/reports/cucumber_report.html
206
+ ```
207
+
208
+ One feature runs alone when the command line names it (a scenario too, with
209
+ its line):
210
+
211
+ ```bash
212
+ LAUNCH_URL=https://djangosteps.ddev.site npx cucumber-js tests/features/first-run.feature
213
+ ```
214
+
215
+ From there, copy the features of [`tests/features/`](tests/features/) (they
216
+ also ship in the package, under
217
+ `node_modules/@webship-js/django-steps/tests/features/`): together they use
218
+ every step of the pack. Each makes its own test objects and deletes them after
219
+ it. They run as they are on the site of either way of step 1.
220
+
221
+ ### What the suite tests
222
+
223
+ The features of this repository run every step of the pack against the test
224
+ site, twice in a row in CI on every change, then the assertions that must fail:
225
+ each account logging in through the form and taking its session over, a refused
226
+ login, a visitor sent to the login page, logging out; the index as each account
227
+ sees it (the apps, the models, add, change or view), the recent actions, the
228
+ breadcrumbs, the navigation sidebar's filter and the colour theme kept from page
229
+ to page; the list of questions with its columns and cells, a search that finds
230
+ two and one that finds none, sorting both ways, a filter and its counts, the date
231
+ drill-down from a year to a month and back, the pages and "Show all"; the
232
+ selection of rows and across all pages, the "Delete selected" confirmation and
233
+ going back, an action without selected rows, the site's own action and the
234
+ deletion of two questions; the add form's sections, folding section, read-only
235
+ field and inline rows, a question added with every kind of field, the "Today" and
236
+ "Now" shortcuts, "Save and add another", a change saved, the autocomplete field
237
+ and the two-list selector, inline rows added, removed and deleted with the form,
238
+ a refused form and a date the form cannot read, a question added in a stacked
239
+ inline row of its category; a deletion with its related objects, going back from
240
+ one, a category a protected relation keeps, the history of an object, a deletion
241
+ in one step; the password change and four of its refusals; the accounts' status
242
+ and groups, the groups' permissions, the users list searched and filtered, a
243
+ group given its permissions with the two-list selector, a group name in use; the
244
+ view-only account with its read-only form and its refusals; and the landmarks of
245
+ the login page, the index and a list.
246
+
247
+ Every object a scenario makes is deleted after it, and a changed password is set
248
+ back: the suite leaves the site as it found it.
249
+
250
+ Not tested: the admin's popups (the "+" beside a related field opens the add form
251
+ of the other model in a window), the calendar and clock popups (the steps type the
252
+ date and time, or use the shortcuts), `list_editable` (no model of the test site
253
+ edits in its list), the password reset of the admin (a project wires it up itself),
254
+ a custom admin site other than the default one, and an admin in another language
255
+ than English (a few steps read the admin's English words: the "Clear all filters"
256
+ link and "Show counts").
257
+
258
+ ## Requirements
259
+
260
+ - Node.js 24 or later
261
+ - A webship-js 2.0 test project (webship-js 2.0.16 or later)
262
+ - A Django project with the admin (`django.contrib.admin`), 5.2 or later, with
263
+ staff accounts on it for the suite (a superuser among them, for the test-object
264
+ steps)
265
+
266
+ ## Install
267
+
268
+ ```bash
269
+ npm install --save-dev @webship-js/django-steps
270
+ ```
271
+
272
+ ## How the steps find things and wait
273
+
274
+ - **By what a person reads.** A model by its plural name as the index shows it
275
+ ("Questions"), an object by its text in the first column of its list, a field by
276
+ its label (the colon left out), a field of an inline table row by its column, a
277
+ filter by its title ("By category"), a column by its heading, a section by its
278
+ heading, an action by its text. The admin's stable hooks are the fallback: the
279
+ classes it puts on the body of each page (`change-list`, `change-form`,
280
+ `delete-confirmation`, `dashboard`), the ids of its parts (`#result_list`,
281
+ `#changelist-filter`, `#searchbar`, `#action-toggle`, `#user-tools`), and the
282
+ classes of its links (`addlink`, `changelink`, `viewlink`, `historylink`,
283
+ `deletelink`).
284
+ - **No fixed sleeps.** The admin draws its pages on the server: an action is a
285
+ page load, and the steps wait for it. The widgets that work in the browser are
286
+ set up by the admin's scripts when the page has loaded, and the steps wait for
287
+ that: the autocomplete fields (their box drawn) and the two-list selectors (their
288
+ "available" list drawn). The autocomplete field waits for the answer of the
289
+ admin's autocomplete request to the typed text; the inline rows, the selectors,
290
+ the folding sections and the action counter are checked until they show the
291
+ change.
292
+ - **The two release lines.** The steps read what Django 5.2 and 6.1 both draw:
293
+ the paginator's current page (`aria-current` on 6.1, `.this-page` on 5.2), the
294
+ action button ("Run" on 6.1, "Go" on 5.2) by its name, a field's label whether
295
+ it is a `label` or the `legend` of the field's own fieldset (6.1 draws the date
296
+ and time and the many-to-many fields so).
297
+ - **A folded section opens** when a step sets a field in it, as a person opens it
298
+ first.
299
+ - **A cut request says so.** When the browser shows its own error page
300
+ (`chrome-error://`, a network change on the machine aborted the request), the
301
+ step says that the request was cut before the site answered, with a hint to run
302
+ the scenario again, instead of blaming the scenario. A login is sent again once.
303
+ - **Failures say what was found.** `The "By category" filter offers no "History".
304
+ It offers: "All", "Food", "Music", …` with a hint on where to look.
305
+
306
+ ## Accounts
307
+
308
+ The suite never creates or deletes an account: the test-object steps refuse to
309
+ make or delete one in the "Users" list. Accounts are configuration: list the ones
310
+ the site has in `worldParameters.users`, by a handle the scenarios use, each with
311
+ its `username` and `password`. `worldParameters.dataAdmin` names the handle of a
312
+ superuser: the test-object steps make and delete the test objects as that account,
313
+ through the admin's own forms, in a session of their own (the browser's session is
314
+ never touched), and set a password a scenario changed back.
315
+
316
+ An account that logged in once keeps its session for the rest of the run
317
+ (`reuseSessions: false` turns it off); a logout ends it.
318
+
319
+ ## Test users
320
+
321
+ The accounts this repository's suite logs in as, exactly as `cucumber.js` lists
322
+ them in `worldParameters.users` (the default values; the `<HANDLE>_USERNAME`,
323
+ `<HANDLE>_PASSWORD` and `<HANDLE>_EMAIL` variables replace them). The build
324
+ script creates them; the Workspace's Django plugin creates the same three.
325
+
326
+ ```json
327
+ {
328
+ "administrator": { "username": "administrator", "password": "dD.123123ddd", "email": "administrator@example.com" },
329
+ "editor": { "username": "editor", "password": "dD.123123ddd", "email": "editor@example.com" },
330
+ "viewer": { "username": "viewer", "password": "dD.123123ddd", "email": "viewer@example.com" }
331
+ }
332
+ ```
333
+
334
+ `administrator` is a superuser; `editor` is staff, in the group Editors, which
335
+ may add, change, delete and view the objects of the project's own apps (the polls);
336
+ `viewer` is staff, in the group Viewers, which may only view them. They are
337
+ placeholder credentials of a throwaway test site, not of any real one.
338
+
339
+ ## A test site
340
+
341
+ [`.github/scripts/build-ddev-site.sh`](.github/scripts/build-ddev-site.sh)
342
+ builds the site the suite of this repository runs against, in a generic DDEV
343
+ project with PostgreSQL 16 and Node.js 24:
344
+
345
+ - Python in the web image ([uv](https://docs.astral.sh/uv/) and the Python it
346
+ installs, 3.13 by default: the image's own Python is too old for Django 6.1 on
347
+ some releases of DDEV), and the packages in a virtual environment of the project;
348
+ - `django-admin startproject mysite`, with Django of the line `DJANGO_VERSION`
349
+ names (6.1 by default, 5.2 the long-term-support line) and the PostgreSQL driver;
350
+ - the settings of the container (`mysite/site_settings.py`, imported at the end of
351
+ `settings.py`): the hosts, the proxy, the database, the mail catcher, and
352
+ `DEBUG` off, as in production (a missing page is the 404 page, a refusal the 403
353
+ page);
354
+ - the polls app of the official tutorial (parts 1 to 8), registered in the admin
355
+ with what most projects use, added to the tutorial's admin: fieldsets (one that
356
+ folds), the inline choices (a table), `list_display`, `list_filter`,
357
+ `search_fields`, `date_hierarchy`, `list_per_page = 10`, an action ("Reset the
358
+ votes of the selected questions"), a category (an autocomplete field, a stacked
359
+ inline of its questions, a protected relation), tags (a two-list selector) and
360
+ a read-only field ("Total votes");
361
+ - its sample data: 5 categories, 4 tags and 24 questions with their choices, from
362
+ 2025 and 2026 (the tutorial's "What's up?" among them);
363
+ - the site served by the web container (`manage.py runserver --insecure`, which
364
+ serves the static files with `DEBUG` off), the router sending the project's
365
+ address to it;
366
+ - the three accounts.
367
+
368
+ [`site/django-site.py`](site/django-site.py) writes all of it: the same script
369
+ the Webship Workspace's Django plugin runs. Run again with `ACCOUNTS_ONLY=1` and
370
+ the same `SITE_DIR`, the build script gives the accounts back their password,
371
+ address, staff status and group (after a run that was stopped half way).
372
+
373
+ The polls app is the official tutorial's, from the Django documentation, under its
374
+ BSD licence (see [`site/POLLS-LICENSE`](site/POLLS-LICENSE)); what this pack adds
375
+ to it is marked in the script.
376
+
377
+ ## Steps
378
+
379
+ 106 steps in 8 files, every one with five examples in its JSDoc (`npm run test:examples` checks them).
380
+
381
+ | File | Steps | Covers |
382
+ | --- | --- | --- |
383
+ | `django-session.steps.js` | 9 | The session: logging in by a handle or through the form, a refused login, a visitor, logging out, who is signed in, the login page. |
384
+ | `django-admin.steps.js` | 15 | The index (apps, models, add/change/view), a list by a model's name, the recent actions, the breadcrumbs, the navigation sidebar, the colour theme, the pages an account is refused. |
385
+ | `django-list.steps.js` | 29 | The change list: rows, columns, cells, the search, the count, sorting, the filters and their counts, the date drill-down, the pages, the selection, the actions. |
386
+ | `django-forms.steps.js` | 26 | The add and change forms: opening them, every kind of field by its label, read-only fields, sections, the autocomplete field, the two-list selector, saving, messages, errors, the view-only form. |
387
+ | `django-inlines.steps.js` | 8 | Inline rows, in a table or stacked: how many, adding, removing, marking for deletion, setting and reading a field, what they list. |
388
+ | `django-history.steps.js` | 9 | The delete confirmation (one object or the selected ones), confirming, going back, a refused deletion, a deletion in one step, the history page. |
389
+ | `django-accounts.steps.js` | 7 | The password change and its refusals; an account's status and groups; a group's permissions. |
390
+ | `django-data.steps.js` | 3 | Test objects made through the add form and deleted after the scenario; an object that must not be there; a check as the data administrator. |
391
+ | `django-helpers.js` | | Shared plumbing: the addresses of the admin, the waits on its page loads and widgets, the users registry and the session cache, the fields by their labels, the list, the inlines, the cut request, the test-data client. It registers no step. |
392
+
393
+ Text, links, buttons, the status code of a page and the accessibility checks are webship-js's own steps (`I should see "..."`, `I click "Delete"`, `the page should have a main landmark`); this pack adds what the admin decides.
394
+
395
+ ### `django-session.steps.js` (9)
396
+
397
+ - `Given I am a logged in user with the "editor" user`
398
+ - `When I log in as "editor" with the login form`
399
+ - `When I log in with the user name "nobody" and the password "Wrong-password-1"`
400
+ - `Then the login should be refused with "Please enter the correct username and password for a staff account."`
401
+ - `Given I am not logged in`
402
+ - `When I log out`
403
+ - `Then I should be logged in as "editor"`
404
+ - `Then I should be logged in`
405
+ - `Then I should be on the admin login page`
406
+
407
+ ### `django-admin.steps.js` (15)
408
+
409
+ - `Given I am on the admin index`
410
+ - `Then the admin index should list the app "Polls"`
411
+ - `Then the app "Polls" should list the model "Questions"`
412
+ - `Then I should be able to add "Questions"`
413
+ - `When I open the "Questions" list`
414
+ - `Then I should be on the "Questions" list`
415
+ - `Then my recent actions should list "Recent action question"`
416
+ - `Then the breadcrumbs should read "Home › Polls › Questions"`
417
+ - `When I follow "Polls" in the breadcrumbs`
418
+ - `When I filter the navigation sidebar with "quest"`
419
+ - `Then the navigation sidebar should show "Questions"`
420
+ - `When I open "Tags" from the navigation sidebar`
421
+ - `When I switch the admin theme to "dark"`
422
+ - `Then the admin theme should be "dark"`
423
+ - `Then I should not be allowed to open "/admin/auth/user/"`
424
+
425
+ ### `django-list.steps.js` (29)
426
+
427
+ - `When I search the list for "train"`
428
+ - `Then the search should find 2 results`
429
+ - `Then the list should show "Which river is the longest?"`
430
+ - `Then the list should have 10 rows`
431
+ - `Then the list should count 24 questions`
432
+ - `Then the list columns should be "Question text", "Date published", "Category", "Published recently?"`
433
+ - `Then the "Which river is the longest?" row should show "Science" in the "Category" column`
434
+ - `Then the first row of the list should be "What's up?"`
435
+ - `Then "What's up?" should come before "Which fruit do you eat most?" in the list`
436
+ - `When I sort the list by "Date published"`
437
+ - `Then the list should be sorted by "Date published" in ascending order`
438
+ - `When I choose "Science" in the "By category" filter`
439
+ - `Then the "By category" filter should be set to "Science"`
440
+ - `When I clear all filters`
441
+ - `When I show the filter counts`
442
+ - `Then the "By category" filter should count 5 for "Science"`
443
+ - `When I choose "2025" in the date drill-down`
444
+ - `Then the date drill-down should offer "2025"`
445
+ - `When I go to page 2 of the list`
446
+ - `Then the list should be on page 2`
447
+ - `Then the list should have 3 pages`
448
+ - `When I show all rows of the list`
449
+ - `When I select "Which river is the longest?" in the list`
450
+ - `When I select all rows on the page`
451
+ - `When I select everything in the list`
452
+ - `When I clear the selection`
453
+ - `Then the selection should read "2 of 10 selected"`
454
+ - `Then the list should offer the action "Delete selected questions"`
455
+ - `When I run the action "Delete selected questions"`
456
+
457
+ ### `django-forms.steps.js` (26)
458
+
459
+ - `When I open the add form of "Questions"`
460
+ - `When I open "Which river is the longest?" from the list`
461
+ - `When I open "What's up?" in the "Questions" list`
462
+ - `When I set "Question text" to "Who is there?"`
463
+ - `When I set these fields:`
464
+ - `Then "Question text" should be set to "Who is there?"`
465
+ - `Then "Total votes" should be read-only`
466
+ - `Then the form should have the section "Classification"`
467
+ - `Then the section "Classification" should have the field "Category"`
468
+ - `When I open the section "Date information"`
469
+ - `Then the section "Date information" should be closed`
470
+ - `When I type "Sci" in the "Category" autocomplete`
471
+ - `Then the "Category" autocomplete should offer "Science"`
472
+ - `When I choose "Science" in the "Category" autocomplete`
473
+ - `When I choose "Fun" in the "Tags" selector`
474
+ - `When I choose all in the "Tags" selector`
475
+ - `When I filter the available "Tags" with "Fu"`
476
+ - `Then the "Tags" selector should have "Fun" chosen`
477
+ - `When I save the form`
478
+ - `Then the form should be saved`
479
+ - `Then I should see the success message "The question “What is new?” was added successfully."`
480
+ - `Then the field "Question text" should have the error "This field is required."`
481
+ - `Then the form should show the error "Please correct the errors below."`
482
+ - `Then the form should have no errors`
483
+ - `Then I should see the "Add question" form`
484
+ - `Then the form should be read-only`
485
+
486
+ ### `django-inlines.steps.js` (8)
487
+
488
+ - `Then the "Choices" inline should have 3 rows`
489
+ - `When I add a row to the "Choices" inline`
490
+ - `When I remove row 4 of the "Choices" inline`
491
+ - `Then row 2 of the "Choices" inline should be marked for deletion`
492
+ - `When I set "Choice text" to "Yes" in row 1 of the "Choices" inline`
493
+ - `When I fill in the "Choices" inline:`
494
+ - `Then row 1 of the "Choices" inline should have "Yes" in "Choice text"`
495
+ - `Then the "Choices" inline should list "Yes"`
496
+
497
+ ### `django-history.steps.js` (9)
498
+
499
+ - `Then the delete confirmation should list "Question: Delete test question"`
500
+ - `Then the delete confirmation should count "Questions: 1"`
501
+ - `When I confirm the deletion`
502
+ - `When I cancel the deletion`
503
+ - `Then the deletion should be refused`
504
+ - `When I delete "Delete test question" from the "Questions" list`
505
+ - `When I open the history`
506
+ - `Then the history should list "Added."`
507
+ - `Then the history should have 1 entry`
508
+
509
+ ### `django-accounts.steps.js` (7)
510
+
511
+ - `When I change my password to "Changed-pass-2026!"`
512
+ - `When I try to change my password with the old password "Not-the-password-1" and the new passwords "Changed-pass-2026!" and "Changed-pass-2026!"`
513
+ - `Then my password should be changed`
514
+ - `Then the password change should be refused with "Your old password was entered incorrectly. Please enter it again."`
515
+ - `Then the user "editor" should be staff`
516
+ - `Then the user "editor" should be in the "Editors" group`
517
+ - `Then the "Editors" group should have the "Polls | question | Can change question" permission`
518
+
519
+ ### `django-data.steps.js` (3)
520
+
521
+ - `Given there is no "Data step question" in the "Questions" list`
522
+ - `Given there is a "Data step question" in the "Questions" list with:`
523
+ - `Then there should be a "Data step question" in the "Questions" list`
524
+
525
+ ## Phrases shared with other packs
526
+
527
+ The session phrases are the ones every platform pack has, so a feature reads
528
+ the same on every system (one cucumber.js profile per system; the platform packs
529
+ are not meant to be loaded together). Loaded beside each of the 26 published
530
+ packs, these phrases of this pack also match one of theirs:
531
+
532
+ | Phrase of this pack | Also in |
533
+ | --- | --- |
534
+ | `I am a logged in user with the "editor" user` | codeigniter, django-cms, drupal-core, joomla, laravel, mediawiki, odoo, symfony, typo3, wordpress |
535
+ | `I am not logged in` | django-cms, drupal-core, joomla, odoo, typo3, wordpress |
536
+ | `I log out` | codeigniter, django-cms, drupal-core, laravel, mediawiki, odoo, symfony, typo3, wordpress |
537
+ | `I should be logged in` / `I should be logged in as "editor"` | backdrop-cms, codeigniter, django-cms, drupal-core, laravel, mediawiki, odoo, symfony, typo3, wordpress |
538
+ | `I log in as "editor" with the login form` | codeigniter, laravel, mediawiki, symfony |
539
+ | `I log in with the user name "…" and the password "…"`, `the login should be refused with "…"` | mediawiki |
540
+ | `I should be on the admin login page` | joomla |
541
+ | `I should see the success message "…"` | codeigniter, drupal-core, jira, joomla, magento, prestashop, symfony, woocommerce |
542
+ | `the user "editor" should be staff`, `the "Editors" group should have the "…" permission`, `I should not be allowed to open "…"` | django-cms |
543
+ | `the user "editor" should be in the "Editors" group` | django-cms, joomla |
544
+ | `I search the list for "…"` | joomla |
545
+ | `I sort the list by "…"`, `the first row of the list should be "…"` | ghost, prestashop |
546
+ | `the list should have 3 pages`, `I go to page 2 of the list`, `the list should be on page 2` | ghost, symfony |
547
+ | `the list should have 10 rows` | prestashop |
548
+ | `I save the form` | magento, odoo |
549
+ | `I confirm the deletion` | drupal-core |
550
+ | `I clear all filters` | shopify |
551
+ | `the search should find 2 results` | backdrop-cms, squarespace |
552
+ | `the form should show the error "…"` | squarespace |
553
+
554
+ None matches a webship-js step, and none matches a phrase of the component
555
+ pack (Bootstrap), which can be loaded beside this one.
556
+
557
+ The django CMS pack (`@webship-js/django-cms-steps`) works on the same admin, with
558
+ the CMS toolbar on top of it. Eight of its phrases are this pack's (the session,
559
+ an account's status and groups, a group's permissions, a refused address). Its
560
+ admin steps would hold on this pack's: django CMS serves the admin under a
561
+ language prefix, which `worldParameters.adminPath` (`/en/admin/`) gives.
562
+
563
+ ## Testing this package
564
+
565
+ ```bash
566
+ npm ci
567
+ npm run test:examples # every step's JSDoc examples match it and nothing else; every feature step resolves
568
+ npm run test:paths # a feature named on the command line runs alone
569
+ npx cucumber-js --dry-run
570
+ SITE_DIR="$PWD/../django-site" .github/scripts/build-ddev-site.sh
571
+ npx cucumber-js # the whole suite
572
+ npm run test:must-fail # the assertions that must fail, each with its message and a hint
573
+ ```
574
+
575
+ ## How the steps were written
576
+
577
+ Every step was written from a round of manual testing of a real local site in
578
+ the browser first, on both release lines: each screen it touches was opened, its
579
+ roles, labels and messages noted, and the signal it gives while it loads or saves
580
+ found. The failures of the first runs went back to the browser before the step
581
+ changed.
582
+
583
+ ## License
584
+
585
+ MIT, see [LICENSE](LICENSE). The polls app the build script writes is the
586
+ official tutorial's, under the BSD licence of the Django documentation
587
+ ([`site/POLLS-LICENSE`](site/POLLS-LICENSE)).
588
+
589
+ ## Logo
590
+
591
+ The Django logo in this README comes from Simple Icons 16.37.0 (CC0-1.0), filled
592
+ with the colour the set lists for the brand. The Django name and logo are
593
+ trademarks of their owner; this pack is not affiliated with or endorsed by them.