Files
healer-man/src/game/dungeonCatalog.test.ts
T
2026-09-12 23:55:24 -04:00

93 lines
3.9 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
DUNGEON_CATALOG,
DUNGEON_CATEGORIES,
dungeonById,
dungeonsByCategory,
} from "./dungeonCatalog";
import { DUNGEON_MANIFEST } from "./dungeonManifest";
import { RUNEWAKER_DUNGEON_DEFINITIONS } from "./generated/runewakerDungeonDefinitions.generated";
import { compareDungeonReleaseOrder } from "./dungeonReleaseStage";
import availability from "./generated/dungeonAvailability.json";
describe("dungeon catalog", () => {
it("lists the complete generated campaign with Stormwind Stockades in Beta first", () => {
expect(DUNGEON_CATALOG).toHaveLength(84);
expect(DUNGEON_CATALOG[0]).toMatchObject({
id: "stormwind-stockade",
releaseStage: "beta",
available: true,
});
expect(dungeonById(DUNGEON_MANIFEST.id)).toMatchObject({
title: DUNGEON_MANIFEST.title,
mapId: DUNGEON_MANIFEST.mapId,
entranceName: DUNGEON_MANIFEST.entrance.name,
releaseStage: "alpha",
});
expect(DUNGEON_CATALOG.find((dungeon) => dungeon.id === "deadmines")).toMatchObject({
id: "deadmines",
mapId: 36,
available: true,
});
expect(DUNGEON_CATALOG.find((dungeon) => dungeon.id === "forsaken-abbey")).toMatchObject({
id: "forsaken-abbey",
category: "rom",
mapId: 102,
available: true,
});
});
it("separates WoW and RoM dungeons with all RuneWaker imports under RoM", () => {
expect(DUNGEON_CATEGORIES.map((category) => category.id)).toEqual(["wow", "rom"]);
expect(dungeonsByCategory("rom").map((dungeon) => dungeon.id).sort()).toEqual([
"forsaken-abbey",
...RUNEWAKER_DUNGEON_DEFINITIONS.map((definition) => definition.id),
].sort());
expect(dungeonsByCategory("wow")).not.toContainEqual(
expect.objectContaining({ id: "forsaken-abbey" }),
);
expect(dungeonsByCategory("rom")).toHaveLength(30);
});
it("keeps stable unique ids and resolves only catalogued dungeons", () => {
const ids = DUNGEON_CATALOG.map((dungeon) => dungeon.id);
expect(new Set(ids).size).toBe(ids.length);
expect(dungeonById(DUNGEON_MANIFEST.id)).toBe(DUNGEON_CATALOG.find((dungeon) => dungeon.id === DUNGEON_MANIFEST.id));
expect(dungeonById("missing-dungeon")).toBeNull();
});
it("provides centralized display copy for every entry", () => {
for (const dungeon of DUNGEON_CATALOG) {
expect(dungeon.location.trim()).not.toBe("");
expect(dungeon.theme.trim()).not.toBe("");
expect(dungeon.summary.trim()).not.toBe("");
}
});
it("keeps only Stockades in Beta and alphabetizes each release group", () => {
expect(DUNGEON_CATALOG.filter((dungeon) => dungeon.releaseStage === "beta").map((dungeon) => dungeon.id))
.toEqual(["stormwind-stockade"]);
expect(DUNGEON_CATALOG.filter((dungeon) => dungeon.id !== "stormwind-stockade").every((dungeon) => dungeon.releaseStage === "alpha"))
.toBe(true);
for (const category of DUNGEON_CATEGORIES) {
const dungeons = dungeonsByCategory(category.id);
expect(dungeons).toEqual([...dungeons].sort(compareDungeonReleaseOrder));
}
const stages = [
{ title: "Zeta", releaseStage: "alpha" as const },
{ title: "Beta Z", releaseStage: "beta" as const },
{ title: "Released Z", releaseStage: "full-release" as const },
{ title: "Alpha", releaseStage: "alpha" as const },
{ title: "Beta A", releaseStage: "beta" as const },
{ title: "Released A", releaseStage: "full-release" as const },
];
expect(stages.sort(compareDungeonReleaseOrder).map((entry) => entry.title))
.toEqual(["Released A", "Released Z", "Beta A", "Beta Z", "Alpha", "Zeta"]);
});
it("shares the complete dungeon identity list used to validate reports on the server", () => {
expect(DUNGEON_CATALOG.map((dungeon) => dungeon.id).sort())
.toEqual(["forsaken-abbey", ...Object.keys(availability.enabled)].sort());
});
});