@cosmicdrift/kumiko-testing 0.409.0 → 0.411.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-testing",
3
- "version": "0.409.0",
3
+ "version": "0.411.0",
4
4
  "description": "Test template for Kumiko apps: per-flow seedTenant, app test stack, canonical test preloads, bunfig generator and integration runner.",
5
5
  "license": "MIT",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -103,9 +103,9 @@
103
103
  "kumiko-testing": "./bin/kumiko-testing.ts"
104
104
  },
105
105
  "dependencies": {
106
- "@cosmicdrift/kumiko-framework": "0.409.0",
107
- "@cosmicdrift/kumiko-guards": "0.409.0",
108
- "@cosmicdrift/kumiko-types": "0.409.0",
106
+ "@cosmicdrift/kumiko-framework": "0.411.0",
107
+ "@cosmicdrift/kumiko-guards": "0.411.0",
108
+ "@cosmicdrift/kumiko-types": "0.411.0",
109
109
  "zod": "^4.6.7"
110
110
  },
111
111
  "peerDependencies": {
@@ -129,8 +129,8 @@
129
129
  }
130
130
  },
131
131
  "devDependencies": {
132
- "@cosmicdrift/kumiko-bundled-features": "0.409.0",
133
- "@cosmicdrift/kumiko-dev-server": "0.409.0",
132
+ "@cosmicdrift/kumiko-bundled-features": "0.411.0",
133
+ "@cosmicdrift/kumiko-dev-server": "0.411.0",
134
134
  "@happy-dom/global-registrator": "^21.0.4",
135
135
  "@playwright/test": "^1.64.1",
136
136
  "@testing-library/dom": "^10.4.2",
package/src/changes.json CHANGED
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "version": "0.411.0",
4
+ "type": "improvement",
5
+ "title": "renderTestSetup starter \"blank\"",
6
+ "detail": "`renderTestSetup({ starter: \"blank\" })` skips the tasks integration and e2e files, ships a boot validation unit test and a boot integration test, and runs Playwright with `--pass-with-no-tests`."
7
+ },
8
+ {
9
+ "version": "0.411.0",
10
+ "type": "fix",
11
+ "title": "runScreenshots finishes CSS transitions before the capture",
12
+ "detail": "`runScreenshots` captures with `animations: \"disabled\"` like `runMatrix`. A scenario flow that toggles the dark theme no longer catches `transition-all` buttons mid-fade with their light-theme colours."
13
+ },
2
14
  {
3
15
  "version": "0.409.0",
4
16
  "type": "fix",
@@ -274,7 +274,9 @@ export function runScreenshots(scenarios: readonly Scenario[], opts: FlatOptions
274
274
  presentIdentities: identities.register,
275
275
  });
276
276
  const path = `${outDir}/${s.name}.png`;
277
- await captureScenario(page, s, identities.mappings, { path });
277
+ // Same as runMatrix: a theme toggle in the flow starts transition-all fades that
278
+ // the settle fingerprint cannot see, so finish them at capture time.
279
+ await captureScenario(page, s, identities.mappings, { path, animations: "disabled" });
278
280
  expect.soft(statSync(path).size).toBeGreaterThan(MIN_BYTES);
279
281
  },
280
282
  );
@@ -1,6 +1,7 @@
1
1
  import type { AccessRule, SessionUser } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { AccessDeniedError } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import { createTestUser } from "@cosmicdrift/kumiko-framework/seeding";
4
+ import { isAnySignedInGranted } from "@cosmicdrift/kumiko-types/handlers";
4
5
  import type { TestStack } from "../stack/test-stack.ts";
5
6
 
6
7
  // Test-only helper: extracts the role list from a role-based AccessRule,
@@ -22,7 +23,12 @@ const PROBE_ROLE = "access-contract-probe";
22
23
  type CheckedHandlerCounts = { checkedWriteHandlers: number; checkedQueryHandlers: number };
23
24
 
