Introduce adapter injection and migrate test suite
Replace direct adapter/persistence imports with context-based injection (AdapterContext + useAdapters) so tests use in-memory implementations instead of vi.mock. Migrate component tests from context mocking to AllProviders with real hooks. Extract export/import logic from ActionBar into useEncounterExportImport hook. Add bestiary-cache and bestiary-index-adapter test suites. Raise adapter coverage thresholds (68→80 lines, 56→62 branches). 77 test files, 891 tests, all passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
12
apps/web/src/__tests__/factories/build-combatant.ts
Normal file
12
apps/web/src/__tests__/factories/build-combatant.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { Combatant } from "@initiative/domain";
|
||||
import { combatantId } from "@initiative/domain";
|
||||
|
||||
let counter = 0;
|
||||
|
||||
export function buildCombatant(overrides?: Partial<Combatant>): Combatant {
|
||||
return {
|
||||
id: combatantId(`c-${++counter}`),
|
||||
name: "Combatant",
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
10
apps/web/src/__tests__/factories/build-encounter.ts
Normal file
10
apps/web/src/__tests__/factories/build-encounter.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Encounter } from "@initiative/domain";
|
||||
|
||||
export function buildEncounter(overrides?: Partial<Encounter>): Encounter {
|
||||
return {
|
||||
combatants: [],
|
||||
activeIndex: 0,
|
||||
roundNumber: 1,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
2
apps/web/src/__tests__/factories/index.ts
Normal file
2
apps/web/src/__tests__/factories/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { buildCombatant } from "./build-combatant.js";
|
||||
export { buildEncounter } from "./build-encounter.js";
|
||||
Reference in New Issue
Block a user