|
1 | 1 | import { describe, it, expect, vi } from 'vitest'; |
2 | 2 | import { DevPlugin } from './dev-plugin'; |
3 | 3 |
|
| 4 | +// #3060: init()'s graceful-degradation path dynamically imports ~10 real |
| 5 | +// workspace packages (objectql, runtime, plugin-auth, …). Under a fully |
| 6 | +// parallel `pnpm test` those vite transforms alone can blow past the test |
| 7 | +// timeout — the "handle missing deps" test flaked at 15s while passing in |
| 8 | +// <100ms standalone. The test's INTENT is "peer deps missing", so make them |
| 9 | +// genuinely missing: each factory throws the same shape an absent package |
| 10 | +// produces. The degradation branch is exercised for real, with zero real |
| 11 | +// module resolution on the hot path. (The stub-contract tests below disable |
| 12 | +// all real services, so they never reach these imports.) |
| 13 | +// (vi.mock calls are hoisted above any const, so the factories are inline.) |
| 14 | +vi.mock('@objectstack/objectql', () => { throw Object.assign(new Error("Cannot find package '@objectstack/objectql'"), { code: 'ERR_MODULE_NOT_FOUND' }); }); |
| 15 | +vi.mock('@objectstack/runtime', () => { throw Object.assign(new Error("Cannot find package '@objectstack/runtime'"), { code: 'ERR_MODULE_NOT_FOUND' }); }); |
| 16 | +vi.mock('@objectstack/driver-memory', () => { throw Object.assign(new Error("Cannot find package '@objectstack/driver-memory'"), { code: 'ERR_MODULE_NOT_FOUND' }); }); |
| 17 | +vi.mock('@objectstack/service-i18n', () => { throw Object.assign(new Error("Cannot find package '@objectstack/service-i18n'"), { code: 'ERR_MODULE_NOT_FOUND' }); }); |
| 18 | +vi.mock('@objectstack/plugin-auth', () => { throw Object.assign(new Error("Cannot find package '@objectstack/plugin-auth'"), { code: 'ERR_MODULE_NOT_FOUND' }); }); |
| 19 | +vi.mock('@objectstack/plugin-security', () => { throw Object.assign(new Error("Cannot find package '@objectstack/plugin-security'"), { code: 'ERR_MODULE_NOT_FOUND' }); }); |
| 20 | +vi.mock('@objectstack/plugin-hono-server', () => { throw Object.assign(new Error("Cannot find package '@objectstack/plugin-hono-server'"), { code: 'ERR_MODULE_NOT_FOUND' }); }); |
| 21 | +vi.mock('@objectstack/rest', () => { throw Object.assign(new Error("Cannot find package '@objectstack/rest'"), { code: 'ERR_MODULE_NOT_FOUND' }); }); |
| 22 | + |
4 | 23 | describe('DevPlugin', () => { |
5 | 24 | it('should have correct metadata', () => { |
6 | 25 | const plugin = new DevPlugin(); |
@@ -41,10 +60,12 @@ describe('DevPlugin', () => { |
41 | 60 | getKernel: vi.fn(), |
42 | 61 | }; |
43 | 62 |
|
44 | | - // DevPlugin should not throw even if peer dependencies are missing |
| 63 | + // DevPlugin should not throw even if peer dependencies are missing. |
| 64 | + // Deps are mocked-away above (#3060), so the default timeout suffices — |
| 65 | + // if someone removes the mocks, the slowness resurfaces loudly here. |
45 | 66 | const plugin = new DevPlugin({ seedAdminUser: false }); |
46 | 67 | await expect(plugin.init(ctx)).resolves.not.toThrow(); |
47 | | - }, 15_000); |
| 68 | + }); |
48 | 69 |
|
49 | 70 | it('should register contract-compliant dev stubs for all core services', async () => { |
50 | 71 | const registeredServices = new Map<string, any>(); |
|
0 commit comments