Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.
TypeScript canva-alternativecanvasdesigndesign-tooldrag-and-dropeditorgraphic-designkonvanextjsopen-sourcereactself-hostedtemplatestypescript
fix(e2e): the provenance spec asserted the REST-rail 404 convention — the designs family answers differently
Ashiq Hussain Mireccdb4368850
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0934b83..4e774ed 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,8 +15,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).generation was verified against, stored on the applied design; thedesign GET returns it as `aiProvenance` and the editor hydrates it.- `PUT|GET /api/designs/[id]/ai-provenance` — edit-gated persistence- (same-origin, its own rate budget, flat 404 on foreign designs), plus- a live-DB e2e spec (`tests/e2e/unified-ai-provenance.spec.ts`).+ (same-origin, its own rate budget, NOT_YOUR_DESIGN on foreign+ designs, flat 404 on missing ids), plus a live-DB e2e spec+ (`tests/e2e/unified-ai-provenance.spec.ts`).- `mergeBriefs` / `normalizeStoredBrief` (`src/lib/agent/brief.ts`): thestored contract merges with every chat-agent run on that design —union semantics, hostile input capped, dimensions dropped (the designdiff --git a/docs/UNIFIED-AI-MILESTONE.md b/docs/UNIFIED-AI-MILESTONE.mdindex 912acb3..98f07ff 100644--- a/docs/UNIFIED-AI-MILESTONE.md+++ b/docs/UNIFIED-AI-MILESTONE.md@@ -100,8 +100,10 @@ the enforcement needed no new client-side gate code).- Live-DB e2e: `tests/e2e/unified-ai-provenance.spec.ts` — theprovenance PUT/GET round trip through the real API against realPostgres, normalization asserted, junk/dimension-only briefs 422,- foreign designs a flat 404 (no existence oracle), the design GET- carrying `aiProvenance` back (the hydration path).+ foreign designs follow the designs family (GET link-view 200 with+ null provenance — that viewer can already GET the design itself;+ PUT answers NOT_YOUR_DESIGN 403), missing ids a flat 404, and the+ design GET carrying `aiProvenance` back (the hydration path).## Decisions and disclosed limitsdiff --git a/tests/e2e/unified-ai-provenance.spec.ts b/tests/e2e/unified-ai-provenance.spec.tsindex 2150239..091ef86 100644--- a/tests/e2e/unified-ai-provenance.spec.ts+++ b/tests/e2e/unified-ai-provenance.spec.ts@@ -16,8 +16,10 @@ import { Client } from 'pg'// as aiProvenance — this is what hydrates the editor store// 3. GET /api/designs/[id]/ai-provenance returns it too// 4. a brief with nothing usable is a 422 (honest rejection)-// 5. a foreign design is a flat 404 on both GET and PUT — no-// existence oracle+// 5. foreign designs follow the designs family: GET is link-view+// (200, null provenance — that viewer can already GET the design+// itself), PUT answers NOT_YOUR_DESIGN (403); a missing id is a+// flat 404 on both verbs (no existence oracle)// 6. dimension-only briefs are rejected too (the design owns the// geometry after apply — a stored size would fail every// refinement on a legitimately resized design)@@ -146,18 +148,36 @@ test.describe('design AI provenance (Unified Canvix AI)', () => {await ctx.close()})- test('a foreign design is a flat 404 on both GET and PUT — no existence oracle', async ({ browser }) => {+ test('foreign designs follow the designs family — viewable, never writable; a missing id is a flat 404', async ({ browser }) => {const ctx = await signedInContext(browser)const api = ctx.request+ // GET: link-view semantics, same as GET /api/designs/[id] itself —+ // that viewer can already read the whole design, so the (less+ // sensitive) provenance rides the same rule: null when none storedconst got = await api.fetch(`${BASE}/api/designs/d_e2e_prov_other/ai-provenance`)- expect(got.status()).toBe(404)+ expect(got.status()).toBe(200)+ expect(((await got.json()) as { provenance?: unknown }).provenance).toBeNull()++ // PUT: the family's NOT_YOUR_DESIGN — a foreign design is never+ // writable, and the response says exactly thatconst put = await api.fetch(`${BASE}/api/designs/d_e2e_prov_other/ai-provenance`, {method: 'PUT',headers: { 'Content-Type': 'application/json', origin: BASE },data: { brief: { requiredTexts: [{ text: 'nope' }] } },})- expect(put.status()).toBe(404)+ expect(put.status()).toBe(403)++ // a design that does not exist is a flat 404 on both verbs — no+ // existence oracle+ const gotMissing = await api.fetch(`${BASE}/api/designs/d_e2e_prov_does_not_exist/ai-provenance`)+ expect(gotMissing.status()).toBe(404)+ const putMissing = await api.fetch(`${BASE}/api/designs/d_e2e_prov_does_not_exist/ai-provenance`, {+ method: 'PUT',+ headers: { 'Content-Type': 'application/json', origin: BASE },+ data: { brief: { requiredTexts: [{ text: 'nope' }] } },+ })+ expect(putMissing.status()).toBe(404)await ctx.close()})