feat: read only publish of drawings
This commit is contained in:
@@ -58,6 +58,37 @@ describe("createServer", () => {
|
||||
const { server } = createServerFixture();
|
||||
|
||||
expect(Object.hasOwn(server.routes, "/d/:id")).toBe(false);
|
||||
expect(Object.hasOwn(server.routes, "/p/:slug")).toBe(false);
|
||||
});
|
||||
|
||||
test("serves public drawing data through the public api", async () => {
|
||||
const { server, store } = createServerFixture();
|
||||
const drawing = store.createDrawing("Published");
|
||||
store.publishDrawing(drawing.id, { slug: "published-note" });
|
||||
|
||||
const response = await server.routes["/api/public/drawings/:slug"]?.GET?.(
|
||||
Object.assign(new Request("http://local/api/public/drawings/published-note"), {
|
||||
params: { slug: "published-note" },
|
||||
}),
|
||||
);
|
||||
|
||||
expect(response?.status).toBe(200);
|
||||
expect(await response?.json()).toEqual({
|
||||
title: "Published",
|
||||
elements: [],
|
||||
appState: { theme: "dark" },
|
||||
files: {},
|
||||
});
|
||||
});
|
||||
|
||||
test("returns 404 for unknown or unpublished public slugs", async () => {
|
||||
const { server } = createServerFixture();
|
||||
|
||||
const response = await server.routes["/api/public/drawings/:slug"]?.GET?.(
|
||||
Object.assign(new Request("http://local/api/public/drawings/missing"), { params: { slug: "missing" } }),
|
||||
);
|
||||
|
||||
expect(response?.status).toBe(404);
|
||||
});
|
||||
|
||||
test("returns JSON 404 for unmatched requests", async () => {
|
||||
|
||||
Reference in New Issue
Block a user