fix(build): pick a source's own fixture, not a sibling page's on the same site

build-feed globbed fixtures by site (`fandom-*`), so a second Fandom page
for a game, such as Genshin's Miliastra Pass beside its event page, would
have handed its fixture to the events parser. pickFixture matches the
source's whole name followed by a date. Every fixture already follows
that name, and the built feed is unchanged (206 events, same ids).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-16 06:10:51 +02:00
1 parent 6e7c231160
commit 40d0dbef5a
3 files changed
+50 -9

No files matched your search

+27
View File
@@ -1,3 +1,4 @@
import { pickFixture } from "../src/ingest/snapshots.ts";
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { statSync } from "node:fs";
import { mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
@@ -454,3 +455,29 @@ describe("freshnessAt", () => {
).toBe(T0);
});
});
describe("pickFixture: a source's own fixture, never a sibling's", () => {
const files = [
"fixtures/genshin/fandom-events-2026-09-12.html",
"fixtures/genshin/fandom-miliastra-pass-2026-10-16.html",
"fixtures/genshin/game8-events-2026-08-14.html",
];
test("an -events source keeps its old names", () => {
expect(pickFixture("genshin-fandom-events", "genshin", files)).toBe(
"fixtures/genshin/fandom-events-2026-09-12.html",
);
});
test("a second page on the same site does not take the events page's fixture, or give it its own", () => {
expect(pickFixture("genshin-fandom-miliastra-pass", "genshin", files)).toBe(
"fixtures/genshin/fandom-miliastra-pass-2026-10-16.html",
);
});
test("the newest date wins, and nothing matches nothing", () => {
expect(pickFixture("genshin-game8-events", "genshin", [...files, "fixtures/genshin/game8-events-2026-09-01.html"]))
.toBe("fixtures/genshin/game8-events-2026-09-01.html");
expect(pickFixture("genshin-fandom-other", "genshin", files)).toBeUndefined();
});
});