24
25
  function isRoleRestricted(access: AccessRule | undefined): boolean {
25
- return access !== undefined && "roles" in access && access.roles.length > 0;
26
+ return (
27
+ access !== undefined &&
28
+ "roles" in access &&
29
+ access.roles.length > 0 &&
30
+ !isAnySignedInGranted(access)
31
+ );
26
32
  }
27
33
 
28
34
  async function deniedOutcome(res: Response): Promise<string | undefined> {
@@ -42,8 +48,8 @@ const ACCESS_DENIED_CODE = new AccessDeniedError().code;
42
48
  * Contract test: every role-restricted write/query handler in the stack rejects
43
49
  * a signed-in caller who holds none of its roles with 403 access_denied, over
44
50
  * real HTTP. Roles are checked centrally before payload parsing (pre-handler
45
- * gates / dispatch-query), so an empty payload is enough. openToAll handlers
46
- * and handlers without access are skipped. Throws once with all deviations;
51
+ * gates / dispatch-query), so an empty payload is enough. openToAll and
52
+ * anySignedIn handlers and handlers without access are skipped. Throws once with all deviations;
47
53
  * `minimumHandlerCount` guards against an empty registry walk passing silently.
48
54
  */
49
55
  export async function expectRoleRestrictedHandlersDenyForeignRole(
@@ -0,0 +1,48 @@
1
+ // @runtime tooling
2
+ export type ScaffoldTestStarter = "demo" | "blank";
3
+
4
+ export const BLANK_E2E_PLAYWRIGHT_FLAG = "--pass-with-no-tests";
5
+
6
+ export const BLANK_TEST_FILES: Readonly<Record<string, string>> = {
7
+ "src/__tests__/run-config.test.ts": [
8
+ 'import { describe, expect, test } from "bun:test";',
9
+ 'import { validateBoot } from "@cosmicdrift/kumiko-framework/engine";',
10
+ 'import { composeFeatures } from "@cosmicdrift/kumiko-server-runtime/compose-features";',
11
+ 'import { APP_FEATURES, HAS_AUTH } from "../run-config";',
12
+ "",
13
+ 'describe("run-config", () => {',
14
+ ' test("the mounted features pass boot validation", () => {',
15
+ " const features = composeFeatures([...APP_FEATURES], { includeBundled: HAS_AUTH });",
16
+ " expect(() => validateBoot(features)).not.toThrow();",
17
+ " });",
18
+ "});",
19
+ "",
20
+ ].join("\n"),
21
+ "src/__tests__/boot.integration.test.ts": [
22
+ 'import { afterAll, beforeAll, describe, expect, test } from "bun:test";',
23
+ 'import { setupAppTestStack } from "@cosmicdrift/kumiko-dev-server/testing";',
24
+ 'import type { TestStack } from "@cosmicdrift/kumiko-testing/stack";',
25
+ 'import { APP_FEATURES } from "../run-config";',
26
+ "",
27
+ "let stack: TestStack;",
28
+ "",
29
+ "beforeAll(async () => {",
30
+ " stack = await setupAppTestStack([...APP_FEATURES]);",
31
+ "});",
32
+ "",
33
+ "afterAll(async () => {",
34
+ " await stack?.cleanup();",
35
+ "});",
36
+ "",
37
+ 'describe("boot", () => {',
38
+ ' test("the mounted features boot and refuse an unknown login", async () => {',
39
+ ' const res = await stack.http.raw("POST", "/api/auth/login", {',
40
+ ' email: "nobody@example.com",',
41
+ ' password: "not-a-real-password",',
42
+ " });",
43
+ " expect(res.status).toBeGreaterThanOrEqual(400);",
44
+ " });",
45
+ "});",
46
+ "",
47
+ ].join("\n"),
48
+ };
package/src/scaffold.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  // @runtime tooling
2
2
  import { BUNFIG_FILES, renderBunfigFiles, TEST_TIMEOUT_MS } from "./bunfig";
3
3
  import { REAL_PROVIDERS_ENV } from "./helpers/real-providers";
4
+ import {
5
+ BLANK_E2E_PLAYWRIGHT_FLAG,
6
+ BLANK_TEST_FILES,
7
+ type ScaffoldTestStarter,
8
+ } from "./scaffold-blank";
4
9
 
5
10
  export type ScaffoldTestSetup = {
6
11
  readonly files: Readonly<Record<string, string>>;
@@ -13,6 +18,7 @@ export type RenderTestSetupInput = {
13
18
  readonly appName: string;
14
19
  readonly frameworkVersion: string;
15
20
  readonly port?: number;
21
+ readonly starter?: ScaffoldTestStarter;
16
22
  };
17
23
 
18
24
  // One above the scaffold's `bun dev` default (4173) so both can run side by side.
@@ -202,19 +208,25 @@ function renderIntegrationTest(): string {
202
208
  }
203
209
 
204
210
  export function renderTestSetup(input: RenderTestSetupInput): ScaffoldTestSetup {
205
- const { appName, frameworkVersion, port = SCAFFOLD_E2E_PORT } = input;
211
+ const { appName, frameworkVersion, port = SCAFFOLD_E2E_PORT, starter = "demo" } = input;
212
+ const isBlank = starter === "blank";
213
+ const playwrightRun = `bunx --bun playwright test${isBlank ? ` ${BLANK_E2E_PLAYWRIGHT_FLAG}` : ""}`;
206
214
  const unitTestScript = `bun --config=${BUNFIG_FILES.unit} test --timeout=${TEST_TIMEOUT_MS.unit} --dots`;
207
215
  const integrationTestScript = `bun kumiko-testing integration --parallel ${SCAFFOLD_INTEGRATION_PARALLEL}`;
208
216
  return {
209
217
  files: {
210
218
  ...renderBunfigFiles({ install: { linker: "hoisted" }, dom: true }),
211
219
  "playwright.config.ts": renderPlaywrightConfig(port),
212
- "e2e/_helpers/index.ts": renderE2eHelpers(),
213
220
  "e2e/server.ts": renderE2eServer(appName),
214
- "e2e/smoke.spec.ts": renderE2eSmokeSpec(),
215
- "src/__tests__/_setup.ts": renderIntegrationSetup(),
216
- "src/__tests__/run-config.test.ts": renderUnitTest(),
217
- "src/__tests__/tasks.integration.test.ts": renderIntegrationTest(),
221
+ ...(isBlank
222
+ ? BLANK_TEST_FILES
223
+ : {
224
+ "e2e/_helpers/index.ts": renderE2eHelpers(),
225
+ "e2e/smoke.spec.ts": renderE2eSmokeSpec(),
226
+ "src/__tests__/_setup.ts": renderIntegrationSetup(),
227
+ "src/__tests__/run-config.test.ts": renderUnitTest(),
228
+ "src/__tests__/tasks.integration.test.ts": renderIntegrationTest(),
229
+ }),
218
230
  },
219
231
  scripts: {
220
232
  test: unitTestScript,
@@ -231,9 +243,9 @@ export function renderTestSetup(input: RenderTestSetupInput): ScaffoldTestSetup
231
243
  // picks up the unit suite.
232
244
  "test:real": `${REAL_PROVIDERS_ENV}=1 bun --config=${BUNFIG_FILES.real} test --timeout=${TEST_TIMEOUT_MS.real} .real.test.ts`,
233
245
  "test:bunfig": "bun kumiko-testing bunfig --hoisted",
234
- e2e: "bunx --bun playwright test",
235
- "e2e:real": `${REAL_PROVIDERS_ENV}=1 bunx --bun playwright test`,
236
- screenshots: "SCREENSHOT_DIR=docs/screenshots bunx --bun playwright test",
246
+ e2e: playwrightRun,
247
+ "e2e:real": `${REAL_PROVIDERS_ENV}=1 ${playwrightRun}`,
248
+ screenshots: `SCREENSHOT_DIR=docs/screenshots ${playwrightRun}`,
237
249
  },
238
250
  devDependencies: {
239
251
  "@cosmicdrift/kumiko-testing": frameworkVersion,