@webship.co/workspace-express 0.0.0-stage → 1.0.0

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,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Webship.co
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,191 @@
1
- # Temporary Holding Version
1
+ <p align="center"><img src="https://raw.githubusercontent.com/webship/workspace-express/1.0.x/assets/logo.svg" alt="Express icon" 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
+ # @webship.co/workspace-express
4
+
5
+ Express for the [Webship Workspace](https://github.com/webship/workspace) dashboard: a builder that makes an Express
6
+ app (the step pack's own demo app at a line of Express, or an app from its repository) and serves it with Node.js in a
7
+ container of its own; the [Express step pack](https://github.com/webship/express-steps) wired into the testing setup
8
+ of that app; and its AI items — two agents, a skill, a command and two prompts for building and testing Express apps —
9
+ each listed in the workspace folder of its kind.
10
+
11
+ The app brings its own language in its own container: Node 24's official image, pinned by digest, its packages
12
+ installed in the app's folder (`app/node_modules`) at the first start (`npm ci` with a lock file) and kept after.
13
+ Nothing of Node.js or npm runs on the machine.
14
+
15
+ - **Its server is the app itself:** node, the container's main process under an init, in production mode, so a stop
16
+ reaches it and Express's error handler shows no stack trace. It listens on `PORT` (3000).
17
+ - **The demo app** is the step pack's own small app (MIT), placed with the plugin: accounts (kept in memory while it
18
+ runs), Express's own refusal pages, static files and a session cookie that is Secure behind a TLS proxy (`trust
19
+ proxy` and `secure: 'auto'`: DDEV's router) and not on plain http. Its packages are the line's exact versions (5.3.0,
20
+ the latest, or 4.22.3 with `--line`, with express-session 1.19.0), and its session secret is made by the builder
21
+ into a file only you can read (`.webship-express/session-secret`), never in the code.
22
+ - **An app of your own** comes from its repository (`--source`, `--ref`, `--path`, the folder of its `package.json`),
23
+ started with its own command (`--start 'node server.js'`).
24
+ - **No database hook:** Express has no database of its own, so the row's Backup keeps the files. An app that brings a
25
+ database brings that database's own plugin.
26
+
27
+ The workspace is container-based (DDEV by default): an app is a row like any other, so the row menus the core draws
28
+ (start, stop, launch, backup, restore, clone, remove, tests) work on it. The builder builds on DDEV by default, and with
29
+ `--runtime` on Docker Compose, Podman or a Kubernetes cluster: see [Runtimes](#runtimes).
30
+
31
+ ## Use it
32
+
33
+ ```bash
34
+ cd ~/workspace
35
+ bash core/scripts/plugins.sh --require express --with-needs # npm install into the dashboard
36
+ bash core/scripts/plugins.sh --activate express --with-needs # plugins.express in settings.yml
37
+ bash core/scripts/plugins.sh --install express # the builder, functions, args, AI items
38
+ bash core/scripts/plugins.sh --configure express # nothing to configure: it has no settings file
39
+ ```
40
+
41
+ The same four steps are buttons on the dashboard's **Settings → Plugins** page.
42
+
43
+ | What | Lands in |
44
+ | --- | --- |
45
+ | `cmd-express-project.sh` | every active sites folder: `dev/`, `test/`, `sandboxes/`, `demos/` |
46
+ | The agents `express-builder`, `express-tester` | `ai-agents/` |
47
+ | The skill `express-scenarios` | `ai-skills/` |
48
+ | The command `/express-test` | `ai-commands/` |
49
+ | The prompts `express-build-and-test`, `express-scenarios-for-a-project` | `ai-prompts/` |
50
+
51
+ ## What it needs
52
+
53
+ A workspace starts empty, so the manifest says what else this plugin needs (`needs`):
54
+
55
+ - one sites folder, for the builder: `dev`, `test`, `sandboxes`, `demos` (`dev` is the one added when none is there).
56
+ - `ai-agents`, `ai-skills`, `ai-commands` and `ai-prompts`: the AI folders its items are placed in.
57
+
58
+ Everything the builder runs for an app runs in the app's own container, through the container tool the workspace
59
+ already needs. An app of your own is cloned with git.
60
+
61
+ ## What the package holds
62
+
63
+ | Path | What it is |
64
+ | --- | --- |
65
+ | `commands/cmd-express-project.sh` | The builder, in the Build list as **Express (demo app)** |
66
+ | `scripts/functions/fun-express.sh` | The bash functions behind it; the names the core's tools look for (`set_express_users`, `add_express_users`, `cancel_express_users`, `testing_configure_express`) |
67
+ | `scripts/args/arg-express.sh` | Its argparse; the Build form draws the builder's flags from it |
68
+ | `scripts/docker-compose.express.yaml` | On DDEV, the app's service, copied into the project's `.ddev/` |
69
+ | `demo/` | The step pack's demo app (`app.js`, `public/app.css`), placed with the plugin |
70
+ | `testing/site.feature` | The first feature the demo app gets when testing is set up |
71
+ | `ai/` | The agents, the skill, the command and the prompts |
72
+ | `src/index.ts` | `register(api)`: what the assistant is told about Express here |
73
+ | `features/express.feature`, `features/express-runtimes.feature` | Scenarios for the dashboard's own browser suite |
74
+
75
+ ## The commands
76
+
77
+ ### Build and serve
78
+
79
+ ```bash
80
+ cd ~/workspace/dev
81
+ bash cmd-express-project.sh app1 --install --add-users # the demo app on Express 5.3.0, its two accounts
82
+ bash cmd-express-project.sh app1 --install --line 4.22.3 # on Express 4.22.3
83
+ bash cmd-express-project.sh app1 --install --source https://example.org/app.git --ref main --start 'node server.js'
84
+ bash cmd-express-project.sh app1 --install --runtime docker --launch
85
+ ```
86
+
87
+ | Flag | What it does |
88
+ | --- | --- |
89
+ | `--line 5.3.0` / `--line 4.22.3` | The line of Express of the demo app: its exact packages |
90
+ | `--source`, `--ref`, `--path` | An app of your own: its repository, its branch or tag, the folder of its `package.json` |
91
+ | `--start` | Its start command, a plain command from its folder (needed with `--source`); it listens on `PORT` (3000) |
92
+ | `--install` | Starts it (its packages installed at the first start) and checks its front page |
93
+ | `--add-users` | Registers `webship-tester` and `webship-other` through the demo app's own form |
94
+ | `--runtime ddev` / `docker` / `podman` / `kubernetes` | The container runtime |
95
+ | `--launch` | Opens it in a browser |
96
+
97
+ ### Test an app
98
+
99
+ ```bash
100
+ bash cmd-tools-testing.sh app1 # webship-js, the Express step pack, the accounts, a first feature
101
+ bash cmd-tools-testing.sh app1 --run
102
+ ```
103
+
104
+ The testing setup adds `@webship-js/express-steps` ^2.0.0, its step definitions, the accounts `tester` and `other`
105
+ (`EXPRESS_TESTER_PASSWORD`, `EXPRESS_OTHER_PASSWORD`, the workspace's by default), the app's address, and for the demo
106
+ app its session cookie's name, the 404 and the 500 its first feature loads on purpose (by their address) and a first
107
+ feature. A scenario of the demo app reads:
108
+
109
+ ```gherkin
110
+ Feature: The app
111
+ Background:
112
+ Given the HTTP app has the account "tester"
113
+
114
+ Scenario: Signed in, refusals, static files and the session cookie
115
+ Given I am signed in to the HTTP app as "tester"
116
+ Then the HTTP app should say "Signed in as webship-tester."
117
+ And the HTTP app's session cookie should be HttpOnly
118
+ And the HTTP app's session cookie should have SameSite "Lax"
119
+ When I sign out of the HTTP app
120
+ Then I should not be signed in to the HTTP app
121
+ And the HTTP app should redirect "/account" to "/login"
122
+ When I go to "/webship-no-such-page"
123
+ Then the HTTP app should answer 404 "Cannot GET /webship-no-such-page"
124
+ When I send the HTTP app the JSON "{bad" at "/api/echo"
125
+ Then the HTTP app should answer 400 "Bad Request"
126
+ And the HTTP app should show no stack trace
127
+ When I ask the HTTP app for "/api/greeting" as "text/plain"
128
+ Then the HTTP app should answer 406 "Not Acceptable"
129
+ And the HTTP app should cache "/app.css" for 3600 seconds
130
+ And the HTTP app should answer "/app.css" again with 304
131
+ And the HTTP app should send the header "X-Powered-By" with "Express"
132
+ ```
133
+
134
+ ### Runtimes
135
+
136
+ | Runtime | The address | Proven with this builder |
137
+ | --- | --- | --- |
138
+ | DDEV (the default) | `https://<name>.ddev.site` | Yes: built in 63 s, the pack 10/10, the first feature 3/3; a stop in 0.2 s |
139
+ | Docker Compose (`--runtime docker`) | `http://127.0.0.1:<port>` | Yes: built in 99 s, the pack 10/10; a stop in 0.5 s |
140
+ | Podman (`--runtime podman`) | `http://127.0.0.1:<port>` | Yes: the pack 10/10; a stop in 0.7 s |
141
+ | Kubernetes (`--runtime kubernetes`) | `http://<node address>:<NodePort>` | Yes (kind): built in 43 s, the pack 10/10; a stop in 0.1 s |
142
+
143
+ Each proof built the demo app with `--install --add-users` (on core 1.0.54) and ran the step pack's suite on it.
144
+ Lando and Docksal are runtimes of the workspace too, not proven with this builder yet: it says so and stops, before
145
+ anything is made.
146
+
147
+ ### Users
148
+
149
+ | Account | Made by |
150
+ | --- | --- |
151
+ | `webship-tester`, `webship-other` | `--add-users`, or `cmd-tools-add-users.sh <name> express`: the demo app's own register form, with the workspace's password |
152
+
153
+ The demo keeps its accounts in memory while it runs: a restart forgets them, and the step pack's Background registers
154
+ them again. On DDEV every start of the demo says so, with the command that registers them again
155
+ (`cmd-tools-add-users.sh <name> express`); on the other runtimes the app's own log says it at its start. `cmd-tools-cancel-users.sh <name> express` says the demo has no way to stop an account.
156
+
157
+ ## The AI items
158
+
159
+ | Item | Kind | What it is for |
160
+ | --- | --- | --- |
161
+ | `express-builder` | agent | Builds and fixes Express apps: the demo or one of your own, its packages, its start command |
162
+ | `express-tester` | agent | Writes and runs scenarios with the step pack |
163
+ | `express-scenarios` | skill | The step pack's phrases, the rules that keep a suite green, four example features |
164
+ | `/express-test <app>` | command | Sets the pack up when missing, matches every step, runs, reports |
165
+ | `express-build-and-test` | prompt | Builds an app and proves it |
166
+ | `express-scenarios-for-a-project` | prompt | Writes and runs scenarios for an app's pages, refusals and headers |
167
+
168
+ Every item says the workspace is container-based (DDEV by default), and the agents and the skill send the reader to
169
+ the book *Automated Functional Testing Recipes* first.
170
+
171
+ ## Develop it
172
+
173
+ ```bash
174
+ npm install
175
+ npm test # builds, then the unit tests: the manifest, the scripts, the AI items, the needs
176
+ npm run lint # the TypeScript compiler, no output
177
+ ```
178
+
179
+ CI runs the same on Node.js 24 and 26, checks that every shell script parses, and runs the plugin's webship-js
180
+ features against a dashboard with the plugin installed (`featuresSite`:
181
+ `cmd-express-project.sh ci-express --install --add-users --runtime docker`).
182
+
183
+ ## License
184
+
185
+ ISC (see `LICENSE`).
186
+
187
+ ## Logo
188
+
189
+ The logo is Simple Icons' Express icon (`icons/express.svg` of simple-icons 16.39.0, CC0-1.0), in the colour the set
190
+ lists for it (`#0A0A0A`); its path is unmodified. Express and its mark are the OpenJS Foundation's; this plugin is not
191
+ affiliated with or endorsed by it. The logo is not covered by this package's licence.
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: express-builder
3
+ description: Use this agent to build, start or fix an Express app in the Webship Workspace with the Express plugin's builder (`cmd-express-project.sh`) — the step pack's demo app at Express 5.3.0 or 4.22.3, or an app from its repository with its start command, served by Node.js in Node 24's own image in production mode, on DDEV or Docker Compose, Podman or Kubernetes. Use when an Express app needs making, will not start or answer, or its packages need installing again.
4
+ model: fable
5
+ tools:
6
+ - Bash
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ - Glob
11
+ - Grep
12
+ ---
13
+
14
+ # express-builder
15
+
16
+ You build and keep Express apps of a Webship Workspace (`~/workspace`), a container-based workspace (DDEV by default).
17
+ Nothing runs on the host: no node, npm or npx outside the app's container.
18
+
19
+ ## The book
20
+
21
+ For any automated functional testing in this work (a Gherkin feature, a step definition, choosing a
22
+ step, a test run and its failures), read the book *Automated Functional Testing Recipes* first.
23
+
24
+ - **Where.** Use the first that exists: `.claude/automated-functional-testing-recipes/` in the project,
25
+ `~/.claude/automated-functional-testing-recipes/` (installed by webship/webship-js-ai-agent,
26
+ webship/webship-js-skills or webship/ai-agents), or
27
+ https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
28
+ - **How.** Its `README.md` first, then the chapter that matches the task (one file per chapter,
29
+ named by its subject), not the single complete file.
30
+ - **Which wins.** The installed webship-js package and the step pack are the source of truth for
31
+ step phrasing. When they differ from the book, follow them and say so.
32
+
33
+ ## Build
34
+
35
+ ```bash
36
+ cd ~/workspace/dev
37
+ bash cmd-express-project.sh <name> --install --add-users # the demo app on Express 5.3.0
38
+ bash cmd-express-project.sh <name> --install --line 4.22.3 # on Express 4.22.3
39
+ bash cmd-express-project.sh <name> --install --source <repository> --start 'node server.js'
40
+ bash cmd-express-project.sh <name> --install --runtime docker
41
+ ```
42
+
43
+ The builder deletes a project of the same name first: stop if it is one somebody still needs.
44
+
45
+ ## What a project is
46
+
47
+ - `app/`: the app (the demo, or the repository's folder), its packages in `app/node_modules` (installed at the first
48
+ start: `npm ci` with a lock file).
49
+ - `.webship-express/` (0700): the start command, the line, and for the demo its session secret (0600).
50
+ - Node.js runs the app in production mode, the container's main process under an init: a stop reaches it. It listens
51
+ on PORT (3000). Its log: `ddev logs -s express`.
52
+ - Express has no database of its own: the row's Backup keeps the files.
53
+
54
+ ## When it does not answer
55
+
56
+ Read `ddev logs -s express` (or the runtime's log of the web container): a failed `npm ci` names the package; an app
57
+ that exits names its start command (`--start`). Delete `app/node_modules` and start the project again to install its
58
+ packages anew.
59
+
60
+ Report what you built or changed, its address, and how it was checked.
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: express-tester
3
+ description: Use this agent to test an Express app with webship-js and the Express step pack (`@webship-js/express-steps`) in the Webship Workspace — build it with `cmd-express-project.sh`, set the testing stack up with `cmd-tools-testing.sh`, write scenarios for its accounts, Express's own refusal pages, redirects, static files, headers and the session cookie, run them and read why one fails. Use when an Express app needs features, a failing scenario needs fixing, or a run needs reading.
4
+ model: fable
5
+ tools:
6
+ - Bash
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ - Glob
11
+ - Grep
12
+ ---
13
+
14
+ # express-tester
15
+
16
+ You test Express apps of a Webship Workspace (`~/workspace`), a container-based workspace (DDEV by default), with
17
+ webship-js and the Express step pack.
18
+
19
+ ## The book
20
+
21
+ For any automated functional testing in this work (a Gherkin feature, a step definition, choosing a
22
+ step, a test run and its failures), read the book *Automated Functional Testing Recipes* first.
23
+
24
+ - **Where.** Use the first that exists: `.claude/automated-functional-testing-recipes/` in the project,
25
+ `~/.claude/automated-functional-testing-recipes/` (installed by webship/webship-js-ai-agent,
26
+ webship/webship-js-skills or webship/ai-agents), or
27
+ https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
28
+ - **How.** Its `README.md` first, then the chapter that matches the task (one file per chapter,
29
+ named by its subject), not the single complete file.
30
+ - **Which wins.** The installed webship-js package and the step pack are the source of truth for
31
+ step phrasing. When they differ from the book, follow them and say so.
32
+ - **For Express.** Start with `ch10-authentication-authorization.md` (signing in, a refusal),
33
+ `ch11-api-testing-recipes.md` (its JSON answers and refusals) and `ch44-javascript-and-friendly-errors.md` (the
34
+ browser's errors, and the ones let through).
35
+
36
+ ## Set up and run
37
+
38
+ ```bash
39
+ cd ~/workspace/dev
40
+ bash cmd-express-project.sh <name> --install --add-users # the demo app and its two accounts
41
+ bash cmd-tools-testing.sh <name> # webship-js, the step pack, the accounts, a first feature
42
+ bash cmd-tools-testing.sh <name> --run
43
+ ```
44
+
45
+ ## How the pack reads an Express app
46
+
47
+ - Its phrases say "the HTTP app", never the framework's name (the skill `express-scenarios` lists them).
48
+ - A form's answer is a redirect to a new page: the steps wait for it before reading the flash message.
49
+ - Express's own refusal pages are read by their status and the text of their `<pre>`; a page loaded with a 4xx or 5xx
50
+ logs it in the console, so let each one a scenario loads on purpose through, by its address (cucumber.js).
51
+ - The requests the pack sends itself (redirects, JSON bodies, static files) are read from their answers, never the
52
+ console.
53
+ - The session cookie's flags are read from the header the app sent.
54
+
55
+ Report what ran, what passed, and for each failure the step, its message, and the change you propose.
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Test an Express app of the Webship Workspace with webship-js and the Express step pack — set the testing stack up when it is missing, match every step, run the suite (or one feature, or a tag), and read why a scenario fails.
3
+ argument-hint: '<app> [tests/features/<name>.feature | @tag]'
4
+ ---
5
+
6
+ # /express-test
7
+
8
+ Test the Express app named in: `$ARGUMENTS`
9
+
10
+ `$ARGUMENTS` stands for what was typed after the command: the app's name, then a feature or a tag to run alone.
11
+
12
+ The workspace is container-based (DDEV by default). Work in the sites folder the app is in (`~/workspace/dev`
13
+ unless told otherwise).
14
+
15
+ 1. When the app is not there, build it: `bash cmd-express-project.sh <app> --install --add-users`.
16
+ 2. When it has no testing stack yet (no `cucumber.js` in its folder), set it up: `bash cmd-tools-testing.sh <app>`.
17
+ 3. Match every step before running: `bash cmd-tools-testing.sh <app> --dry-run`. An undefined step is a phrase the
18
+ pack or webship-js does not have: the skill `express-scenarios` says which one to use.
19
+ 4. Run it: `bash cmd-tools-testing.sh <app> --run`, or `--run --path tests/features/<name>.feature`, or
20
+ `--run --tags @<tag>`.
21
+ 5. Read a failure from its message and hint: the pack says what it expected, what it found and what to try.
22
+
23
+ Before you write or change a scenario, or read a failed run, read the book *Automated Functional
24
+ Testing Recipes* (its `README.md`, then the matching chapter):
25
+ `.claude/automated-functional-testing-recipes/` in the app,
26
+ `~/.claude/automated-functional-testing-recipes/`, or
27
+ https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
28
+
29
+ Report what ran, what passed, and for each failure the step, its message, and the change you propose.
@@ -0,0 +1,20 @@
1
+ Build an Express app in a sites folder, serve it, and prove it with webship-js.
2
+
3
+ The launch command below is for Claude Code, the default; the text between the triple quotes can be given to another AI CLI as it is.
4
+
5
+ ```
6
+ claude --permission-mode bypassPermissions """
7
+ Build the Express app named <name> in this sites folder, serve it and test it with webship-js
8
+ # ~/workspace/<dev|test|sandboxes|demos> · https://<name>.ddev.site · container-based (DDEV by default)
9
+ # the builder deletes a project of the same name first: stop if <name> is an app somebody still needs
10
+ # nothing on the host: no node, npm or npx outside the app's container
11
+ # a feature to write or a run to read: the book Automated Functional Testing Recipes first (its README.md, then the matching chapter), from .claude/automated-functional-testing-recipes/ in the project, ~/.claude/automated-functional-testing-recipes/ or https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
12
+
13
+ 1. bash cmd-express-project.sh <name> --install --add-users (the demo app, Node.js, its two accounts)
14
+ 2. bash cmd-tools-testing.sh <name> (webship-js, the Express step pack, the accounts, a first feature)
15
+ 3. bash cmd-tools-testing.sh <name> --run, and read every failure from its message and hint
16
+ 4. Add one scenario of your own for <what the app should do>, from the skill express-scenarios, and run it
17
+
18
+ Report the address, what ran, what passed, and what you changed.
19
+ """
20
+ ```
@@ -0,0 +1,18 @@
1
+ Write webship-js scenarios for an Express app of the workspace: its accounts, its pages, its refusals and its headers.
2
+
3
+ The launch command below is for Claude Code, the default; the text between the triple quotes can be given to another AI CLI as it is.
4
+
5
+ ```
6
+ claude --permission-mode bypassPermissions """
7
+ Write webship-js scenarios for the Express app <name> in this sites folder
8
+ # ~/workspace/<dev|test|sandboxes|demos> · container-based (DDEV by default) · nothing on the host
9
+ # the book Automated Functional Testing Recipes first (its README.md, then the matching chapter), from .claude/automated-functional-testing-recipes/ in the project, ~/.claude/automated-functional-testing-recipes/ or https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
10
+
11
+ 1. bash cmd-tools-testing.sh <name> (when it has no cucumber.js yet)
12
+ 2. Read its pages in the browser, then the skill express-scenarios for the phrases
13
+ 3. Write tests/features/<subject>.feature: what a person does and reads on its pages, its refusals
14
+ 4. bash cmd-tools-testing.sh <name> --run --path tests/features/<subject>.feature, until it passes twice
15
+
16
+ Report the scenarios, what they check, and what passed.
17
+ """
18
+ ```
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: express-scenarios
3
+ description: The phrases of the Express step pack (@webship-js/express-steps) for webship-js scenarios of an Express app built in the container-based Webship Workspace (DDEV by default) with cmd-express-project.sh — accounts registered and signed in and out through the app's forms, its flash messages, Express's own refusal pages with no stack trace, redirects, the body parsers' and content negotiation's refusals, static files' caching and 304, headers and the session cookie. Use when writing or fixing a feature for such an app, or when a step about an Express app does not match.
4
+ ---
5
+
6
+ # Scenarios for an Express app
7
+
8
+ An Express app answers each form with a redirect to a new page, refuses with Express's own pages (titled "Error", the
9
+ status's text in a `<pre>`), serves its files through express.static, and keeps who is signed in in a session cookie.
10
+ The pack's steps do what a person does on its pages and wait for the page that answers each form, never for a fixed
11
+ time. Its phrases say "the HTTP app", never the framework's name. The workspace is container-based (DDEV by default).
12
+ The pack's own features on its demo app are its examples: `examples/accounts.feature` (signing in and out, a wrong
13
+ password, a page that needs an account), `examples/answers.feature` (Express's own answers), `examples/static.feature`
14
+ (static files and headers) and `examples/session.feature` (the session cookie).
15
+
16
+ ## The book
17
+
18
+ For any automated functional testing in this work (a Gherkin feature, a step definition, choosing a
19
+ step, a test run and its failures), read the book *Automated Functional Testing Recipes* first.
20
+
21
+ - **Where.** Use the first that exists: `.claude/automated-functional-testing-recipes/` in the project,
22
+ `~/.claude/automated-functional-testing-recipes/` (installed by webship/webship-js-ai-agent,
23
+ webship/webship-js-skills or webship/ai-agents), or
24
+ https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
25
+ - **How.** Its `README.md` first, then the chapter that matches the task (one file per chapter,
26
+ named by its subject), not the single complete file.
27
+ - **Which wins.** The installed webship-js package and the step pack are the source of truth for
28
+ step phrasing. When they differ from the book, follow them and say so.
29
+ - **For Express.** Start with `ch10-authentication-authorization.md` (signing in, a refusal),
30
+ `ch11-api-testing-recipes.md` (its JSON answers and refusals) and `ch44-javascript-and-friendly-errors.md` (the
31
+ browser's errors, and the ones let through).
32
+
33
+ ## Keeping a suite green
34
+
35
+ - An account a scenario needs is made with `Given the HTTP app has the account "…"`, which counts a name already taken
36
+ as there: never a plain register in a Background.
37
+ - A page a scenario loads with a 4xx or 5xx on purpose logs it in the console: let it through in cucumber.js, by its
38
+ status and address, and check the refusal with the pack's step.
39
+ - Passwords never go in a feature: the accounts' come from the environment (worldParameters.users).
40
+ - The demo keeps its accounts in memory: a restart forgets them, and the Background registers them again.
41
+
42
+ ## The phrases
43
+
44
+ 18 step definitions; each has five examples in its JSDoc block.
45
+
46
+ ### `express-accounts.steps.js` (6)
47
+
48
+ - `Given the HTTP app has the account "<account>"`: registered through the form when it is not there yet; a name
49
+ taken counts as there.
50
+ - `Given I am signed in to the HTTP app as "<account>"`: the session's cookies cleared first.
51
+ - `When I try to sign in to the HTTP app as "<account>" with a wrong password`: a wrong password made by the step.
52
+ - `When I sign out of the HTTP app`
53
+ - `Then the HTTP app should say "<message>"`: the flash message, as a whole.
54
+ - `Then I should be signed in to the HTTP app as "<account>"` / `Then I should not be signed in to the HTTP app`
55
+
56
+ ### `express-answers.steps.js` (7)
57
+
58
+ - `Then the HTTP app should answer <status> "<text>"`: the status and the text of Express's own page, of the request
59
+ this pack sent last in the scenario, or else of the page loaded last.
60
+ - `Then the HTTP app should show no stack trace`
61
+ - `Then the HTTP app should redirect "<path>" to "<path>"`: a 3xx and its Location, not followed.
62
+ - `When I send the HTTP app the JSON "<raw>" at "<path>"` / `When I send the HTTP app a JSON body of <n> bytes at "<path>"`
63
+ - `When I ask the HTTP app for "<path>" as "<type>"`: its Accept.
64
+ - `Then the HTTP app should send the header "<name>"` (`with "<value>"`) / `should not send the header "<name>"`
65
+
66
+ ### `express-static.steps.js` (3)
67
+
68
+ - `Then the HTTP app should cache "<path>" for <n> seconds`
69
+ - `Then the HTTP app should answer "<path>" again with 304`: asked again with its ETag.
70
+ - `Then the HTTP app should not serve "<path>"`: 404.
71
+
72
+ ### `express-session.steps.js` (2)
73
+
74
+ - `Then the HTTP app's session cookie should be HttpOnly` / `Secure` (or `should not be`)
75
+ - `Then the HTTP app's session cookie should have SameSite "<Lax|Strict|None>"` / `should have no SameSite`
@@ -0,0 +1,24 @@
1
+ # Accounts of the HTTP app: registered through its form, signed in and out, a wrong password refused, and the flash
2
+ # message it says. Passwords come from the environment.
3
+ Feature: Accounts of the HTTP app
4
+ An account registers, signs in and out through the app's forms, and a wrong password is refused.
5
+
6
+ Background:
7
+ Given the HTTP app has the account "tester"
8
+
9
+ Scenario: Signed in and out
10
+ Given I am signed in to the HTTP app as "tester"
11
+ Then the HTTP app should say "Signed in as webship-tester."
12
+ And I should be signed in to the HTTP app as "tester"
13
+ When I sign out of the HTTP app
14
+ Then I should not be signed in to the HTTP app
15
+
16
+ Scenario: A wrong password
17
+ When I try to sign in to the HTTP app as "tester" with a wrong password
18
+ Then the HTTP app should say "Wrong user name or password."
19
+ And I should not be signed in to the HTTP app
20
+
21
+ Scenario: A page that needs an account sends a visitor to the sign-in form
22
+ Then the HTTP app should redirect "/account" to "/login"
23
+ When I go to "/account"
24
+ Then the HTTP app should say "Sign in first."
@@ -0,0 +1,26 @@
1
+ # Express's own answers: its 404, its error handler (no stack trace in production), the body parsers' refusals and
2
+ # content negotiation's.
3
+ Feature: Express's own answers
4
+ The app refuses with Express's own pages, and shows no stack trace.
5
+
6
+ Scenario: A page the app does not have
7
+ When I go to "/webship-no-such-page"
8
+ Then the HTTP app should answer 404 "Cannot GET /webship-no-such-page"
9
+
10
+ Scenario: A page that fails shows no stack trace
11
+ When I go to "/boom"
12
+ Then the HTTP app should answer 500 "Internal Server Error"
13
+ And the HTTP app should show no stack trace
14
+
15
+ Scenario: The body parser refuses malformed JSON and a body over its limit
16
+ When I send the HTTP app the JSON "{bad" at "/api/echo"
17
+ Then the HTTP app should answer 400 "Bad Request"
18
+ And the HTTP app should show no stack trace
19
+ When I send the HTTP app a JSON body of 2000 bytes at "/api/echo"
20
+ Then the HTTP app should answer 413 "Payload Too Large"
21
+
22
+ Scenario: Content negotiation refuses a type the app does not offer
23
+ When I ask the HTTP app for "/api/greeting" as "text/plain"
24
+ Then the HTTP app should answer 406 "Not Acceptable"
25
+ When I ask the HTTP app for "/api/greeting" as "application/json"
26
+ Then the HTTP app should send the header "Content-Type" with "application/json; charset=utf-8"
@@ -0,0 +1,10 @@
1
+ # The session cookie, as the app sets it.
2
+ Feature: The session cookie
3
+ The session cookie is HttpOnly and SameSite Lax; served over http, it is not Secure.
4
+
5
+ Scenario: The session cookie's flags
6
+ Given the HTTP app has the account "tester"
7
+ And I am signed in to the HTTP app as "tester"
8
+ Then the HTTP app's session cookie should be HttpOnly
9
+ And the HTTP app's session cookie should have SameSite "Lax"
10
+ And the HTTP app's session cookie should not be Secure
@@ -0,0 +1,11 @@
1
+ # express.static: caching, ETag and 304, and dotfiles not served; and the header Express adds.
2
+ Feature: Static files and headers
3
+ express.static serves the app's files with a cache time and an ETag, and never its dotfiles.
4
+
5
+ Scenario: A stylesheet cached for an hour and answered 304 when unchanged
6
+ Then the HTTP app should cache "/app.css" for 3600 seconds
7
+ And the HTTP app should answer "/app.css" again with 304
8
+ And the HTTP app should send the header "X-Powered-By" with "Express"
9
+
10
+ Scenario: A dotfile is not served
11
+ Then the HTTP app should not serve "/.webship-hidden"
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # workspace-name: Express (demo app)
4
+
5
+ # Installed by the Express plugin (plugins.sh --install express); __WORKSPACE__ is the workspace it was installed into.
6
+ #
7
+ # Make an Express app: the step pack's own demo app at a line of Express (5.3.0, the latest, or 4.22.3 with --line),
8
+ # or an app from its repository with --source (and --start naming its start command), and serve it with Node.js in
9
+ # Node 24's official image, its packages installed in the app's folder, in production mode. Node.js, the app's language,
10
+ # runs in the app's container, never on the machine. With --install the app is started and checked; with --add-users
11
+ # the demo's accounts are registered through its own form. The workspace is container-based (DDEV by default, at
12
+ # https://<name>.ddev.site); --runtime docker, podman or kubernetes builds it on Docker Compose, Podman or a Kubernetes
13
+ # cluster instead.
14
+
15
+ # Bootstrap.
16
+ # Find the workspace tooling from this script, so a fresh clone needs no setup.
17
+ WORKSPACE_SCRIPTS="${WORKSPACE_SCRIPTS:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../core/scripts" && pwd)}";
18
+ source ${WORKSPACE_SCRIPTS}/bootstrap.sh || exit 1 ;
19
+
20
+ # Load workspace settings.
21
+ eval $(parse_yaml ${WORKSPACE_CONFIG}/workspace.__WORKSPACE__.settings.yml);
22
+
23
+ # Distribution.
24
+ distribution_name="express";
25
+ distribution_title="Express";
26
+ distribution_webroot="app";
27
+
28
+ ARGPARSE_DESCRIPTION="Build a ${distribution_title} project in __WORKSPACE__"
29
+ # The args file comes with the plugin: core/scripts/plugins/express/ is where plugins.sh --install puts it.
30
+ source ${WORKSPACE_SCRIPTS}/plugins/express/args/arg-express.sh || exit 1 ;
31
+
32
+ shift $#;
33
+
34
+ express_build ;