fix(studio): resolve exact component filenames for Linux previews
This commit is contained in:
1 parent
f1cf0e9f2b
commit
59f1d9d28a
5 files changed
+61
-8
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
test("composed and catalog previews use exact shipped filename casing on every platform", () => {
|
||||
const preview = pathToFileURL(resolve(import.meta.dir, "../src/preview.ts")).href;
|
||||
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();
|
||||
const names = new Set(readdirSync(directory));
|
||||
const 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 { previewDocument } = await import(${JSON.stringify(preview)});
|
||||
await previewDocument(CORE_DESIGN_SYSTEMS.square);
|
||||
for (let page = 0; page < 7; page++) await previewDocument(CORE_DESIGN_SYSTEMS.soft, { content: "catalog", page });
|
||||
if (checked < 104) throw Error("Incomplete component coverage: " + checked);
|
||||
console.log("Exact filename casing verified for all 104 preview components.");
|
||||
`;
|
||||
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 preview components");
|
||||
});
|
||||
Reference in new issue
Block a user