@shivaedev/test-story 0.22.0 → 0.23.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.23.0 - 2026-10-29
4
+
5
+ ### Added
6
+
7
+ - Forwarding proxy fixtures relay WebSocket upgrades, including the same origin and trusted proxy headers as HTTP requests. Existing proxy URLs also work for socket clients.
8
+
9
+ ### Breaking
10
+
11
+ - Screen text readouts concatenate visible HTML text nodes without CSS text transforms or layout line breaks. Update text assertions to match DOM text content; hidden descendants remain omitted.
12
+ - Contract clients use Effect RPC over a shared WebSocket by default. Replace `httpClient`, `transformClient` and `serialization` client options with a native `protocol` Layer for custom transports. Node clients can supply upgrade `headers` and a `webSocketConstructor` Layer; browsers use their session cookie automatically.
13
+ - Mounting a bound query subscribes before its first authorized read; unmounting releases its subscription. Use `live: false` when binding an ordinary client without subscriptions. Query preparation alone no longer opens a change stream.
14
+ - Hosts serve live subscriptions on the WebSocket upgrade at the RPC path. Move HTTP `$changes` consumers to Effect RPC's socket protocol; the POST route serves ordinary RPC only. Configure development proxies to forward WebSocket upgrades.
15
+ - React session boundaries bind shared sockets to the identified session, so replacing an account upgrades with its current cookie. They also ask the auth owner to recheck when the live socket closes. Keep `recheck` safe to call after a network interruption; the auth owner still decides whether the session ends.
16
+
3
17
  ## 0.22.0 - 2026-10-28
4
18
 
5
19
  ### Added
package/README.md CHANGED
@@ -8,9 +8,9 @@ When agents write most of the code, test files grow into hundreds of lines nobod
8
8
 
9
9
  ```ts
10
10
  bakery.it("steps until the condition holds", [ovenIsLit(), hasDough(3)], function* ({ oven }) {
11
- yield* oven.bakesEverything();
12
- expect(oven.loaves()).toBe(3);
13
- expect(oven.minutes()).toBe(3);
11
+ yield* oven.bakesEverything();
12
+ expect(oven.loaves()).toBe(3);
13
+ expect(oven.minutes()).toBe(3);
14
14
  });
15
15
  ```
16
16
 
@@ -54,7 +54,6 @@ Every story belongs to a **genre**, the kind of engine it runs. The kit names ea
54
54
  The package runs on Effect and Vitest, but an engine needs neither: every hook, trait and test body may be a plain function. Use a generator function to yield Effects when a hook needs a service or fails with a typed error; the kit runs it, so no definition needs `Effect.gen`. Creation, stage `after` hooks and traits may also be plain functions that return an Effect directly. The kit runs that Effect in the story's Scope, with the services from its layer.
55
55
 
56
56
  The work splits into three layers, and each is written by a different hand at a different time:
57
-
58
57
  1. **Once per engine**, a story kit in `test-support/` says how to create the engine, which services it needs, and how to seed, step and show it.
59
58
  2. **Once per feature**, traits and verbs in the kit name that feature in domain words.
60
59
  3. **In every test**, a spec tells a story with the kit's `it` and checks what a user would see.
@@ -65,12 +64,12 @@ A verb performs one action on the real engine or reads one observation. An actio
65
64
 
66
65
  Acquire real services in `create` or a trait inside the story's per-test Scope, with dependencies provided by `layer`. Keep those services on the engine so verbs use the same running instance; scoped cleanup releases them after the story. Do not build and tear down services inside each verb. When closing a service is the action under test, expose that action separately from acquisition and observation.
67
66
 
68
- | Shape to avoid | What to do instead |
69
- | --- | --- |
70
- | A verb runs a whole scenario and returns the measurements the spec asserts. | Give each action and observation its own verb; let the spec compose them and compare the observations. |
71
- | A verb hard-codes the expected outcome or hides assertions. | Return the real response or observation, and put expected values and all assertions in the spec. |
72
- | A verb does two jobs and returns both results. | Split the jobs into two verbs and show both calls in the spec. |
73
- | A verb silently does nothing when its target is missing, such as `button?.click()`. | Fail with a message naming the missing target, then perform the action only once the target exists. |
67
+ | Shape to avoid | What to do instead |
68
+ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
69
+ | A verb runs a whole scenario and returns the measurements the spec asserts. | Give each action and observation its own verb; let the spec compose them and compare the observations. |
70
+ | A verb hard-codes the expected outcome or hides assertions. | Return the real response or observation, and put expected values and all assertions in the spec. |
71
+ | A verb does two jobs and returns both results. | Split the jobs into two verbs and show both calls in the spec. |
72
+ | A verb silently does nothing when its target is missing, such as `button?.click()`. | Fail with a message naming the missing target, then perform the action only once the target exists. |
74
73
  | An engine default hides what the story declares, such as a lit oven, signed-in user or authorization header. | Start with a neutral engine and name the precondition in a trait or pass the input explicitly in the action. |
75
74
 
76
75
  The bakery below starts with a cold oven and no dough. Its traits declare heat and dough, its baking action returns no report, and its readouts expose loaves and elapsed minutes separately. `runUntil` waits for that one engine action to complete; it does not replace a spec's sequence of actions.
@@ -83,64 +82,63 @@ Every story gets Effect's native `TestCrypto` service with seed `0`, created afr
83
82
 
84
83
  ```ts
85
84
  export const bakery = storyKit({
86
- after: {
87
- *kitchen(state) {
88
- if (state.bowls === 0) {
89
- return yield* new NoBowls();
90
- }
91
- state.capacity = state.bowls * DOUGH_PER_BOWL;
92
- },
93
- },
94
- create: emptyBakery,
95
- layer: Supplier.layer,
96
- name: "bakery",
97
- run: {
98
- diagnose: stillWaiting,
99
- failed: ovenTrouble,
100
- maxSteps: 60,
101
- *step(state, tell) {
102
- state.minute += 1;
103
- if (state.overfired) {
104
- return yield* new BurntLoaf({ minute: state.minute });
105
- }
106
- state.dough += state.starter ? 0 : -1;
107
- state.loaves += 1;
108
- tell(`${state.minute}m a loaf comes out of the oven`);
109
- },
110
- },
111
- stages: ["kitchen", "pantry"],
112
- verbs: (state, story) => ({
113
- baker: {
114
- kneads: (count: number) => {
115
- story.tell(`the baker kneads ${count} balls of dough`);
116
- state.dough += count;
117
- },
118
- },
119
- oven: {
120
- bakesEverything: (maxSteps?: number): Effect.Effect<void, BurntLoaf> =>
121
- story.runUntil((current) => current.dough === 0, { maxSteps }),
122
- loaves: () => state.loaves,
123
- minutes: () => state.minute,
124
- },
125
- }),
85
+ after: {
86
+ *kitchen(state) {
87
+ if (state.bowls === 0) {
88
+ return yield* new NoBowls();
89
+ }
90
+ state.capacity = state.bowls * DOUGH_PER_BOWL;
91
+ },
92
+ },
93
+ create: emptyBakery,
94
+ layer: Supplier.layer,
95
+ name: "bakery",
96
+ run: {
97
+ diagnose: stillWaiting,
98
+ failed: ovenTrouble,
99
+ maxSteps: 60,
100
+ *step(state, tell) {
101
+ state.minute += 1;
102
+ if (state.overfired) {
103
+ return yield* new BurntLoaf({ minute: state.minute });
104
+ }
105
+ state.dough += state.starter ? 0 : -1;
106
+ state.loaves += 1;
107
+ tell(`${state.minute}m a loaf comes out of the oven`);
108
+ },
109
+ },
110
+ stages: ["kitchen", "pantry"],
111
+ verbs: (state, story) => ({
112
+ baker: {
113
+ kneads: (count: number) => {
114
+ story.tell(`the baker kneads ${count} balls of dough`);
115
+ state.dough += count;
116
+ },
117
+ },
118
+ oven: {
119
+ bakesEverything: (maxSteps?: number): Effect.Effect<void, BurntLoaf> => story.runUntil((current) => current.dough === 0, { maxSteps }),
120
+ loaves: () => state.loaves,
121
+ minutes: () => state.minute,
122
+ },
123
+ }),
126
124
  });
127
125
  ```
128
126
 
