diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..95ef395 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,7 @@ +# Commit Style + +- Use Conventional Commits. +- Keep the type and subject lowercase. +- Keep commit messages terse. + +Example: `feat: dark mode by default` diff --git a/src/api.test.ts b/src/api.test.ts index 5e79849..a1a1ccd 100644 --- a/src/api.test.ts +++ b/src/api.test.ts @@ -20,6 +20,15 @@ function withApi() { } describe("api", () => { + test("creates a drawing with dark theme by default", async () => { + const { api, cleanup } = withApi(); + + const created = await api.createDrawing().json(); + + expect(created.appState.theme).toBe("dark"); + cleanup(); + }); + test("returns 400 for invalid JSON", async () => { const { api, cleanup } = withApi(); const drawing = await api.createDrawing().json(); diff --git a/src/db.test.ts b/src/db.test.ts index 7c5c670..8c52d38 100644 --- a/src/db.test.ts +++ b/src/db.test.ts @@ -27,6 +27,7 @@ describe("drawing store", () => { const created = store.createDrawing(); expect(created.title).toBe("Untitled"); + expect(created.scene.appState.theme).toBe("dark"); expect(store.listDrawings()).toHaveLength(1); const updated = store.updateDrawing(created.id, { diff --git a/src/scene.test.ts b/src/scene.test.ts index c9fdff7..f8f1a91 100644 --- a/src/scene.test.ts +++ b/src/scene.test.ts @@ -1,7 +1,13 @@ import { describe, expect, test } from "bun:test"; -import { HttpError, MAX_SCENE_BYTES, normalizeScene, parseJsonBody } from "./scene"; +import { HttpError, MAX_SCENE_BYTES, emptyScene, normalizeScene, parseJsonBody } from "./scene"; describe("scene helpers", () => { + test("creates empty scenes with dark theme by default", () => { + const scene = emptyScene(); + + expect(scene.appState.theme).toBe("dark"); + }); + test("normalizes volatile app state fields", () => { const scene = normalizeScene({ elements: [], diff --git a/src/scene.ts b/src/scene.ts index 8bf5d1e..32435e9 100644 --- a/src/scene.ts +++ b/src/scene.ts @@ -26,7 +26,7 @@ const VOLATILE_APP_STATE_KEYS = new Set([ export function emptyScene(): ScenePayload { return { elements: [], - appState: {}, + appState: { theme: "dark" }, files: {}, }; }