import { beforeEach, describe, expect, it } from "vitest"; import { clearMobRuntimeRegistry, setMobPosition } from "./mobRuntimeRegistry"; import { clearPartyRuntimeRegistry } from "./partyRuntimeRegistry"; import { usePartyStore } from "./partyStore"; import { PLAYER_AURA_ENTITY_ID, useCombatStore } from "./combatStore"; describe("WoW Rogue Vanish and Preparation runtime", () => { beforeEach(() => { clearMobRuntimeRegistry(); clearPartyRuntimeRegistry(); useCombatStore.getState().initializeCharacter({ classId: "rogue", level: 80 }); useCombatStore.getState().setPlayerPosition([0, 0, 0]); usePartyStore.getState().initializeParty("wow335-rogue-vanish-preparation-tests", 1, useCombatStore.getState().health); }); it.each(["root", "slow"] as const)("Vanish grants stealth, clears %s, and does not relocate the rogue", (mechanic) => { useCombatStore.getState().registerMob("vanish-target", { name: "vanish-target", maxHealth: 100_000, xpReward: 0 }); setMobPosition("vanish-target", [8, 0, 0]); useCombatStore.getState().selectMob("vanish-target"); useCombatStore.setState({ controlledUntil: 15_000, controlMechanic: mechanic }); const result = useCombatStore.getState().castAbility("wow335-rogue-vanish", undefined, 1_000); expect(result).toMatchObject({ ok: true, abilityId: "wow335-rogue-vanish" }); const state = useCombatStore.getState(); expect(state.auras.some((aura) => aura.targetId === PLAYER_AURA_ENTITY_ID && aura.definition.utilityTags?.includes("stealth") && aura.expiresAt === null)).toBe(true); expect(state).toMatchObject({ controlledUntil: 0, controlMechanic: null, playerPosition: [0, 0, 0] }); }); it("Preparation resets only its five source-listed cooldowns", () => { const abilities = useCombatStore.getState().abilities; const byName = (name: string) => { const ability = abilities.find((candidate) => candidate.name === name); expect(ability, name).toBeDefined(); return ability!; }; const resetNames = ["Evasion", "Sprint", "Vanish", "Cold Blood", "Shadowstep"]; const resetIds = resetNames.map((name) => byName(name).id); const unrelatedId = byName("Kick").id; useCombatStore.setState((state) => ({ talentRanks: { ...state.talentRanks, "talent-284": 1 }, cooldowns: { ...state.cooldowns, ...Object.fromEntries([...resetIds, unrelatedId].map((id) => [id, 60_000])), }, })); const result = useCombatStore.getState().castAbility("wow335-rogue-preparation", undefined, 1_000); expect(result).toMatchObject({ ok: true, abilityId: "wow335-rogue-preparation" }); const cooldowns = useCombatStore.getState().cooldowns; for (const id of resetIds) expect(cooldowns[id], id).toBe(0); expect(cooldowns[unrelatedId]).toBe(60_000); expect(cooldowns["wow335-rogue-preparation"]).toBe(601_000); }); });