fix: install Studio Linux preview patch and verify all gallery pages
This commit is contained in:
1 parent
953e928b05
commit
fac1c4461f
7 files changed
+78
-7
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
test("installed Studio previews resolve exact Linux filenames for every component", () => {
|
||||
const probe = `
|
||||
import { mock } from "bun:test";
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import { dirname, basename } from "node:path";
|
||||
import { uiComponentsDir } from "@wrnexus/ui/registry";
|
||||
import { CORE_DESIGN_SYSTEMS } from "@wrnexus/design-system";
|
||||
const directory = uiComponentsDir(), names = new Set(readdirSync(directory)), originalRead = readFileSync;
|
||||
let checked = 0;
|
||||
mock.module("node:fs", () => ({ readFileSync(path, ...options) {
|
||||
if (typeof path === "string" && dirname(path) === directory && path.endsWith(".wrn")) {
|
||||
if (!names.has(basename(path))) throw Error("Case-sensitive component lookup failed: " + basename(path));
|
||||
checked++;
|
||||
}
|
||||
return originalRead(path, ...options);
|
||||
}}));
|
||||
const { createStudioHandler } = await import("@wrnexus/design-studio/server");
|
||||
const handler = await createStudioHandler();
|
||||
for (const options of [{}, ...Array.from({length:7}, (_, page) => ({content:"catalog", page}))]) {
|
||||
const response = await handler(new Request("http://127.0.0.1/api/preview", {
|
||||
method:"POST", headers:{"content-type":"application/json"}, body:JSON.stringify({system:CORE_DESIGN_SYSTEMS.soft,...options})
|
||||
}));
|
||||
if (!response.ok) throw Error(await response.text());
|
||||
}
|
||||
if (checked < 104) throw Error("Incomplete installed preview coverage: " + checked);
|
||||
console.log("All 104 installed preview components pass case-sensitive file lookup.");
|
||||
`;
|
||||
const result = Bun.spawnSync([process.execPath, "--eval", probe], {
|
||||
cwd: resolve(import.meta.dir, ".."),
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
});
|
||||
expect(new TextDecoder().decode(result.stderr)).not.toContain(
|
||||
"Case-sensitive component lookup failed",
|
||||
);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(new TextDecoder().decode(result.stdout)).toContain(
|
||||
"All 104 installed preview components",
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user