@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 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()` — wipe + re-apply schema + re-seed + clear inbox/sessions.
297
- Call in `beforeEach`.
298
- - `app.reset({ mode: "data" })` — available in testing SDK **0.14.0+**. Faster
299
- opt-in for stable schemas: truncate ordinary tables in `public`, restart their
300
- owned serial/identity sequences, re-run the data-only seed, and clear the same
301
- simulator/user/session state as the default. It preserves tables and other
302
- schema objects instead of rebuilding them. The default remains full schema
303
- reset; `app.reset({ mode: "schema" })` explicitly selects that default.
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
- // Only after verifying this suite keeps its schema fixed and uses a data-only seed:
307
- beforeEach(() => app.reset({ mode: "data" }));
309
+ beforeEach(() => app.reset());
308
310
  ```
309
311
 
310
- Keep `app.reset()` for tests that change schema or depend on INSERTs in the
311
- schema script. Also keep full reset for independent sequences, materialized
312
- views, partitioned/foreign tables, temporary tables, and custom triggers or
313
- cross-schema dependencies. Data mode does not restore those states or detect
314
- eligibility; inspect both the tests and seed before opting in. All required
315
- baseline rows must come from the data-only seed callback, not schema SQL.
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. This option does not change workers
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 reached the wire there.
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
- * Rebuild the schema (default), re-run the seed, and clear simulator/user state.
637
- * `mode: "data"` instead truncates ordinary public tables and restarts owned
638
- * sequences. Use only with a stable schema and data-only seed; it does not
639
- * restore DDL changes, schema-script data, or independent sequences.
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
- * Rebuild the schema (default), re-run the seed, and clear simulator/user state.
637
- * `mode: "data"` instead truncates ordinary public tables and restarts owned
638
- * sequences. Use only with a stable schema and data-only seed; it does not
639
- * restore DDL changes, schema-script data, or independent sequences.
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";