129
127
  This is the bakery kit this package tests itself with. `emptyBakery`, `stillWaiting` and `ovenTrouble` are plain functions beside it. `kitchen` and `step` are generators because they fail with typed errors, `NoBowls` and `BurntLoaf`.
130
128
 
131
- | Hook | Says |
132
- | --- | --- |
133
- | `name` | What the engine is called in failures, "the bakery", and the kit's genre, "Bakery Story". |
134
- | `outbound` | Optional. A map of exact hostnames to fake server origins for Node fetch and the DOM environment's document requests. |
135
- | `around(effect)` | Optional. Wraps creation, staged seeding and the body; worker Layer acquisition remains outside it. It may require the worker services and per-test Scope. |
136
- | `clock` | Optional. `"test"` by default, `"live"` for real time, or a UTC `DateTime` to start TestClock at that instant. A story’s `options.clock` takes precedence. |
137
- | `create()` | A fresh engine. Every story starts from a new one. |
138
- | `layer` | Optional. The worker Effect layer that provides the services hooks, traits and test bodies use. Per-test Scope is already available to creation, staged and run hooks, traits and bodies. A hook that needs a service the layer does not provide does not compile, and neither does a test whose traits or body need one. |
139
- | `stages` | The order traits are applied in. A trait names its stage, and one that names a stage the kit does not declare does not compile. |
140
- | `after` | Optional. A hook per stage that runs once that stage's traits are applied, even when no trait names the stage, so a value it derives is ready before a later stage reads it. Its typed failure fails the test. |
141
- | `run` | Optional. What `story.runUntil` needs: `step(engine, tell)` advances the engine once and tells what happened, `maxSteps` caps one run, `failed(engine)` returns a sentence when the engine is in a state it cannot recover from, and `diagnose(engine)` says why it has not finished. |
142
- | `inspect` | Optional. The part of the engine a failure prints. Without it, the failure prints the whole engine. |
143
- | `verbs(engine, story)` | One action or one observation per verb. A verb that waits for a stepped engine returns the Effect from `story.runUntil`; the spec reads observations and asserts separately. |
129
+ | Hook | Says |
130
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
131
+ | `name` | What the engine is called in failures, "the bakery", and the kit's genre, "Bakery Story". |
132
+ | `outbound` | Optional. A map of exact hostnames to fake server origins for Node fetch and the DOM environment's document requests. |
133
+ | `around(effect)` | Optional. Wraps creation, staged seeding and the body; worker Layer acquisition remains outside it. It may require the worker services and per-test Scope. |
134
+ | `clock` | Optional. `"test"` by default, `"live"` for real time, or a UTC `DateTime` to start TestClock at that instant. A story’s `options.clock` takes precedence. |
135
+ | `create()` | A fresh engine. Every story starts from a new one. |
136
+ | `layer` | Optional. The worker Effect layer that provides the services hooks, traits and test bodies use. Per-test Scope is already available to creation, staged and run hooks, traits and bodies. A hook that needs a service the layer does not provide does not compile, and neither does a test whose traits or body need one. |
137
+ | `stages` | The order traits are applied in. A trait names its stage, and one that names a stage the kit does not declare does not compile. |
138
+ | `after` | Optional. A hook per stage that runs once that stage's traits are applied, even when no trait names the stage, so a value it derives is ready before a later stage reads it. Its typed failure fails the test. |
139
+ | `run` | Optional. What `story.runUntil` needs: `step(engine, tell)` advances the engine once and tells what happened, `maxSteps` caps one run, `failed(engine)` returns a sentence when the engine is in a state it cannot recover from, and `diagnose(engine)` says why it has not finished. |
140
+ | `inspect` | Optional. The part of the engine a failure prints. Without it, the failure prints the whole engine. |
141
+ | `verbs(engine, story)` | One action or one observation per verb. A verb that waits for a stepped engine returns the Effect from `story.runUntil`; the spec reads observations and asserts separately. |
144
142
 
145
143
  Every test of the kit is named `Bakery Story: <its name>`, so `vitest run -t "Bakery Story: "` runs only the bakery's stories with no setup. A project that splits runs by Vitest tags can also tag them:
146
144
 
@@ -149,7 +147,7 @@ import { genreTags } from "@shivaedev/test-story/server/genreTags.ts";
149
147
  import { defineConfig } from "vitest/config";
150
148
 
151
149
  export default defineConfig({
152
- test: { tags: genreTags("bakery", "mill") },
150
+ test: { tags: genreTags("bakery", "mill") },
153
151
  });
154
152
  ```
155
153
 
@@ -166,16 +164,16 @@ import { bakery, hasDough, ovenIsLit } from "./bakery.ts";
166
164
  import { mill, sailsAreTurning } from "./mill.ts";
167
165
 
168
166
  export const village = storyKit({
169
- extends: [mill, bakery],
170
- name: "village",
167
+ extends: [mill, bakery],
168
+ name: "village",
171
169
  });
172
170
 
173
171
  village.it("mills flour and bakes loaves", [sailsAreTurning(), ovenIsLit(), hasDough(2)], function* ({ miller, oven, story }) {
174
- miller.grinds(3);
175
- yield* oven.bakesEverything();
176
- expect(story.engine.sacks).toBe(3);
177
- expect(story.engine.sails).toBe("turning");
178
- expect(oven.loaves()).toBe(2);
172
+ miller.grinds(3);
173
+ yield* oven.bakesEverything();
174
+ expect(story.engine.sacks).toBe(3);
175
+ expect(story.engine.sails).toBe("turning");
176
+ expect(oven.loaves()).toBe(2);
179
177
  });
180
178
  ```
181
179
 
