test(frontend): fix 2 test-mock bugs that blocked the deploy gate
1. multi-board-integration.test.ts — PinManager mock was missing
hardResetPinStates(). Upstream commit d64eebc (fix(stop): reset CPU
to PC=0) added that method to PinManager and useSimulatorStore.stopBoard
calls it, but this test's vi.mock factory never exposed it. Result:
"TypeError: getBoardPinManager(...)?.hardResetPinStates is not a function"
even though the optional chain looks safe — the chain only short-circuits
on null/undefined, not on a non-function property.
2. vitest.config.ts — was missing the @velxio alias that vite.config.ts
defines. defineConfig from vitest/config does NOT auto-inherit from
vite.config.ts; the alias has to be re-declared. Without it, overlay
tests importing @velxio/store/useEditorStore failed with "Cannot find
package '@velxio/...'" even though the build (which DOES inherit the
alias) resolves them fine.
Verified: full set of 3 previously-failing tests now pass cleanly
(multi-board-integration: 43 passed, snapshot: 0, pinIntrospection: 10).
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
bab33e9e55
commit
3e38397366
|
|
@ -49,6 +49,11 @@ vi.mock('../simulation/PinManager', () => ({
|
||||||
this.onPinChange = vi.fn().mockReturnValue(() => {});
|
this.onPinChange = vi.fn().mockReturnValue(() => {});
|
||||||
this.getListenersCount = vi.fn().mockReturnValue(0);
|
this.getListenersCount = vi.fn().mockReturnValue(0);
|
||||||
this.resetPinStates = vi.fn();
|
this.resetPinStates = vi.fn();
|
||||||
|
// Added by upstream commit d64eebc (Stop semantics): the simulator
|
||||||
|
// store's stopBoard() invokes hardResetPinStates on the active pin
|
||||||
|
// manager. The mock has to expose it or test calls explode with
|
||||||
|
// "is not a function" even though the optional chain looks safe.
|
||||||
|
this.hardResetPinStates = vi.fn();
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { defineConfig } from 'vitest/config';
|
import { defineConfig } from 'vitest/config';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vitest configuration — split out from `vite.config.ts` (Phase 1d-tests J).
|
* Vitest configuration — split out from `vite.config.ts` (Phase 1d-tests J).
|
||||||
|
|
@ -15,8 +16,19 @@ import { defineConfig } from 'vitest/config';
|
||||||
* isolation, state leaks between tests sharing the same worker.
|
* isolation, state leaks between tests sharing the same worker.
|
||||||
* - Coverage excludes the WASM bundle (large binary, irrelevant lcov)
|
* - Coverage excludes the WASM bundle (large binary, irrelevant lcov)
|
||||||
* and the test files themselves.
|
* and the test files themselves.
|
||||||
|
*
|
||||||
|
* - `resolve.alias` mirrors `vite.config.ts` — vitest's defineConfig
|
||||||
|
* does NOT auto-inherit from vite.config.ts, so the @velxio alias
|
||||||
|
* used by overlay tests (e.g. pro/.../snapshot.test.ts importing
|
||||||
|
* `@velxio/store/useEditorStore`) must be declared here too or
|
||||||
|
* test files explode with "Cannot find package '@velxio/...'".
|
||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@velxio': path.resolve(__dirname, 'src'),
|
||||||
|
},
|
||||||
|
},
|
||||||
// Allow vitest to import test files / sources from outside this
|
// Allow vitest to import test files / sources from outside this
|
||||||
// project root - specifically `../../pro/frontend/src/pro/...` for
|
// project root - specifically `../../pro/frontend/src/pro/...` for
|
||||||
// velxio-prod overlay tests. Without this, Vite's fs sandbox blocks
|
// velxio-prod overlay tests. Without this, Vite's fs sandbox blocks
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue