import { expect, test } from "bun:test" import { existsSync, readFileSync, readdirSync } from "node:fs" import { join } from "node:path" const dir = import.meta.dir const page = join(dir, "page") const read = (f) => readFileSync(join(page, f), "utf8") const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8")) // view.js is a classic script, as the page loads it const scope = {} new Function("globalThis", read("view.js"))(scope) const V = scope.LayerfsView test("the package declares the page magpie shows", () => { const p = pkg.magpie.page expect(p.title).toBe("LayerFS trajectory") expect(p.titles.zh).toBe("LayerFS 轨迹") expect(p.file).toBe("page/index.html") expect(p.icon).toBe("page/icon.svg") expect(pkg.files).toContain("page") expect(pkg.files).toContain("page-service.mjs") for (const f of ["index.html", "boot.js", "trajectory.html", "app.js", "view.js", "style.css", "icon.svg"]) expect(existsSync(join(page, f))).toBe(true) const html = read("index.html") expect(html).toContain("_magpie/bridge.js") // the host serves the bridge beside every page // the installed page only jumps: it loads the bridge and the boot // script, and nothing else — no data scripts, no inline scripts expect(html).toContain('src="boot.js"') expect(html).not.toContain('src="trajectory.js"') expect(html).not.toContain('src="trajectory-live.js"') expect(html).not.toMatch(/