fix: serve design studio through the component app production route

This commit is contained in:
Clintchiz committed 2026-10-19 13:34:08 +05:30
1 parent 3987ddbcfe
commit 9a6a2e0a8d
11 files changed
+174 -47

No files matched your search

+24
View File
@@ -1,6 +1,30 @@
import { expect, test } from "bun:test";
import { createStudioHandler } from "@wrnexus/design-studio/server";
import { CORE_DESIGN_SYSTEMS } from "@wrnexus/design-system";
import { createContext } from "@wrnexus/core";
import designStudio from "../app/middleware/design-studio.ts";
test("application middleware mounts Studio before unmatched routes and preserves normal pages", async () => {
const send = (path: string) => {
const req = new Request("https://components.example" + path);
return designStudio(
createContext(req, new URL(req.url)),
() => new Response("normal page"),
);
};
expect(await (await send("/components/button")).text()).toBe("normal page");
expect(await (await send("/design-studio-other")).text()).toBe("normal page");
const redirect = await send("/design-studio");
expect(redirect.status).toBe(308);
expect(redirect.headers.get("location")).toBe("/design-studio/");
expect(await (await send("/design-studio/")).text()).toContain(
"WrNexus Design Studio",
);
expect((await send("/design-studio/studio.js")).status).toBe(200);
expect(
(await (await send("/design-studio/api/application")).json()).enabled,
).toBe(false);
});
test("deployed Studio serves assets and isolated previews without application writes", async () => {
const handler = await createStudioHandler({