Implement the 029-on-demand-bestiary feature that replaces the bundled XMM bestiary JSON with a compact search index (~350KB) and on-demand source loading, where users explicitly provide a URL or upload a JSON file to fetch full stat block data per source, which is then normalized and cached in IndexedDB (with in-memory fallback) so creature stat blocks load instantly on subsequent visits while keeping the app bundle small and never auto-fetching copyrighted content
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { normalizeBestiary } from "../bestiary-adapter.js";
|
||||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
import {
|
||||
normalizeBestiary,
|
||||
setSourceDisplayNames,
|
||||
} from "../bestiary-adapter.js";
|
||||
|
||||
beforeAll(() => {
|
||||
setSourceDisplayNames({ XMM: "MM 2024" });
|
||||
});
|
||||
|
||||
describe("normalizeBestiary", () => {
|
||||
it("normalizes a simple creature", () => {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { expect, it } from "vitest";
|
||||
import rawData from "../../../../../data/bestiary/xmm.json";
|
||||
import { normalizeBestiary } from "../bestiary-adapter.js";
|
||||
|
||||
it("normalizes all 503 monsters without error", () => {
|
||||
const creatures = normalizeBestiary(
|
||||
rawData as unknown as Parameters<typeof normalizeBestiary>[0],
|
||||
);
|
||||
expect(creatures.length).toBe(503);
|
||||
for (const c of creatures) {
|
||||
expect(c.name).toBeTruthy();
|
||||
expect(c.id).toBeTruthy();
|
||||
expect(c.ac).toBeGreaterThanOrEqual(0);
|
||||
expect(c.hp.average).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user