import { copyFileSync, mkdirSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { build, loadProducts } from "../../../tools/migrate/src/build.ts"; import { rig, type Rig } from "./helpers.ts"; let r: Rig; let total = 0; beforeAll(async () => { const legacy = resolve(import.meta.dirname, "../../../legacy"); await loadProducts(legacy); const result = build(legacy); r = rig(); for (const n of result.notes) r.putText(n.path, n.text); for (const a of result.attachments) { mkdirSync(dirname(join(r.site, a.to)), { recursive: true }); copyFileSync(a.from, join(r.site, a.to)); } total = result.notes.length; }); afterAll(() => r.done()); describe("the migrated Site folder", () => { it("is taken in whole, with nothing held and no problems", () => { expect(r.service.scan()).toEqual({ changed: total, held: 0 }); expect(r.store.count().notes).toBe(total); expect(r.service.problems()).toEqual([]); }); it("is searchable and linked", () => { expect(r.store.search("Spirit Island").some((n) => n.type === "board-game")).toBe(true); expect(r.store.backlinks("Magic The Gathering").length).toBeGreaterThan(0); }); });