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>
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import type {
|
|
BestiaryIndex,
|
|
Creature,
|
|
CreatureId,
|
|
Encounter,
|
|
PlayerCharacter,
|
|
UndoRedoState,
|
|
} from "@initiative/domain";
|
|
|
|
export interface EncounterPersistence {
|
|
load(): Encounter | null;
|
|
save(encounter: Encounter): void;
|
|
}
|
|
|
|
export interface UndoRedoPersistence {
|
|
load(): UndoRedoState;
|
|
save(state: UndoRedoState): void;
|
|
}
|
|
|
|
export interface PlayerCharacterPersistence {
|
|
load(): PlayerCharacter[];
|
|
save(characters: PlayerCharacter[]): void;
|
|
}
|
|
|
|
export interface CachedSourceInfo {
|
|
readonly sourceCode: string;
|
|
readonly displayName: string;
|
|
readonly creatureCount: number;
|
|
readonly cachedAt: number;
|
|
}
|
|
|
|
export interface BestiaryCachePort {
|
|
cacheSource(
|
|
sourceCode: string,
|
|
displayName: string,
|
|
creatures: Creature[],
|
|
): Promise<void>;
|
|
isSourceCached(sourceCode: string): Promise<boolean>;
|
|
getCachedSources(): Promise<CachedSourceInfo[]>;
|
|
clearSource(sourceCode: string): Promise<void>;
|
|
clearAll(): Promise<void>;
|
|
loadAllCachedCreatures(): Promise<Map<CreatureId, Creature>>;
|
|
}
|
|
|
|
export interface BestiaryIndexPort {
|
|
loadIndex(): BestiaryIndex;
|
|
getAllSourceCodes(): string[];
|
|
getDefaultFetchUrl(sourceCode: string, baseUrl?: string): string;
|
|
getSourceDisplayName(sourceCode: string): string;
|
|
}
|