Add tests for undo/redo/setTempHp use cases, fix coverage thresholds

Adds missing tests for undoUseCase, redoUseCase, and setTempHpUseCase,
bringing application layer coverage from ~81% to 97%. Removes
autoUpdate from coverage thresholds and sets floors to actual values
so they enforce a real minimum.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-28 18:19:15 +01:00
parent 01b1bba6d6
commit 896fd427ed
3 changed files with 120 additions and 16 deletions

View File

@@ -1,6 +1,14 @@
import type { Encounter, PlayerCharacter } from "@initiative/domain";
import { isDomainError } from "@initiative/domain";
import type { EncounterStore, PlayerCharacterStore } from "../ports.js";
import type {
Encounter,
PlayerCharacter,
UndoRedoState,
} from "@initiative/domain";
import { EMPTY_UNDO_REDO_STATE, isDomainError } from "@initiative/domain";
import type {
EncounterStore,
PlayerCharacterStore,
UndoRedoStore,
} from "../ports.js";
export function requireSaved<T>(value: T | null): T {
if (value === null) throw new Error("Expected store.saved to be non-null");
@@ -52,3 +60,17 @@ export function stubPlayerCharacterStore(
};
return stub;
}
export function stubUndoRedoStore(
initial: UndoRedoState = EMPTY_UNDO_REDO_STATE,
): UndoRedoStore & { saved: UndoRedoState | null } {
const stub = {
saved: null as UndoRedoState | null,
get: () => initial,
save: (state: UndoRedoState) => {
stub.saved = state;
stub.get = () => state;
},
};
return stub;
}