/** * THE RUST TREE'S LIST OF LOOM'S PICTURES IS GENERATED, AND NEVER STALE. * * The guards that hold a kit's pictures to Loom's catalogue (cotton-core * `tests/act_pictures.rs`, cotton-ffi `phone/opened_tests.rs`) read nothing * outside `crates/`, so they read `crates/cotton-core/src/definitions/ * loom_pictures.json`, which `scripts/gen-loom-pictures.py` writes from * `apps/loom/Sources/CottonPaper/Media.xcassets`. An imageset renamed or * removed without regenerating would leave those guards checking a list Loom * no longer ships, so the list is held to a fresh generation here. */import { execFileSync } from"node:child_process";import { existsSync, readFileSync } from"node:fs";import { dirname, resolve } from"node:path";import { fileURLToPath } from"node:url";import { describe, expect, it } from"vitest";const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../..");const LIST = resolve(REPO_ROOT, "crates/cotton-core/src/definitions/loom_pictures.json");const MEDIA = resolve(REPO_ROOT, "apps/loom/Sources/CottonPaper/Media.xcassets");describe("the Rust tree's list of Loom's pictures", () => {/// RULE: loom_pictures.json is what scripts/gen-loom-pictures.py writes from Loom's Media.xcassets today: an imageset added, renamed or removed without `pnpm gen:loom-pictures` fails here, not in a Rust guard reading a stale list. it("is what the generator writes from Loom's catalogue today", () => { expect(() => execFileSync("python3", ["scripts/gen-loom-pictures.py", "--check"], { cwd: REPO_ROOT, stdio: "pipe" })).not.toThrow(); }); it("names imagesets Loom really holds, sorted, each once", () => {const names: string[] = JSON.parse(readFileSync(LIST, "utf8")); expect(names.length).toBeGreaterThan(100); expect([...names].sort()).toEqual(names); expect(newSet(names).size).toBe(names.length);for (const name of names) expect(existsSync(resolve(MEDIA, `${name}.imageset/Contents.json`)), name).toBe(true); });});