@stardeck-customer-apps/testing 0.19.0 → 0.21.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/SKILL.md +26 -21
- package/dist/index.d.mts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +297 -54
- package/dist/index.mjs +283 -30
- package/dist/setup.js +53 -7
- package/dist/setup.mjs +53 -7
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -293,32 +293,32 @@ expect(app.edge.latestDisplay()?.action).toBe("show");
|
|
|
293
293
|
- `schemaSql` — inline DDL instead of a file.
|
|
294
294
|
- `seed(db)` — seed rows; re-runs on every `reset()`.
|
|
295
295
|
- `allowNetwork` — permit non-Stardeck outbound fetches (off by default).
|
|
296
|
-
- `app.reset()` —
|
|
297
|
-
Call in `beforeEach`.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
296
|
+
- `app.reset()` — restore the database to its state right after schema + seed,
|
|
297
|
+
and clear inbox/sessions/simulator state. Call in `beforeEach`.
|
|
298
|
+
Since testing SDK **0.20.0** it restores the rows the schema script inserted
|
|
299
|
+
and every sequence and identity value without firing app triggers, then
|
|
300
|
+
re-runs the seed, in about a fifth of the time of the old schema rebuild. If a
|
|
301
|
+
test ran DDL (CREATE, ALTER, DROP), the next reset rebuilds the schema
|
|
302
|
+
instead, so tests never need to choose a mode. DDL in the seed stays on the
|
|
303
|
+
fast path when it can run twice (`CREATE TABLE IF NOT EXISTS`); a seed that
|
|
304
|
+
fails on its second run makes every reset a rebuild.
|
|
305
|
+
`app.reset({ mode: "schema" })` forces the full rebuild; `mode: "data"` is an
|
|
306
|
+
older spelling of the default.
|
|
304
307
|
|
|
305
308
|
```ts
|
|
306
|
-
|
|
307
|
-
beforeEach(() => app.reset({ mode: "data" }));
|
|
309
|
+
beforeEach(() => app.reset());
|
|
308
310
|
```
|
|
309
311
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
Data mode refuses foreign keys requiring a cross-schema cascade. Database and
|
|
317
|
-
seed errors reject the reset; fix them before running the next test.
|
|
312
|
+
Reset never
|
|
313
|
+
cascades into tables outside `public`: a foreign key from another schema into
|
|
314
|
+
a `public` table rejects the reset with Postgres error `0A000`.
|
|
315
|
+
The first `createTestApp` for a schema saves a database snapshot under
|
|
316
|
+
`node_modules/.cache/stardeck-testing/`; later test files boot from it.
|
|
317
|
+
Deleting that directory is always safe.
|
|
318
318
|
|
|
319
319
|
Do not use `it.concurrent` or `test.concurrent` with a shared test app: user,
|
|
320
320
|
database, and simulator state are shared within the file. Keep file isolation
|
|
321
|
-
enabled and let Vitest parallelize files.
|
|
321
|
+
enabled and let Vitest parallelize files. Reset does not change workers
|
|
322
322
|
or the platform's test-run deadline.
|
|
323
323
|
|
|
324
324
|
- `app.asUser(partial?)` — sign in a test user; `getSession()` in app code
|
|
@@ -530,8 +530,13 @@ cursor, limit })`; `list()` intentionally keeps its previous array shape.
|
|
|
530
530
|
production) or `app.starlens.reject("not a receipt")` (the 422 the SDK maps to
|
|
531
531
|
`UnsupportedDocumentError`). An unregistered call fails with a descriptive 502 so a
|
|
532
532
|
test never passes on an invented extraction. `app.starlens.calls` records each
|
|
533
|
-
request's version, input names/media types (never bytes), schema and
|
|
534
|
-
instructions — assert your `.describe()` aliases
|
|
533
|
+
request's version, effort, input names/media types (never bytes), schema and
|
|
534
|
+
instructions — assert your `.describe()` aliases and `effort: "high"` retries
|
|
535
|
+
reached the wire there. `version: "v1"` with `effort: "high"` is refused with the
|
|
536
|
+
same 400 `unsupported_effort` as production (the SDK throws `ValidationError`). A
|
|
537
|
+
high request with no image input answers `effort: "low"` as production does;
|
|
538
|
+
pass `effort: "low"` in `app.starlens.mock(...)` to simulate an image production
|
|
539
|
+
could not decode.
|
|
535
540
|
|
|
536
541
|
### Receipt layout and printer capabilities
|
|
537
542
|
|
package/dist/index.d.mts
CHANGED
|
@@ -536,7 +536,10 @@ interface TestEdge {
|
|
|
536
536
|
}
|
|
537
537
|
/** One Starlens request the app made, as the simulator saw it (names only, never bytes). */
|
|
538
538
|
interface CapturedStarlensCall {
|
|
539
|
+
/** As sent (`latest` stays `latest`). */
|
|
539
540
|
version: string;
|
|
541
|
+
/** As requested; `"low"` when the app did not set one. The reply says what ran. */
|
|
542
|
+
effort: "low" | "high";
|
|
540
543
|
inputs: {
|
|
541
544
|
name: string;
|
|
542
545
|
mediaType: string | null;
|
|
@@ -557,6 +560,12 @@ type StarlensReply = {
|
|
|
557
560
|
path: string;
|
|
558
561
|
reason: string;
|
|
559
562
|
}[];
|
|
563
|
+
/**
|
|
564
|
+
* The effort the reply says ran. Defaults to the requested effort, or `"low"` for a
|
|
565
|
+
* high request with no image input (production cannot crop a PDF, audio or video).
|
|
566
|
+
* Set `"low"` to simulate a high request on an image production could not decode.
|
|
567
|
+
*/
|
|
568
|
+
effort?: "low" | "high";
|
|
560
569
|
} | {
|
|
561
570
|
reject: string;
|
|
562
571
|
};
|
|
@@ -633,10 +642,10 @@ interface TestApp {
|
|
|
633
642
|
*/
|
|
634
643
|
issueSession(user?: Partial<TestUser>): SessionTokens;
|
|
635
644
|
/**
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
645
|
+
* Restore the rows and sequence values the schema script left, re-run the
|
|
646
|
+
* seed, and clear simulator/user state. Any DDL since the last reset triggers a full
|
|
647
|
+
* schema rebuild instead. `mode: "schema"` forces the rebuild; `mode: "data"`
|
|
648
|
+
* is an older spelling of the default.
|
|
640
649
|
*/
|
|
641
650
|
reset(options?: {
|
|
642
651
|
mode: "schema" | "data";
|
package/dist/index.d.ts
CHANGED
|
@@ -536,7 +536,10 @@ interface TestEdge {
|
|
|
536
536
|
}
|
|
537
537
|
/** One Starlens request the app made, as the simulator saw it (names only, never bytes). */
|
|
538
538
|
interface CapturedStarlensCall {
|
|
539
|
+
/** As sent (`latest` stays `latest`). */
|
|
539
540
|
version: string;
|
|
541
|
+
/** As requested; `"low"` when the app did not set one. The reply says what ran. */
|
|
542
|
+
effort: "low" | "high";
|
|
540
543
|
inputs: {
|
|
541
544
|
name: string;
|
|
542
545
|
mediaType: string | null;
|
|
@@ -557,6 +560,12 @@ type StarlensReply = {
|
|
|
557
560
|
path: string;
|
|
558
561
|
reason: string;
|
|
559
562
|
}[];
|
|
563
|
+
/**
|
|
564
|
+
* The effort the reply says ran. Defaults to the requested effort, or `"low"` for a
|
|
565
|
+
* high request with no image input (production cannot crop a PDF, audio or video).
|
|
566
|
+
* Set `"low"` to simulate a high request on an image production could not decode.
|
|
567
|
+
*/
|
|
568
|
+
effort?: "low" | "high";
|
|
560
569
|
} | {
|
|
561
570
|
reject: string;
|
|
562
571
|
};
|
|
@@ -633,10 +642,10 @@ interface TestApp {
|
|
|
633
642
|
*/
|
|
634
643
|
issueSession(user?: Partial<TestUser>): SessionTokens;
|
|
635
644
|
/**
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
645
|
+
* Restore the rows and sequence values the schema script left, re-run the
|
|
646
|
+
* seed, and clear simulator/user state. Any DDL since the last reset triggers a full
|
|
647
|
+
* schema rebuild instead. `mode: "schema"` forces the rebuild; `mode: "data"`
|
|
648
|
+
* is an older spelling of the default.
|
|
640
649
|
*/
|
|
641
650
|
reset(options?: {
|
|
642
651
|
mode: "schema" | "data";
|