@@ -183,7 +181,7 @@ village.it("mills flour and bakes loaves", [sailsAreTurning(), ovenIsLit(), hasD
183
181
 
184
182
  Creation runs in dependency order, left to right, before any traits. Stages and their `after` hooks then run in that same order, regardless of the order traits appear in the spec. All creation, traits, hooks and the body share one per-test Scope, whose finalizers release resources in reverse acquisition order, including after a failed story. Feature verbs retain their own `runUntil` hooks, so the bakery's waiting verb still steps the bakery. Use each feature's waiting verbs when driving a composed story.
185
183
 
186
- Top-level engine fields, verb names and trait stage names must be unique across the kits. A collision fails typechecking with a message such as `Cannot compose story kits: duplicate verb names` and the conflicting name. Give stages feature-specific names when composing; a trait's stage selects its feature's setup hooks. Traits remain the existing `kit.trait` values and `kit.traits` combinations.
184
+ Top-level engine fields, verb names and trait stage names must be unique across the kits. A collision fails typechecking with a message such as `Cannot compose story kits: duplicate verb names` and the conflicting name. Give stages feature-specific names when composing; a trait's stage selects its feature's setup hooks. Traits are each feature kit's own `kit.trait` values and `kit.traits` combinations.
187
185
 
188
186
  #### Routing outbound HTTP
189
187
 
@@ -191,14 +189,14 @@ When application code calls a hard-coded third-party URL, set `outbound` on its
191
189
 
192
190
  ```ts
193
191
  const app = storyKit({
194
- ...appDefinition,
195
- outbound: { "github.com": fakeUrl, "api.github.com": fakeUrl },
192
+ ...appDefinition,
193
+ outbound: { "github.com": fakeUrl, "api.github.com": fakeUrl },
196
194
  });
197
195
  ```
198
196
 
199
197
  `appDefinition` holds the application's kit hooks, and `fakeUrl` is the listening fake server's HTTP or HTTPS origin, such as `http://127.0.0.1:4321`. The map matches exact URL hostnames, across ports. It replaces the destination origin while keeping the request's path, query, method, headers and body. For example, a POST to `https://github.com/login/oauth/access_token` reaches the fake's `/login/oauth/access_token`. In Node stories, other hostnames pass through the previous dispatcher unchanged. In the DOM environment, only loopback hosts (`localhost`, IPv4 loopback addresses and `[::1]`) may pass through without a route; every other hostname must have an `outbound` fake. A refused request fails the story and names its hostname, even when application code catches the fetch error.
200
198
 
201
- `routeOutbound(routes)` from `@shivaedev/test-story/server/routeOutbound.ts` installs the same routing in the current Effect Scope. Acquire a `fakeHttpService` in `create`, then yield `routeOutbound({ "api.example.com": api.url })` so the fake listener and its routing belong to that story. The starter's social sign-in story exercises this path through both document navigation and host-side requests.
199
+ `routeOutbound(routes)` from `@shivaedev/test-story/server/routeOutbound.ts` installs the same routing in the current Effect Scope. Acquire a `fakeHttpService` in `create`, then yield `routeOutbound({ "api.example.com": api.url })` so the fake listener and its routing belong to that story.
202
200
 
203
201
  Routing uses the global dispatcher that Node's built-in `fetch` already uses. The kit's `outbound` option installs routing before `around`, creation, traits and the body, stays active during scoped cleanup, and restores the previous dispatcher after each story, including a failing story. Stories within one worker must run one at a time because that dispatcher is shared; parallelism belongs between workers or inside one story. The DOM environment uses the same routing for host-side Node fetch and document requests, including redirect destinations. It refuses external hosts even when the kit omits `outbound`.
204
202
 
@@ -217,49 +215,50 @@ import { expect } from "vitest";
217
215
  import { storyKit } from "@shivaedev/test-story/server/storyKit.ts";
218
216
 
219
217
  const app = storyKit({
220
- around: (effect) => effect.pipe(Effect.withSpan("story")),
221
- *create() {
222
- const spans: Tracer.NativeSpan[] = [];
223
- const tracer = Tracer.make({
224
- span: (options) => {
225
- const span = new Tracer.NativeSpan(options);
226
- spans.push(span);
227
- return span;
228
- },
229
- });
230
- const context = yield* Effect.context<never>().pipe(Effect.withTracer(tracer));
231
- const handler = HttpEffect.toWebHandlerWith(context)(Effect.succeed(HttpServerResponse.text("ok")));
232
- return { handler, spans };
233
- },
234
- name: "traced application",
235
- stages: ["ready"],
236
- verbs: ({ handler, spans }) => ({
237
- request: (headers: HeadersInit = {}) => Effect.promise(async () => {
238
- const response = await handler(new Request("http://app.test/", { headers }));
239
- return response.text();
240
- }),
241
- requestSpan: () => {
242
- const span = spans.filter((span) => span.kind === "server").at(-1);
243
- if (span === undefined) throw new Error("The request exported no server span");
244
- return span;
245
- },
246
- }),
218
+ around: (effect) => effect.pipe(Effect.withSpan("story")),
219
+ *create() {
220
+ const spans: Tracer.NativeSpan[] = [];
221
+ const tracer = Tracer.make({
222
+ span: (options) => {
223
+ const span = new Tracer.NativeSpan(options);
224
+ spans.push(span);
225
+ return span;
226
+ },
227
+ });
228
+ const context = yield* Effect.context<never>().pipe(Effect.withTracer(tracer));
229
+ const handler = HttpEffect.toWebHandlerWith(context)(Effect.succeed(HttpServerResponse.text("ok")));
230
+ return { handler, spans };
231
+ },
232
+ name: "traced application",
233
+ stages: ["ready"],
234
+ verbs: ({ handler, spans }) => ({
235
+ request: (headers: HeadersInit = {}) =>
236
+ Effect.promise(async () => {
237
+ const response = await handler(new Request("http://app.test/", { headers }));
238
+ return response.text();
239
+ }),
240
+ requestSpan: () => {
241
+ const span = spans.filter((span) => span.kind === "server").at(-1);
242
+ if (span === undefined) throw new Error("The request exported no server span");
243
+ return span;
244
+ },
245
+ }),
247
246
  });
248
247
 
249
248
  app.it("a request is its own root trace", [], function* ({ request, requestSpan }) {
250
- const storySpan = yield* Effect.currentSpan;
251
- expect(yield* request()).toBe("ok");
252
- const span = requestSpan();
253
- expect(span.parent._tag).toBe("None");
254
- expect(span.traceId).not.toBe(storySpan.traceId);
255
- expect(span.status._tag).toBe("Ended");
249
+ const storySpan = yield* Effect.currentSpan;
250
+ expect(yield* request()).toBe("ok");
251
+ const span = requestSpan();
252
+ expect(span.parent._tag).toBe("None");
253
+ expect(span.traceId).not.toBe(storySpan.traceId);
254
+ expect(span.status._tag).toBe("Ended");
256
255
  });
257
256
 
258
257
  app.it("a request continues its supplied trace", [], function* ({ request, requestSpan }) {
259
- yield* request({ traceparent: "00-1234567890abcdef1234567890abcdef-1234567890abcdef-01" });
260
- const span = requestSpan();
261
- expect(span.traceId).toBe("1234567890abcdef1234567890abcdef");
262
- expect(span.parent).toMatchObject({ value: { spanId: "1234567890abcdef" } });
258
+ yield* request({ traceparent: "00-1234567890abcdef1234567890abcdef-1234567890abcdef-01" });
259
+ const span = requestSpan();
260
+ expect(span.traceId).toBe("1234567890abcdef1234567890abcdef");
261
+ expect(span.parent).toMatchObject({ value: { spanId: "1234567890abcdef" } });
263
262
  });
264
263
  ```
265
264
 
@@ -293,10 +292,10 @@ Use `otlpReceiver` from `@shivaedev/test-story/server/otlpReceiver.ts` in a kit'
293
292
 
294
293
  ```ts
295
294
  app.it("exports the work span", [], function* ({ runWork, disposeRuntime, spans, requests }) {
296
- yield* runWork();
297
- yield* disposeRuntime();
298
- expect(spans()).toContainEqual(expect.objectContaining({ name: "CountWords" }));
299
- expect(requests().some(({ body }) => body.includes(Buffer.from("planted-secret")))).toBe(true);
295
+ yield* runWork();
296
+ yield* disposeRuntime();
297
+ expect(spans()).toContainEqual(expect.objectContaining({ name: "CountWords" }));
298
+ expect(requests().some(({ body }) => body.includes(Buffer.from("planted-secret")))).toBe(true);
300
299
  });
301
300
  ```
302
301
 
@@ -352,7 +351,7 @@ const bytes = yield* Fiber.join(pending);
352
351
 
353
352
  `stall(route)` sends the reply's status and headers, then pauses its body. Its `waiting` effect completes at that pause. Its `release` lets the body continue; a client that gives up also stops waiting on the server. Like a hold, a stall remains installed for matching requests until released. Holds pause before headers. `releaseOnArrival(heldRoute, arrivingRoute, scope?)` releases the current hold when an authorized request reaches the named route; script it before that arrival. Rejected requests do not trigger release.
354
353
 
355
- `fault(route, fault)` acts on an arrived request in the required phase. `{ kind: "status", reply: { status: 503, body: { error: "unavailable" } } }` replaces a held reply before headers. `{ kind: "drop" }` drops a connection before headers. `{ kind: "reset" }` terminates a reply after headers, including after body chunks have arrived. Wait for the hold, stall or client observation before injecting the fault. A fault fails with guidance when no request is in the required phase; it does not queue a failure for a future call. `failOnce` continues to queue a status reply for the next request.
354
+ `fault(route, fault)` acts on an arrived request in the required phase. `{ kind: "status", reply: { status: 503, body: { error: "unavailable" } } }` replaces a held reply before headers. `{ kind: "drop" }` drops a connection before headers. `{ kind: "reset" }` terminates a reply after headers, including after body chunks have arrived. Wait for the hold, stall or client observation before injecting the fault. A fault fails with guidance when no request is in the required phase; it does not queue a failure for a future call. `failOnce` queues a status reply for the next request.
356
355
 
357
356
  `hold(route, scope)`, `stall(route, scope)`, `fault(route, fault, scope)`, `failOnce(route, reply, scope)` and `replyOnce(route, reply, scope)` accept an optional `{ params: { number: "7" } }`. Every supplied parameter must equal the decoded request parameter. Other resources on the same named route answer normally and do not consume the scoped reply. Scoped holds and stalls return `waiting` and `release`. `hold(route, { once: true, params: { number: "7" } })` holds only the first matching request; later matching requests answer while it remains held. Omit `params` to hold only the first request across the route. Omit `once` to keep holding every matching request until release. Pass the same parameter scope as the third argument to `releaseOnArrival` to release that hold.
358
357
 
@@ -398,24 +397,24 @@ A trait is a line and a change, tagged with a stage:
398
397
 
399
398
  ```ts
400
399
  export function hasDough(count: number) {
401
- return bakery.trait("pantry", `the baker has ${count} balls of dough`, (state) => {
402
- if (count > state.capacity) {
403
- throw new Error(`the bowls hold only ${state.capacity}`);
404
- }
405
- state.dough = count;
406
- });
400
+ return bakery.trait("pantry", `the baker has ${count} balls of dough`, (state) => {
401
+ if (count > state.capacity) {
402
+ throw new Error(`the bowls hold only ${state.capacity}`);
403
+ }
404
+ state.dough = count;
405
+ });
407
406
  }
408
407
 
409
408
  export function hasFlourDelivered(sacks: number) {
410
- return bakery.trait("pantry", `the supplier has delivered ${sacks} sacks of flour`, function* (state) {
411
- const supplier = yield* Supplier;
412
- yield* supplier.deliver(sacks);
413
- state.flour = sacks;
414
- });
409
+ return bakery.trait("pantry", `the supplier has delivered ${sacks} sacks of flour`, function* (state) {
410
+ const supplier = yield* Supplier;
411
+ yield* supplier.deliver(sacks);
412
+ state.flour = sacks;
413
+ });
415
414
  }
416
415
 
417
416
  export function morningShift() {
418
- return bakery.traits(ovenIsLit(), hasBowls(1));
417
+ return bakery.traits(ovenIsLit(), hasBowls(1));
419
418
  }
420
419
  ```
421
420
 
@@ -453,15 +452,15 @@ A verb that a feature adds goes into the kit's `verbs`. It acts through the engi
453
452
 
454
453
  ```ts
455
454
  bakery.it("tells each step into the story", [ovenIsLit()], function* ({ baker, oven, story }) {
456
- baker.kneads(2);
457
- yield* oven.bakesEverything();
458
-
459
- expect(story.lines).toEqual([
460
- "the oven is lit",
461
- "the baker kneads 2 balls of dough",
462
- "1m a loaf comes out of the oven",
463
- "2m a loaf comes out of the oven",
464
- ]);
455
+ baker.kneads(2);
456
+ yield* oven.bakesEverything();
457
+
458
+ expect(story.lines).toEqual([
459
+ "the oven is lit",
460
+ "the baker kneads 2 balls of dough",
461
+ "1m a loaf comes out of the oven",
462
+ "2m a loaf comes out of the oven",
463
+ ]);
465
464
  });
466
465
  ```
467
466
 
@@ -475,13 +474,13 @@ For several outcomes after one action, use `outcomes` from `@shivaedev/test-stor
475
474
  import { outcomes } from "@shivaedev/test-story/server/outcomes.ts";
476
475
 
477
476
  accounts.it("removing Bob leaves Alice signed in", [bobAndAliceAreSignedIn()], function* ({ remove, request, sessions }) {
478
- yield* remove("bob");
477
+ yield* remove("bob");
479
478
 
480
- yield* outcomes({
481
- "bob's next request": [request("bob"), "unauthorized"],
482
- "bob's sessions": [sessions("bob"), 0],
483
- "alice's next request": [request("alice"), "ok"],
484
- });
479
+ yield* outcomes({
480
+ "bob's next request": [request("bob"), "unauthorized"],
481
+ "bob's sessions": [sessions("bob"), 0],
482
+ "alice's next request": [request("alice"), "ok"],
483
+ });
485
484
  });
486
485
  ```
487
486
 
@@ -489,9 +488,9 @@ accounts.it("removing Bob leaves Alice signed in", [bobAndAliceAreSignedIn()], f
489
488
 
490
489
  ```ts
491
490
  accounts.it("removing Bob ends his session", [bobIsSignedIn()], function* ({ remove, request }) {
492
- yield* remove("bob");
491
+ yield* remove("bob");
493
492
 
494
- expect(yield* request("bob")).toBe("unauthorized");
493
+ expect(yield* request("bob")).toBe("unauthorized");
495
494
  });
496
495
  ```
497
496
 
@@ -503,27 +502,31 @@ Pass a UTC `DateTime` as the story's `clock` option to pin time before its wrapp
503
502
  import { DateTime } from "effect";
504
503
  import * as TestClock from "effect/testing/TestClock";
505
504
 
506
- app.it("shows the worker's date", [], function* ({ click, settle, text }) {
507
- yield* click("button");
508
- yield* settle();
509
- expect(text("#worker")).toBe("Worker: since Oct 17");
510
- yield* TestClock.adjust("1 day");
511
- yield* click("button");
512
- yield* settle();
513
- expect(text("#worker")).toBe("Worker: since Oct 18");
514
- }, { clock: DateTime.makeUnsafe("2026-10-17T12:34:56.000Z") });
505
+ app.it(
506
+ "shows the worker's date",
507
+ [],
508
+ function* ({ click, settle, text }) {
509
+ yield* click("button");
510
+ yield* settle();
511
+ expect(text("#worker")).toBe("Worker: since Oct 17");
512
+ yield* TestClock.adjust("1 day");
513
+ yield* click("button");
514
+ yield* settle();
515
+ expect(text("#worker")).toBe("Worker: since Oct 18");
516
+ },
517
+ { clock: DateTime.makeUnsafe("2026-10-17T12:34:56.000Z") },
518
+ );
515
519
  ```
516
520
 
517
521
  Acquire hosts, workers and screens in per-story Scope so they inherit the story's Clock. An independent runtime or native HTTP handler must capture the Effect Context at acquisition, as with `HttpEffect.toWebHandlerWith(context)` or `Effect.runPromiseWith(context)`. Worker-scoped kit `layer` acquisition stays outside the per-story clock; shared services acquired there do not acquire a new clock for each story. Direct JavaScript wall-time reads are not replaced. Formatting stays with the application, including its locale and time zone.
518
522
 
519
- The [clock application stories](src/server/fixedClock.dom.spec.ts) run loopback HTTP, a queued worker that writes a timestamp to a file, and a DOM screen with its own Effect runner. They check exact timestamps and rendered dates, advancing time, and a live story without the option. A live-clock kit still runs on real time when a story omits the override.
523
+ A live-clock kit still runs on real time when a story omits the override.
520
524
 
521
525
  ### Running the engine
522
526
 
523
527
  Hooks and steps that wait for real workers can use `withLive(Effect.sleep(...))` or `withLive(eventually(...))` from `@shivaedev/test/withLive.ts` and `@shivaedev/test/eventually.ts`. Both work under the kit's live clock and a story's TestClock override. The wrapped work uses live time without advancing the story's virtual time; outside it, the selected clock still applies. Unwrapped `eventually` uses the active clock and advances TestClock between attempts.
524
528
 
525
529
  `story.runUntil(condition, { maxSteps })` returns an Effect that asks three questions before every step:
526
-
527
530
  1. `run.failed` returns a sentence: it dies with it, even when the condition also holds.
528
531
  2. The condition holds: it succeeds.
529
532
  3. `maxSteps` steps have run, or the kit's `run.maxSteps` when the call names none: it dies with `run.diagnose`.
@@ -540,7 +543,6 @@ That is what `oven.bakesEverything(12)` dies with when the baker keeps a sourdou
540
543
  ### When a story fails
541
544
 
542
545
  After the engine has been created, a failing story test adds the story to its first error, as in the examples above:
543
-
544
546
  - a short guide to reading the story, in a box;
545
547
  - every line in order, traits marked `given`;
546
548
  - `✗` after the last line, on the trait that refused, or alone when the test failed before the story told a line, and under it the spec line where the test stopped or that named the refusing trait;
@@ -569,28 +571,28 @@ For full-app stories, use `around: withIsolatedDatabase` from `@shivaedev/test-s
569
571
 
570
572
  For repository-level tests on a migrated template, `withTestTransaction` from `@shivaedev/test-sql/server/withTestTransaction.ts` provides rollback isolation when all work uses its transaction connection. See the [database test helpers](https://github.com/ShivaeDev/platform/blob/main/packages/test-sql/README.md) for template preparation and both wrappers.
571
573
 
572
- React screen traits acquire roots in Scope and use a fresh native atom registry for each screen. Cleanup unmounts roots before disposing registries and servers. Screen verbs dispatch DOM events and use bounded observations of rendered output. Select a live clock once on an HTTP/DOM kit; keep TestClock for deterministic local stories. `runUntil` is for engines with a meaningful step hook, not HTTP or DOM polling. Creation forms can use the same pattern with the existing `useCreate` path.
574
+ React screen traits acquire roots in Scope and use a fresh native atom registry for each screen. Cleanup unmounts roots before disposing registries and servers. Screen verbs dispatch DOM events and use bounded observations of rendered output. Select a live clock once on an HTTP/DOM kit; keep TestClock for deterministic local stories. `runUntil` is for engines with a meaningful step hook, not HTTP or DOM polling. Creation forms use the same pattern with `useCreate` from `@shivaedev/react/client/create.ts`.
573
575
 
574
576
  For cookie sessions, use the DOM host setup below. Native `RpcTest` can exercise handlers in faster local stories, but omits serialization and transport. Failure inspection is synchronous: keep redacted observed values in the engine instead of trying to query PostgreSQL inside `inspect`.
575
577
 
576
578
  ### DOM stories with cookie sessions
577
579
 
578
- Install `happy-dom@20.14.6` as a dev dependency. Select the `@shivaedev/test-story/server/domEnvironment.config.ts` Vitest environment for DOM tests that start their host in the same process:
580
+ Install `happy-dom` as a dev dependency. Select the `@shivaedev/test-story/server/domEnvironment.config.ts` Vitest environment for DOM tests that start their host in the same process:
579
581
 
580
582
  ```ts
581
583
  import { fileURLToPath } from "node:url";
582
584
  import { defineConfig } from "vitest/config";
583
585
 
584
586
  export default defineConfig({
585
- test: {
586
- environment: fileURLToPath(import.meta.resolve("@shivaedev/test-story/server/domEnvironment.config.ts")),
587
- },
587
+ test: {
588
+ environment: fileURLToPath(import.meta.resolve("@shivaedev/test-story/server/domEnvironment.config.ts")),
589
+ },
588
590
  });
589
591
  ```
590
592
 
591
593
  The environment keeps Node's global `fetch`, `Request`, `Response`, `Headers`, `AbortController` and `AbortSignal` for the in-process host. The separate `window` keeps happy-dom's constructors and cookie jar. Its asynchronous HTTP requests use Node fetch through the same `outbound` dispatcher, including XMLHttpRequest. Synchronous document HTTP requests are refused. The starter's [Vitest config](https://github.com/ShivaeDev/platform/blob/main/examples/starter/vitest.config.ts) selects this environment only for its DOM project while retaining the shared test projects. Use Vitest's standard forks or threads pool.
592
594
 
593
- `domFetch(baseUrl)` from `@shivaedev/test-story/server/domFetch.ts` sets the document's location to the real HTTP host and returns a document fetch that resolves relative request strings against that URL. It translates Node `Request` and `Headers` inputs for happy-dom. Responses have happy-dom's status, headers and body methods; they are not instances of Node's global `Response`. The document keeps and sends cookies, including HttpOnly session cookies. Keep the default `same-origin` credentials policy for same-origin requests, and pass this fetch explicitly to browser clients, such as Better Auth's `fetchOptions.customFetchImpl`. The host continues to use global Node fetch without browser cookies.
595
+ `domFetch(baseUrl)` from `@shivaedev/test-story/server/domFetch.ts` sets the document's location to the real HTTP host and returns a document fetch that resolves relative request strings against that URL. It translates Node `Request` and `Headers` inputs for happy-dom. Responses have happy-dom's status, headers and body methods; they are not instances of Node's global `Response`. The document keeps and sends cookies, including HttpOnly session cookies. Keep the default `same-origin` credentials policy for same-origin requests, and pass this fetch explicitly to browser clients, such as Better Auth's `fetchOptions.customFetchImpl`. The host uses global Node fetch without browser cookies.
594
596
 
595
597
  Call it in the kit's `create` hook after starting the host:
596
598
 
@@ -599,18 +601,18 @@ import { createAuthClient } from "better-auth/react";
599
601
  import { domFetch } from "@shivaedev/test-story/server/domFetch.ts";
600
602
 
601
603
  const cookieApp = storyKit({
602
- around: withIsolatedDatabase,
603
- clock: "live",
604
- *create() {
605
- const { baseUrl } = yield* startHost();
606
- const fetch = domFetch(baseUrl);
607
- const client = createAuthClient({ baseURL: baseUrl, fetchOptions: { customFetchImpl: fetch } });
608
- return { client, fetch };
609
- },
610
- layer: postgres,
611
- name: "cookie auth",
612
- stages: ["account"],
613
- verbs: ({ client, fetch }, story) => authVerbs(client, fetch, story.tell),
604
+ around: withIsolatedDatabase,
605
+ clock: "live",
606
+ *create() {
607
+ const { baseUrl } = yield* startHost();
608
+ const fetch = domFetch(baseUrl);
609
+ const client = createAuthClient({ baseURL: baseUrl, fetchOptions: { customFetchImpl: fetch } });
610
+ return { client, fetch };
611
+ },
612
+ layer: postgres,
613
+ name: "cookie auth",
614
+ stages: ["account"],
615
+ verbs: ({ client, fetch }, story) => authVerbs(client, fetch, story.tell),
614
616
  });
615
617
  ```
616
618
 
@@ -642,15 +644,19 @@ The starter's [social application kit](https://github.com/ShivaeDev/platform/blo
642
644
  The kit renders a Better Auth client whose `customFetchImpl` is `domFetch(baseUrl)`. The story calls `clickGitHubSignIn`, `settle` and `followRedirect` separately, then reads the heading, cookie and session. The screen driver settles on the screen's request state and reads the heading from the current document after navigation. The provider uses `fakeHttpService`. The authorize, token and user requests at the fake and a later session response provide evidence across the provider and application boundaries. The kit does not copy cookies into request headers.
643
645
 
644
646
  ```ts
645
- socialApp.it("a social sign-in returns with a cookie session", [], function* ({ clickGitHubSignIn, settle, followRedirect, heading, cookie, session }) {
646
- yield* clickGitHubSignIn();
647
- yield* settle();
648
- const response = yield* followRedirect();
649
- expect(response.status).toBe(200);
650
- expect(heading()).toBe("Signed in as alice@social.test");
651
- expect(cookie()).not.toContain("session_token");
652
- expect(yield* session()).toMatchObject({ user: { email: "alice@social.test" } });
653
- });
647
+ socialApp.it(
648
+ "a social sign-in returns with a cookie session",
649
+ [],
650
+ function* ({ clickGitHubSignIn, settle, followRedirect, heading, cookie, session }) {
651
+ yield* clickGitHubSignIn();
652
+ yield* settle();
653
+ const response = yield* followRedirect();
654
+ expect(response.status).toBe(200);
655
+ expect(heading()).toBe("Signed in as alice@social.test");
656
+ expect(cookie()).not.toContain("session_token");
657
+ expect(yield* session()).toMatchObject({ user: { email: "alice@social.test" } });
658
+ },
659
+ );
654
660
  ```
655
661
 
656
662
  `domFetch` uses the current window and its cookie jar; it does not isolate multiple users. Run stories using that window serially, and let the application's cleanup end its sessions, restore the page location and close its host. Cookies follow hostnames, not listener ports, so a different loopback port alone does not isolate accounts.
@@ -664,16 +670,17 @@ To use `settle()`, supply a `pending()` function that reads the application's ow
664
670
  ```ts
665
671
  import { screenDriver } from "@shivaedev/test-story/server/screenDriver.ts";
666
672
 
667
- verbs: ({ view, requests }, story) => screenDriver({
668
- root: view.container,
669
- pending: () => requests.pending,
670
- tell: story.tell,
671
- })
673
+ verbs: ({ view, requests }, story) =>
674
+ screenDriver({
675
+ root: view.container,
676
+ pending: () => requests.pending,
677
+ tell: story.tell,
678
+ });
672
679
  ```
673
680
 
674
681
  `click(selector)`, `enter(selector, value)` and `submit(selector = "form")` return Effects. Selectors identify exactly one descendant of the root; missing or ambiguous controls fail. Hidden targets and targets inside hidden ancestors refuse actions and readouts. Text entry focuses an input or textarea and dispatches input and change events. Disabled controls refuse clicks and entry, inert ancestors also prevent form submission, and read-only fields refuse entry. Actions do not wait for settlement, so a story can release a held request before calling `settle()`.
675
682
 
676
- `text(selector?)` returns rendered text from the selected element or the whole root. `value(selector)` returns the current input or textarea value. Both narrate what they read through `tell` and leave assertions to the spec. Entry narration omits the supplied value.
683
+ `text(selector?)` concatenates visible HTML text nodes from the selected element or the whole root, without CSS text transforms or layout line breaks. `value(selector)` returns the current input or textarea value. Both narrate what they read through `tell` and leave assertions to the spec. Entry narration omits the supplied value.
677
684
 
678
685
  `click`, `enter`, `submit`, `text` and `value` also accept a `ScreenTarget` object such as `{ role: "button", name: "Save" }` or `{ role: "textbox", name: /email/i }`. The role and computed accessible name must match exactly when strings are used; regular expressions match the name. Like Testing Library's role queries, these targets exclude hidden elements, including `aria-hidden` ancestors. Missing or ambiguous targets fail with the requested role, name and the visible candidates on screen. Narration names the role and name instead of a selector.
679
686
 
@@ -683,39 +690,38 @@ verbs: ({ view, requests }, story) => screenDriver({
683
690
 
684
691
  `accessible(element)` uses the same computation on an `Element` the kit already holds and tells no story line.
685
692
 
686
- For React, pass `act: async (action) => { await act(action); }` using React's `act`. The adapter wraps each action and flushes renderer work before checking the pending signal, including while waiting for an asynchronous response. The [React driver stories](https://github.com/ShivaeDev/platform/blob/main/packages/react/src/screenDriver.dom.spec.tsx) cover a native pending atom, a rendered response and a controlled field without React warnings. The driver itself has no renderer dependency.
693
+ For React, pass `act: async (action) => { await act(action); }` using React's `act`. The adapter wraps each action and flushes renderer work before checking the pending signal, including while waiting for an asynchronous response. The driver itself has no renderer dependency.
687
694
 
688
- Settlement has a live-time limit of 3 seconds, configurable with the driver's `timeoutMs` or per call with `settle({ timeoutMs })`, and fails with the current screen text and advice when that limit expires. Use the existing DOM environment and scoped `routeOutbound` routing to reach `fakeHttpService`; the driver does not install another transport. The [screen stories](src/server/screenSignals.dom.spec.ts) hold a real HTTP response across repeated renders and sign in by filling and submitting a form against a fake identity provider. These fixtures prove DOM interactions and loopback HTTP, not a browser or a production authentication system.
695
+ Settlement has a live-time limit of 3 seconds, configurable with the driver's `timeoutMs` or per call with `settle({ timeoutMs })`, and fails with the current screen text and advice when that limit expires. Use the DOM environment above and scoped `routeOutbound` routing to reach `fakeHttpService`; the driver does not install another transport. The driver acts on happy-dom over loopback HTTP; it does not drive a real browser.
689
696
 
690
697
  ### API by module
691
698
 
692
699
  Import each module with the prefix `@shivaedev/test-story/`; there is no root entry.
693
700
 
694
- | Module | Exports |
695
- | --- | --- |
696
- | `server/storyKit.ts` | `storyKit`, `Trait`, `RunUntilOptions`, `Story`, `RunHooks`, `StoryKitDefinition`, `Told`, `StoryBody`, `StoryTest`, `StoryIt`, `StoryKit` |
697
- | `server/outcomes.ts` | `outcomes(rows)` |
698
- | `server/domFetch.ts` | `domFetch(baseUrl)` |
699
- | `server/seedCookies.ts` | `seedCookies(cookies)`, `DomCookie` |
700
- | `server/routeOutbound.ts` | `routeOutbound(routes)` |
701
- | `server/screenDriver.ts` | `screenDriver(options)`, `ScreenDriverOptions`, `ScreenDriver`, `ScreenTarget`, `MissingScreenPending` |
702
- | `server/domNavigate.ts` | `domNavigate(url?)` |
703
- | `server/genreTags.ts` | `genreTags(...kitNames)`, `GenreTag` |
704
- | `server/domEnvironment.config.ts` | Default Vitest environment preserving Node host globals and happy-dom document transport |
705
- | `server/fakeHttpService.ts` | `fakeHttpService(options)`, `FakeHttpRoute`, `FakeHttpRequest`, `FakeHttpRequestRecord` (`status`: number, `"pending"` or `"unanswered"`), `FakeHttpReply`, `FakeHttpReplySource` (fixed or request/time function), `FakeHttpFault`, `FakeHttpHold`, `FakeHttpHoldOptions` (`params`, `once`), `FakeHttpScope`, `FakeHttpScriptOptions`, `FakeHttpScript`, `FakeHttpServiceOptions`; reply functions receive `(request, now)`, request records expose answered statuses, holds accept a scope and `once`, `releaseOnArrival` accepts a held scope, and routes accept final `:name*` rest params |
706
- | `server/forwardingProxy.ts` | `forwardingProxy(upstream, options?)`, `ForwardingProxyOptions` |
707
- | `server/otlpReceiver.ts` | `otlpReceiver(options?)`, `OtlpSpan`, `OtlpExport`, `OtlpReceiverOptions` |
701
+ | Module | Exports |
702
+ | --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
703
+ | `server/storyKit.ts` | `storyKit`, `Trait`, `RunUntilOptions`, `Story`, `RunHooks`, `StoryKitDefinition`, `Told`, `StoryBody`, `StoryTest`, `StoryIt`, `StoryKit` |
704
+ | `server/outcomes.ts` | `outcomes(rows)` |
705
+ | `server/domFetch.ts` | `domFetch(baseUrl)` |
706
+ | `server/seedCookies.ts` | `seedCookies(cookies)`, `DomCookie` |
707
+ | `server/routeOutbound.ts` | `routeOutbound(routes)` |
708
+ | `server/screenDriver.ts` | `screenDriver(options)`, `ScreenDriverOptions`, `ScreenDriver`, `ScreenTarget`, `MissingScreenPending` |
709
+ | `server/domNavigate.ts` | `domNavigate(url?)` |
710
+ | `server/genreTags.ts` | `genreTags(...kitNames)`, `GenreTag` |
711
+ | `server/domEnvironment.config.ts` | Default Vitest environment preserving Node host globals and happy-dom document transport |
712
+ | `server/fakeHttpService.ts` | `fakeHttpService(options)`, `FakeHttpRoute`, `FakeHttpRequest`, `FakeHttpRequestRecord` (`status`: number, `"pending"` or `"unanswered"`), `FakeHttpReply`, `FakeHttpReplySource` (fixed or request/time function), `FakeHttpFault`, `FakeHttpHold`, `FakeHttpHoldOptions` (`params`, `once`), `FakeHttpScope`, `FakeHttpScriptOptions`, `FakeHttpScript`, `FakeHttpServiceOptions` |
713
+ | `server/forwardingProxy.ts` | `forwardingProxy(upstream, options?)`, `ForwardingProxyOptions` |
714
+ | `server/otlpReceiver.ts` | `otlpReceiver(options?)`, `OtlpSpan`, `OtlpExport`, `OtlpReceiverOptions` |
708
715
 
709
716
  ### Install and limits
710
717
 
711
718
  ```sh
712
- pnpm add --save-dev @shivaedev/test-story @effect/platform-node@4.0.5 @effect/vitest@4.0.5 effect@4.0.5 vitest@5.0.3
719
+ pnpm add --save-dev @shivaedev/test-story @effect/platform-node @effect/vitest effect vitest
713
720
  ```
714
721
 
715
722
  `@effect/platform-node`, `@effect/vitest`, `effect` and `vitest` are peers, so the application's own versions run the stories. The Node adapter supplies the digest implementation retained by `TestCrypto`.
716
723
 
717
724
  Test-story is an application's one test dependency: it brings [`@shivaedev/test`](https://github.com/ShivaeDev/platform/tree/main/packages/test#readme) and [`@shivaedev/test-sql`](https://github.com/ShivaeDev/platform/tree/main/packages/test-sql#readme), which an application on `@shivaedev/platform` imports by their own names without listing them. `@effect/sql-pg` is an optional peer for `test-sql`'s PostgreSQL helpers; install it when the stories use them. A library that tests with test-story still declares `test` or `test-sql` directly when it imports them.
718
-
719
725
  - The package runs inside Vitest. The story reaches the failure by rewriting the first error's message in Vitest's `onTestFailed` hook.
720
726
  - Layer acquisition and engine creation failures precede that hook and carry no story appendix. A printed rerun command still needs a Vitest configuration that collects its file.
721
727
  - A kit's `it` is created when the kit is defined, so a kit lives in a module that only Vitest test files import.
@@ -1 +1 @@
1
- {"version":3,"file":"forwardingProxy.d.ts","sourceRoot":"","sources":["../../src/server/forwardingProxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,eAAe;;uCAuC1B,CAAC"}
1
+ {"version":3,"file":"forwardingProxy.d.ts","sourceRoot":"","sources":["../../src/server/forwardingProxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,eAAe;;uCAyE1B,CAAC"}
@@ -7,8 +7,8 @@ export const forwardingProxy = Effect.fnUntraced(function* (upstream, options =
7
7
  if (options.localAddress !== undefined) {
8
8
  yield* Effect.scoped(loopbackServer(createServer(), { host: options.localAddress })).pipe(Effect.mapError((cause) => new Error(`Cannot acquire forwarding proxy with local address ${options.localAddress}`, { cause })));
9
9
  }
10
- const forward = (incoming, response) => {
11
- const outgoing = request(`${upstream}${incoming.url}`, {
10
+ function requestOptions(incoming) {
11
+ return {
12
12
  family: options.localAddress === undefined ? undefined : isIP(options.localAddress),
13
13
  headers: {
14
14
  ...incoming.headers,
@@ -19,7 +19,10 @@ export const forwardingProxy = Effect.fnUntraced(function* (upstream, options =
19
19
  },
20
20
  localAddress: options.localAddress,
21
21
  method: incoming.method,
22
- }, (result) => {
22
+ };
23
+ }
24
+ const forward = (incoming, response) => {
25
+ const outgoing = request(`${upstream}${incoming.url}`, requestOptions(incoming), (result) => {
23
26
  response.writeHead(result.statusCode ?? HttpStatus.fromLiteral("BadGateway"), result.headers);
24
27
  result.pipe(response);
25
28
  });
@@ -34,8 +37,41 @@ export const forwardingProxy = Effect.fnUntraced(function* (upstream, options =
34
37
  response.on("close", () => outgoing.destroy());
35
38
  incoming.pipe(outgoing);
36
39
  };
37
- const url = yield* loopbackServer(createServer(forward));
38
- yield* loopbackServer(createServer(forward), { host: "::1", port: Number(new URL(url).port) });
40
+ const sockets = new Set();
41
+ function server() {
42
+ return createServer(forward).on("upgrade", (incoming, downstream, head) => {
43
+ sockets.add(downstream);
44
+ downstream.on("close", () => sockets.delete(downstream));
45
+ const outgoing = request(`${upstream}${incoming.url}`, requestOptions(incoming));
46
+ outgoing.on("upgrade", (result, upstreamSocket, upstreamHead) => {
47
+ downstream.write(`HTTP/1.1 ${result.statusCode} ${result.statusMessage}\r\n`);
48
+ for (let index = 0; index < result.rawHeaders.length; index += 2) {
49
+ downstream.write(`${result.rawHeaders[index]}: ${result.rawHeaders[index + 1]}\r\n`);
50
+ }
51
+ downstream.write("\r\n");
52
+ downstream.write(upstreamHead);
53
+ upstreamSocket.write(head);
54
+ downstream.pipe(upstreamSocket).pipe(downstream);
55
+ downstream.on("close", () => upstreamSocket.destroy());
56
+ upstreamSocket.on("error", () => downstream.destroy());
57
+ });
58
+ outgoing.on("response", (result) => {
59
+ downstream.end(`HTTP/1.1 ${result.statusCode} ${result.statusMessage}\r\nConnection: close\r\n\r\n`);
60
+ result.resume();
61
+ });
62
+ outgoing.on("error", () => downstream.destroy());
63
+ downstream.on("error", () => outgoing.destroy());
64
+ downstream.on("close", () => outgoing.destroy());
65
+ outgoing.end();
66
+ });
67
+ }
68
+ const url = yield* loopbackServer(server());
69
+ yield* loopbackServer(server(), { host: "::1", port: Number(new URL(url).port) });
70
+ yield* Effect.addFinalizer(() => Effect.sync(() => {
71
+ for (const socket of sockets) {
72
+ socket.destroy();
73
+ }
74
+ }));
39
75
  return { url };
40
76
  });
41
77
  //# sourceMappingURL=forwardingProxy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"forwardingProxy.js","sourceRoot":"","sources":["../../src/server/forwardingProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,OAAO,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAQvD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,QAAgB,EAAE,OAAO,GAA2B,EAAE;IACjH,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACxC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CACxF,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,sDAAsD,OAAO,CAAC,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAC9H,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;QACvD,MAAM,QAAQ,GAAG,OAAO,CACvB,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAAG,EAAE,EAC5B;YACC,MAAM,EAAE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C,GAAG,EAAE;QAChB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC9B,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;IACF,CAAC,CAAC,CACF,CAAC;IACF,OAAO,EAAE,GAAG,EAAE,CAAC;AAChB,CAAC,CAAC,CAAC"}
@@ -6,5 +6,6 @@ export declare function screenElements(root: () => HTMLElement): {
6
6
  form: (selector: ScreenTarget) => HTMLFormElement;
7
7
  input: (selector: ScreenTarget) => HTMLInputElement | HTMLTextAreaElement;
8
8
  rendered: (found: HTMLElement, selector: string) => HTMLElement;
9
+ text: (found: HTMLElement) => string;
9
10
  };
10
11
  //# sourceMappingURL=screenElements.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenElements.d.ts","sourceRoot":"","sources":["../../../src/server/internal/screenElements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,WAAW;wBAO1B,YAAY;qBAsBf,WAAW,YAAY,YAAY;sBAQxC,YAAY,SAAS,MAAM;qBAY5B,YAAY;sBA7BL,YAAY;sBAnBZ,WAAW,YAAY,MAAM;EA2DtD"}
1
+ {"version":3,"file":"screenElements.d.ts","sourceRoot":"","sources":["../../../src/server/internal/screenElements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,WAAW;wBAO1B,YAAY;qBAsBf,WAAW,YAAY,YAAY;sBAkBxC,YAAY,SAAS,MAAM;qBAY5B,YAAY;sBAvCL,YAAY;sBAnBZ,WAAW,YAAY,MAAM;kBAiCjC,WAAW,KAAG,MAAM;EAqCzC"}
@@ -29,6 +29,16 @@ export function screenElements(root) {
29
29
  throw new Error(`The screen's ${targetName(selector)} is disabled.\nhelp: Wait for the app to enable the control before acting on it.`);
30
30
  }
31
31
  }
32
+ function text(found) {
33
+ const walker = found.ownerDocument.createTreeWalker(found, NodeFilter.SHOW_TEXT);
34
+ const parts = [];
35
+ for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
36
+ if (node.parentElement instanceof HTMLElement && isRendered(node.parentElement)) {
37
+ parts.push(node.textContent ?? "");
38
+ }
39
+ }
40
+ return parts.join("");
41
+ }
32
42
  return {
33
43
  element,
34
44
  enabled,
@@ -54,6 +64,7 @@ export function screenElements(root) {
54
64
  },
55
65
  input,
56
66
  rendered,
67
+ text,
57
68
  };
58
69
  }
59
70
  //# sourceMappingURL=screenElements.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenElements.js","sourceRoot":"","sources":["../../../src/server/internal/screenElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAGvF,MAAM,UAAU,cAAc,CAAC,IAAuB;IACrD,SAAS,QAAQ,CAAC,KAAkB,EAAE,QAAgB;QACrD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,gBAAgB,QAAQ,8FAA8F,CAAC,CAAC;QACzI,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,SAAS,OAAO,CAAC,QAAsB;QACtC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAClC,OAAO,WAAW,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,EAAE,CAAC,gBAAgB,CAAc,QAAQ,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CACd,kBAAkB,OAAO,CAAC,MAAM,gBAAgB,IA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AAC,QAAQ,CAAC,CAAC;YAChC,IAAI,CAAC,CAAC,KAAK,YAAY,eAAe,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,gBAAgB,UAAU,CAAC,QAAQ,CAAC,0DAA0D,CAAC,CAAC;YACjH,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC;QACD,KAAK;QACL,QAAQ;QACR,IAAI;KACJ,CAAC;AACH,CAAC"}
@@ -71,7 +71,7 @@ function makeScreenDriver({ root, pending, tell, act = (action) => action(), tim
71
71
  settle,
72
72
  submit: (selector = "form") => perform(`submit ${targetName(selector)}`, () => elements.form(selector).requestSubmit()),
73
73
  text: (selector) => {
74
- const text = (selector === undefined ? elements.rendered(currentRoot(), "root") : elements.element(selector)).innerText;
74
+ const text = elements.text(selector === undefined ? elements.rendered(currentRoot(), "root") : elements.element(selector));
75
75
  tell(`read ${selector === undefined ? "the screen" : targetName(selector)}: ${JSON.stringify(text)}`);
76
76
  return text;
77
77
  },
@@ -1 +1 @@
1
- {"version":3,"file":"screenDriver.js","sourceRoot":"","sources":["../../src/server/screenDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAY7D,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC;IAC/D,OAAO,GACxB,wMAAwM,CAAC;CAC1M;AAQD,MAAM,UAAU,YAAY,CAAC,OAA4B;IACxD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAE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AAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3H,IAAI,CAAC,QAAQ,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtG,OAAO,IAAI,CAAC;QACb,CAAC;QACD,KAAK,EAAE,CAAC,QAAsB,EAAE,EAAE;YACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;YAC7C,IAAI,CAAC,qBAAqB,UAAU,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5E,OAAO,KAAK,CAAC;QACd,CAAC;KACD,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/test-story",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Tests that read like stories over the real engine: a story kit per engine with its own it, traits per feature, and a failure that prints the story, where it stopped and the engine's state",
5
5
  "homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/test-story#readme",
6
6
  "bugs": {
@@ -48,7 +48,7 @@
48
48
  "devDependencies": {
49
49
  "@effect/platform-node": "4.0.5",
50
50
  "@effect/vitest": "4.0.5",
51
- "@shivaedev/quality": "0.43.0",
51
+ "@shivaedev/quality": "0.44.1",
52
52
  "@types/node": "24.19.2",
53
53
  "effect": "4.0.5",
54
54
  "happy-dom": "21.0.4",
@@ -1,5 +1,6 @@
1
- import { createServer, type RequestListener, request } from "node:http";
1
+ import { createServer, type IncomingMessage, type RequestListener, request } from "node:http";
2
2
  import { isIP } from "node:net";
3
+ import type { Duplex } from "node:stream";
3
4
  import { Effect } from "effect";
4
5
  import * as HttpStatus from "effect/http/HttpStatus";
5
6
  import { loopbackServer } from "#internal/loopback.ts";
@@ -16,26 +17,25 @@ export const forwardingProxy = Effect.fnUntraced(function* (upstream: string, op
16
17
  Effect.mapError((cause) => new Error(`Cannot acquire forwarding proxy with local address ${options.localAddress}`, { cause })),
17
18
  );
18
19
  }
19
- const forward: RequestListener = (incoming, response) => {
20
- const outgoing = request(
21
- `${upstream}${incoming.url}`,
22
- {
23
- family: options.localAddress === undefined ? undefined : isIP(options.localAddress),
24
- headers: {
25
- ...incoming.headers,
26
- "x-forwarded-for": [incoming.headers["x-forwarded-for"], ...(options.forwardedHops ?? [incoming.socket.remoteAddress])]
27
- .filter(Boolean)
28
- .join(", "),
29
- ...options.headers,
30
- },
31
- localAddress: options.localAddress,
32
- method: incoming.method,
33
- },
34
- (result) => {
35
- response.writeHead(result.statusCode ?? HttpStatus.fromLiteral("BadGateway"), result.headers);
36
- result.pipe(response);
20
+ function requestOptions(incoming: IncomingMessage) {
21
+ return {
22
+ family: options.localAddress === undefined ? undefined : isIP(options.localAddress),
23
+ headers: {
24
+ ...incoming.headers,
25
+ "x-forwarded-for": [incoming.headers["x-forwarded-for"], ...(options.forwardedHops ?? [incoming.socket.remoteAddress])]
26
+ .filter(Boolean)
27
+ .join(", "),
28
+ ...options.headers,
37
29
  },
38
- );
30
+ localAddress: options.localAddress,
31
+ method: incoming.method,
32
+ };
33
+ }
34
+ const forward: RequestListener = (incoming, response) => {
35
+ const outgoing = request(`${upstream}${incoming.url}`, requestOptions(incoming), (result) => {
36
+ response.writeHead(result.statusCode ?? HttpStatus.fromLiteral("BadGateway"), result.headers);
37
+ result.pipe(response);
38
+ });
39
39
  outgoing.on("error", (error) => {
40
40
  if (response.headersSent) {
41
41
  response.destroy(error);
@@ -46,7 +46,42 @@ export const forwardingProxy = Effect.fnUntraced(function* (upstream: string, op
46
46
  response.on("close", () => outgoing.destroy());
47
47
  incoming.pipe(outgoing);
48
48
  };
49
- const url = yield* loopbackServer(createServer(forward));
50
- yield* loopbackServer(createServer(forward), { host: "::1", port: Number(new URL(url).port) });
49
+ const sockets = new Set<Duplex>();
50
+ function server() {
51
+ return createServer(forward).on("upgrade", (incoming, downstream, head) => {
52
+ sockets.add(downstream);
53
+ downstream.on("close", () => sockets.delete(downstream));
54
+ const outgoing = request(`${upstream}${incoming.url}`, requestOptions(incoming));
55
+ outgoing.on("upgrade", (result, upstreamSocket, upstreamHead) => {
56
+ downstream.write(`HTTP/1.1 ${result.statusCode} ${result.statusMessage}\r\n`);
57
+ for (let index = 0; index < result.rawHeaders.length; index += 2) {
58
+ downstream.write(`${result.rawHeaders[index]}: ${result.rawHeaders[index + 1]}\r\n`);
59
+ }
60
+ downstream.write("\r\n");
61
+ downstream.write(upstreamHead);
62
+ upstreamSocket.write(head);
63
+ downstream.pipe(upstreamSocket).pipe(downstream);
64
+ downstream.on("close", () => upstreamSocket.destroy());
65
+ upstreamSocket.on("error", () => downstream.destroy());
66
+ });
67
+ outgoing.on("response", (result) => {
68
+ downstream.end(`HTTP/1.1 ${result.statusCode} ${result.statusMessage}\r\nConnection: close\r\n\r\n`);
69
+ result.resume();
70
+ });
71
+ outgoing.on("error", () => downstream.destroy());
72
+ downstream.on("error", () => outgoing.destroy());
73
+ downstream.on("close", () => outgoing.destroy());
74
+ outgoing.end();
75
+ });
76
+ }
77
+ const url = yield* loopbackServer(server());
78
+ yield* loopbackServer(server(), { host: "::1", port: Number(new URL(url).port) });
79
+ yield* Effect.addFinalizer(() =>
80
+ Effect.sync(() => {
81
+ for (const socket of sockets) {
82
+ socket.destroy();
83
+ }
84
+ }),
85
+ );
51
86
  return { url };
52
87
  });
@@ -35,6 +35,16 @@ export function screenElements(root: () => HTMLElement) {
35
35
  throw new Error(`The screen's ${targetName(selector)} is disabled.\nhelp: Wait for the app to enable the control before acting on it.`);
36
36
  }
37
37
  }
38
+ function text(found: HTMLElement): string {
39
+ const walker = found.ownerDocument.createTreeWalker(found, NodeFilter.SHOW_TEXT);
40
+ const parts: string[] = [];
41
+ for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
42
+ if (node.parentElement instanceof HTMLElement && isRendered(node.parentElement)) {
43
+ parts.push(node.textContent ?? "");
44
+ }
45
+ }
46
+ return parts.join("");
47
+ }
38
48
  return {
39
49
  element,
40
50
  enabled,
@@ -60,5 +70,6 @@ export function screenElements(root: () => HTMLElement) {
60
70
  },
61
71
  input,
62
72
  rendered,
73
+ text,
63
74
  };
64
75
  }
@@ -101,7 +101,7 @@ function makeScreenDriver({ root, pending, tell, act = (action) => action(), tim
101
101
  settle,
102
102
  submit: (selector: ScreenTarget = "form") => perform(`submit ${targetName(selector)}`, () => elements.form(selector).requestSubmit()),
103
103
  text: (selector?: ScreenTarget) => {
104
- const text = (selector === undefined ? elements.rendered(currentRoot(), "root") : elements.element(selector)).innerText;
104
+ const text = elements.text(selector === undefined ? elements.rendered(currentRoot(), "root") : elements.element(selector));
105
105
  tell(`read ${selector === undefined ? "the screen" : targetName(selector)}: ${JSON.stringify(text)}`);
106
106
  return text;
107
107
  },