forked from phenom/healer-man
71 lines
3.4 KiB
TypeScript
71 lines
3.4 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { activePartyBossObjectives } from "./partyRuntime";
|
|
import { useCombatStore } from "./combatStore";
|
|
import { threeToWow, wowToThree } from "./dungeonCoordinates";
|
|
import { DUNGEON_DEFINITIONS, dungeonCanEnter } from "./dungeonRegistry";
|
|
import { registerDungeonRuntimeReset } from "./dungeonRuntimeReset";
|
|
import { activateDungeonSession } from "./dungeonSession";
|
|
import { getMobPosition, setMobPosition } from "./mobRuntimeRegistry";
|
|
import { getPartyRuntimePosition, updatePartyRuntimePosition } from "./partyRuntimeRegistry";
|
|
import { spawnMatchesDifficulty } from "./mobPopulation";
|
|
import { useGameStore } from "./store";
|
|
import { useWailingEncounterStore } from "./wailingCavernsEncounter";
|
|
|
|
describe("dungeon pipeline runtime foundation", () => {
|
|
afterEach(() => {
|
|
useGameStore.getState().activateDungeon("wailing-caverns");
|
|
useWailingEncounterStore.getState().reset();
|
|
});
|
|
|
|
it("registers every reviewed instanced dungeon with WC first", () => {
|
|
expect(DUNGEON_DEFINITIONS).toHaveLength(92);
|
|
expect(DUNGEON_DEFINITIONS[0].id).toBe("wailing-caverns");
|
|
expect(DUNGEON_DEFINITIONS.some((definition) => definition.id === "deadmines")).toBe(true);
|
|
expect(DUNGEON_DEFINITIONS.some((definition) => definition.id === "forsaken-abbey")).toBe(true);
|
|
expect(DUNGEON_DEFINITIONS.every((definition) => definition.schemaVersion === 1)).toBe(true);
|
|
expect(dungeonCanEnter("wailing-caverns")).toBe(true);
|
|
expect(dungeonCanEnter("deadmines")).toBe(true);
|
|
expect(dungeonCanEnter("forsaken-abbey")).toBe(true);
|
|
expect(dungeonCanEnter("kalins-shrine")).toBe(true);
|
|
});
|
|
|
|
it("round-trips the recorded WoW coordinate transform", () => {
|
|
const source = [123.25, -44.5, 8.75] as const;
|
|
expect(threeToWow(wowToThree(source))).toEqual(source);
|
|
});
|
|
|
|
it("filters normal and heroic server spawns by bit mask", () => {
|
|
expect(spawnMatchesDifficulty(undefined, 1)).toBe(true);
|
|
expect(spawnMatchesDifficulty(1, 1)).toBe(true);
|
|
expect(spawnMatchesDifficulty(1, 2)).toBe(false);
|
|
expect(spawnMatchesDifficulty(3, 2)).toBe(true);
|
|
});
|
|
|
|
it("clears combat, position, party, and registered animation/navigation caches at the switch boundary", () => {
|
|
useCombatStore.getState().registerMob("stale-wc-mob", { name: "Stale WC Mob" });
|
|
setMobPosition("stale-wc-mob", [1, 2, 3]);
|
|
updatePartyRuntimePosition("stale-party-member", 4, 5, 6);
|
|
const reset = vi.fn();
|
|
const unregister = registerDungeonRuntimeReset(reset);
|
|
|
|
expect(activateDungeonSession("wailing-caverns")).toBe(true);
|
|
expect(useCombatStore.getState().mobs).toEqual({});
|
|
expect(getMobPosition("stale-wc-mob")).toBeNull();
|
|
expect(getPartyRuntimePosition("stale-party-member")).toBeNull();
|
|
expect(reset).toHaveBeenCalledOnce();
|
|
expect(useGameStore.getState().playerPosition).toEqual(
|
|
DUNGEON_DEFINITIONS[0].entrance.footPosition,
|
|
);
|
|
unregister();
|
|
});
|
|
|
|
it("resolves objectives from the active definition without stale WC state", () => {
|
|
useGameStore.getState().activateDungeon("deadmines");
|
|
expect(activePartyBossObjectives().map((objective) => objective.name)).toContain("Edwin VanCleef");
|
|
useGameStore.getState().activateDungeon("wailing-caverns");
|
|
expect(activePartyBossObjectives()).toHaveLength(7);
|
|
useWailingEncounterStore.setState({ phase: "mutanus" });
|
|
expect(activePartyBossObjectives()).toHaveLength(8);
|
|
});
|
|
});
|