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:
44
apps/web/src/adapters/production-adapters.ts
Normal file
44
apps/web/src/adapters/production-adapters.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { Adapters } from "../contexts/adapter-context.js";
|
||||
import {
|
||||
loadEncounter,
|
||||
saveEncounter,
|
||||
} from "../persistence/encounter-storage.js";
|
||||
import {
|
||||
loadPlayerCharacters,
|
||||
savePlayerCharacters,
|
||||
} from "../persistence/player-character-storage.js";
|
||||
import {
|
||||
loadUndoRedoStacks,
|
||||
saveUndoRedoStacks,
|
||||
} from "../persistence/undo-redo-storage.js";
|
||||
import * as bestiaryCache from "./bestiary-cache.js";
|
||||
import * as bestiaryIndex from "./bestiary-index-adapter.js";
|
||||
|
||||
export const productionAdapters: Adapters = {
|
||||
encounterPersistence: {
|
||||
load: loadEncounter,
|
||||
save: saveEncounter,
|
||||
},
|
||||
undoRedoPersistence: {
|
||||
load: loadUndoRedoStacks,
|
||||
save: saveUndoRedoStacks,
|
||||
},
|
||||
playerCharacterPersistence: {
|
||||
load: loadPlayerCharacters,
|
||||
save: savePlayerCharacters,
|
||||
},
|
||||
bestiaryCache: {
|
||||
cacheSource: bestiaryCache.cacheSource,
|
||||
isSourceCached: bestiaryCache.isSourceCached,
|
||||
getCachedSources: bestiaryCache.getCachedSources,
|
||||
clearSource: bestiaryCache.clearSource,
|
||||
clearAll: bestiaryCache.clearAll,
|
||||
loadAllCachedCreatures: bestiaryCache.loadAllCachedCreatures,
|
||||
},
|
||||
bestiaryIndex: {
|
||||
loadIndex: bestiaryIndex.loadBestiaryIndex,
|
||||
getAllSourceCodes: bestiaryIndex.getAllSourceCodes,
|
||||
getDefaultFetchUrl: bestiaryIndex.getDefaultFetchUrl,
|
||||
getSourceDisplayName: bestiaryIndex.getSourceDisplayName,
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user