WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(appview): strengthen theme-policy type guards and test assertions (ATB-57)

Malpercio 7513c8ae 00f04ca9

+14 -2
+10
apps/appview/src/routes/__tests__/admin.test.ts
··· 2990 2990 expect(call.record.defaultDarkTheme).toEqual({ theme: { uri: darkUri, cid: "bafydark" } }); 2991 2991 expect(call.record.allowUserChoice).toBe(true); 2992 2992 expect(typeof call.record.updatedAt).toBe("string"); 2993 + expect(call.collection).toBe("space.atbb.forum.themePolicy"); 2994 + expect(call.repo).toBe(ctx.config.forumDid); 2993 2995 }); 2994 2996 2995 2997 it("overwrites existing policy (upsert) and returns 200 with uri and cid", async () => { ··· 3045 3047 body: JSON.stringify({ ...validBody, availableThemes: [] }), 3046 3048 }); 3047 3049 expect(res.status).toBe(400); 3050 + const body = await res.json(); 3051 + expect(body.error).toMatch(/availableThemes/i); 3048 3052 }); 3049 3053 3050 3054 it("returns 400 when availableThemes item is missing cid", async () => { ··· 3059 3063 }), 3060 3064 }); 3061 3065 expect(res.status).toBe(400); 3066 + const body = await res.json(); 3067 + expect(body.error).toMatch(/uri.*cid|cid.*uri|uri and cid/i); 3062 3068 }); 3063 3069 3064 3070 it("returns 400 when defaultLightThemeUri is not in availableThemes", async () => { ··· 3097 3103 body: JSON.stringify(bodyWithout), 3098 3104 }); 3099 3105 expect(res.status).toBe(400); 3106 + const body = await res.json(); 3107 + expect(body.error).toMatch(/defaultLightThemeUri/i); 3100 3108 }); 3101 3109 3102 3110 it("returns 400 when defaultDarkThemeUri is missing", async () => { ··· 3107 3115 body: JSON.stringify(bodyWithout), 3108 3116 }); 3109 3117 expect(res.status).toBe(400); 3118 + const body = await res.json(); 3119 + expect(body.error).toMatch(/defaultDarkThemeUri/i); 3110 3120 }); 3111 3121 3112 3122 it("returns 401 when not authenticated", async () => {
+4 -2
apps/appview/src/routes/admin.ts
··· 1269 1269 } 1270 1270 for (const t of availableThemes as unknown[]) { 1271 1271 if ( 1272 - typeof (t as any)?.uri !== "string" || 1273 - typeof (t as any)?.cid !== "string" 1272 + typeof t !== "object" || 1273 + t === null || 1274 + typeof (t as Record<string, unknown>).uri !== "string" || 1275 + typeof (t as Record<string, unknown>).cid !== "string" 1274 1276 ) { 1275 1277 return c.json({ error: "Each availableThemes entry must have uri and cid string fields" }, 400); 1276 1278 }