|
1 | 1 | // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. |
2 | | -// test-budget: 30 — spawns the real producer once per single-cause fixture: four boots of the built CLI (a missing and a broken `@objectstack/plugin-auth` in production, the broken one under `--dev`, and production with no stub), each differing only in the input under test; MEASURED_PLACEHOLDER |
| 2 | +// test-budget: 20 — spawns the real producer once per single-cause fixture: four boots of the built CLI (a missing and a broken `@objectstack/plugin-auth` in production, the broken one under `--dev`, and production with no stub), each differing only in the input under test; 13.3 s, the slowest of three local runs on a shared container, x 1.25, no CI reading yet |
3 | 3 |
|
4 | 4 | import { afterAll, beforeAll, describe, expect, it } from 'vitest'; |
5 | 5 | import { spawn, type ChildProcessByStdio } from 'node:child_process'; |
@@ -48,9 +48,14 @@ const HOOK = pathToFileURL(resolve(HERE, 'fixtures/plugin-auth-load-failure.hook |
48 | 48 | const AUTH_TIER_CONFIG = 'export default {};\n'; |
49 | 49 |
|
50 | 50 | const LOAD_FAILURE_TEXT = '@objectstack/plugin-auth failed to load'; |
51 | | -/** Node's own sentences for the two stubbed installs — the hook writes neither. */ |
52 | | -const MISSING_CAUSE = 'Cannot find module'; |
53 | | -const BROKEN_CAUSE = 'does not provide an export named'; |
| 51 | +/** |
| 52 | + * The openings of node's own sentences for the two stubbed installs — the hook |
| 53 | + * writes neither. Asserted right after `The load error: `, because the same |
| 54 | + * sentence also appears in oclif's warning for the `verify` command (see the |
| 55 | + * hook's header), which alone would pass a leg that named no load error. |
| 56 | + */ |
| 57 | +const MISSING_CAUSE = "Cannot find module '"; |
| 58 | +const BROKEN_CAUSE = "The requested module 'node:path' does not provide an export named 'createLocalAccountIssuer'"; |
54 | 59 | const SECRET = 'os-adr-0131-d9-load-failure-leg-secret-not-a-real-credential'; |
55 | 60 |
|
56 | 61 | type BootChild = ChildProcessByStdio<null, Readable, Readable>; |
@@ -129,8 +134,7 @@ async function expectRefused(leg: Leg, cause: string): Promise<string> { |
129 | 134 | expect(exitCode).not.toBe(0); |
130 | 135 | expect(output).not.toMatch(READY_BANNER_TAIL); |
131 | 136 | expect(output).toContain(LOAD_FAILURE_TEXT); |
132 | | - expect(output).toContain(`The load error: `); |
133 | | - expect(output).toContain(cause); |
| 137 | + expect(output).toContain(`The load error: ${cause}`); |
134 | 138 | // Refused instead of the old warn-and-boot line, not after it. |
135 | 139 | expect(output).not.toContain('⚠ AuthPlugin failed to load'); |
136 | 140 | expect(existsSync(leg.databaseFile), `the refused boot opened its database\n${output}`).toBe(false); |
@@ -178,7 +182,6 @@ describe('os serve — a production boot whose plugin-auth fails to load is refu |
178 | 182 |
|
179 | 183 | it('control: --dev with the broken install keeps the warn-and-boot path', async () => { |
180 | 184 | const output = await expectBoots({ databaseFile: db('broken-dev-no-server'), stub: 'broken', args: ['--dev', '--no-server'] }); |
181 | | - expect(output).toContain('⚠ AuthPlugin failed to load'); |
182 | | - expect(output).toContain(BROKEN_CAUSE); |
| 185 | + expect(output).toContain(`⚠ AuthPlugin failed to load: ${BROKEN_CAUSE}`); |
183 | 186 | }, 240_000); |
184 | 187 | }); |
0 commit comments