123 lines
5.0 KiB
TypeScript
123 lines
5.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
MANASTORM_CATALOG,
|
|
installedManastormEncounterById,
|
|
installedManastormMapById,
|
|
installedManastormRowsForMap,
|
|
} from "./manastormCatalog";
|
|
import { MANASTORM_CATALOG_SUMMARY } from "./manastormCatalogSummary";
|
|
|
|
describe("installed-client Manastorm catalog", () => {
|
|
it("preserves the complete installed source and its deterministic identities", () => {
|
|
expect(MANASTORM_CATALOG.schemaVersion).toBe(1);
|
|
expect(MANASTORM_CATALOG.counts).toMatchObject({
|
|
sourceRows: 1025,
|
|
maps: 73,
|
|
encounters: 530,
|
|
modifiers: 32768,
|
|
groupModifiers: 15,
|
|
messages: 291,
|
|
resolvedMessageIcons: 291,
|
|
unresolvedMessageIcons: 0,
|
|
validationIssues: 0,
|
|
});
|
|
expect(new Set(MANASTORM_CATALOG.sourceRows.map((row) => row.id)).size).toBe(1025);
|
|
expect(new Set(MANASTORM_CATALOG.maps.map((map) => map.mapId)).size).toBe(73);
|
|
expect(new Set(MANASTORM_CATALOG.encounters.map((encounter) => encounter.encounterId)).size)
|
|
.toBe(530);
|
|
expect(MANASTORM_CATALOG.sourceRows[0].id).toBe("manastorm:row:1");
|
|
});
|
|
|
|
it("keeps the lightweight entry-screen summary synchronized with the importer output", () => {
|
|
expect(MANASTORM_CATALOG_SUMMARY).toEqual({
|
|
catalogId: MANASTORM_CATALOG.catalogId,
|
|
sourceRows: MANASTORM_CATALOG.counts.sourceRows,
|
|
maps: MANASTORM_CATALOG.counts.maps,
|
|
encounters: MANASTORM_CATALOG.counts.encounters,
|
|
modifiers: MANASTORM_CATALOG.counts.modifiers,
|
|
groupModifiers: MANASTORM_CATALOG.counts.groupModifiers,
|
|
messages: MANASTORM_CATALOG.counts.messages,
|
|
});
|
|
});
|
|
|
|
it("resolves every map to authoritative Map.dbc names and directories", () => {
|
|
const catalogMapIds = new Set(MANASTORM_CATALOG.maps.map((map) => map.mapId));
|
|
expect(MANASTORM_CATALOG.maps.every((map) => map.name && map.directory)).toBe(true);
|
|
expect(MANASTORM_CATALOG.sourceRows.every((row) => catalogMapIds.has(row.mapId))).toBe(true);
|
|
expect(installedManastormMapById(43)).toMatchObject({
|
|
id: "manastorm:map:43",
|
|
name: "Wailing Caverns",
|
|
directory: "WailingCaverns",
|
|
});
|
|
expect(installedManastormRowsForMap(43)).toHaveLength(14);
|
|
expect(installedManastormMapById(999_999)).toBeNull();
|
|
});
|
|
|
|
it("resolves installed encounter creatures while keeping the source sentinel explicit", () => {
|
|
const zeroEncounter = installedManastormEncounterById(0);
|
|
expect(zeroEncounter).toMatchObject({
|
|
id: "manastorm:encounter:0",
|
|
creatureReference: { status: "unresolved", id: null, sourceEncounterId: 0 },
|
|
spellReference: { status: "unresolved", id: null },
|
|
iconReference: { status: "unresolved", id: null },
|
|
});
|
|
const resolvedCreatures = MANASTORM_CATALOG.encounters.filter(
|
|
(encounter) => encounter.creatureReference.status === "resolved",
|
|
);
|
|
expect(resolvedCreatures).toHaveLength(529);
|
|
expect(resolvedCreatures.every(
|
|
(encounter) => encounter.creatureReference.status === "resolved"
|
|
&& encounter.creatureReference.id > 0
|
|
&& encounter.creatureReference.source === "DungeonEncounterExtra.dbc",
|
|
)).toBe(true);
|
|
});
|
|
|
|
it("records exact checksums and resolves message icons from DBC or installed files", () => {
|
|
expect(MANASTORM_CATALOG.provenance.sources.map(({ role }) => role)).toEqual([
|
|
"manastorm",
|
|
"messages",
|
|
"modifiers",
|
|
"groupModifiers",
|
|
"map",
|
|
"dungeonEncounter",
|
|
"dungeonEncounterExtra",
|
|
"spell",
|
|
"spellIcon",
|
|
]);
|
|
for (const source of MANASTORM_CATALOG.provenance.sources) {
|
|
expect(source.sha256).toMatch(/^[0-9a-f]{64}$/);
|
|
expect(source.byteLength).toBeGreaterThan(0);
|
|
expect(source.dbc.recordCount).toBeGreaterThan(0);
|
|
}
|
|
const fileResolvedMessages = MANASTORM_CATALOG.messages.filter(
|
|
(message) => message.iconReference.status === "resolved"
|
|
&& message.iconReference.resolutionSource === "installed-icon-file",
|
|
);
|
|
expect(fileResolvedMessages).toHaveLength(50);
|
|
expect(fileResolvedMessages.every(
|
|
(message) => message.iconReference.status === "resolved"
|
|
&& Boolean(message.iconReference.sha256?.match(/^[0-9a-f]{64}$/)),
|
|
)).toBe(true);
|
|
expect(fileResolvedMessages.some(
|
|
(message) => message.iconReference.basename?.toLowerCase() === "warlock_summon_beholder",
|
|
)).toBe(true);
|
|
expect(MANASTORM_CATALOG.messages.every(
|
|
(message) => message.spellReference.status === "unresolved",
|
|
)).toBe(true);
|
|
});
|
|
|
|
it("retains complete modifier curves and player-group multipliers", () => {
|
|
expect(MANASTORM_CATALOG.modifiers[0]).toMatchObject({
|
|
id: "manastorm:modifier:1",
|
|
sourceRecordId: 1,
|
|
modeId: 0,
|
|
level: 1,
|
|
rawFlag: 1,
|
|
});
|
|
expect(MANASTORM_CATALOG.modifiers[0].tuning).toHaveLength(11);
|
|
expect(MANASTORM_CATALOG.groupModifiers.map((modifier) => modifier.playerCount))
|
|
.toEqual(Array.from({ length: 15 }, (_, index) => index + 1));
|
|
expect(MANASTORM_CATALOG.groupModifiers[4].multipliers[0]).toBeCloseTo(1.4);
|
|
});
|
|
});
|