···25802580 expect(body.error).toContain("Forum agent not available");
25812581 });
2582258225832583+ it("returns 503 when ForumAgent not authenticated", async () => {
25842584+ const originalAgent = ctx.forumAgent;
25852585+ ctx.forumAgent = { getAgent: () => null } as any;
25862586+ const res = await app.request("/api/admin/themes", {
25872587+ method: "POST",
25882588+ headers: { "Content-Type": "application/json" },
25892589+ body: JSON.stringify({ name: "Test", colorScheme: "light", tokens: {} }),
25902590+ });
25912591+ expect(res.status).toBe(503);
25922592+ const body = await res.json();
25932593+ expect(body.error).toBe("Forum agent not authenticated. Please try again later.");
25942594+ expect(mockPutRecord).not.toHaveBeenCalled();
25952595+ ctx.forumAgent = originalAgent;
25962596+ });
25972597+25832598 it("returns 401 when not authenticated", async () => {
25842599 mockUser = null;
25852600 const res = await app.request("/api/admin/themes", {
···27982813 });
27992814 });
2800281528162816+ it("returns 503 when ForumAgent not authenticated", async () => {
28172817+ const originalAgent = ctx.forumAgent;
28182818+ ctx.forumAgent = { getAgent: () => null } as any;
28192819+ const res = await app.request(`/api/admin/themes/${TEST_RKEY}`, {
28202820+ method: "PUT",
28212821+ headers: { "Content-Type": "application/json" },
28222822+ body: JSON.stringify({ name: "Updated", colorScheme: "light", tokens: {} }),
28232823+ });
28242824+ expect(res.status).toBe(503);
28252825+ const body = await res.json();
28262826+ expect(body.error).toBe("Forum agent not authenticated. Please try again later.");
28272827+ expect(mockPutRecord).not.toHaveBeenCalled();
28282828+ ctx.forumAgent = originalAgent;
28292829+ });
28302830+28012831 it("returns 503 when PDS write fails with a network error", async () => {
28022832 mockPutRecord.mockRejectedValueOnce(new Error("fetch failed"));
28032833 const res = await app.request(`/api/admin/themes/${TEST_RKEY}`, {
···29372967 mockRequirePermission.mockImplementation(() => async (_c: any, next: any) => {
29382968 await next();
29392969 });
29702970+ });
29712971+29722972+ it("returns 503 when ForumAgent not authenticated", async () => {
29732973+ const originalAgent = ctx.forumAgent;
29742974+ ctx.forumAgent = { getAgent: () => null } as any;
29752975+ const res = await app.request(`/api/admin/themes/${themeRkey}`, {
29762976+ method: "DELETE",
29772977+ });
29782978+ expect(res.status).toBe(503);
29792979+ const body = await res.json();
29802980+ expect(body.error).toBe("Forum agent not authenticated. Please try again later.");
29812981+ expect(mockDeleteRecord).not.toHaveBeenCalled();
29822982+ ctx.forumAgent = originalAgent;
29402983 });
2941298429422985 it("returns 503 when PDS delete fails with a network error", async () => {
···31623205 expect(res.status).toBe(500);
31633206 const body = await res.json();
31643207 expect(body.error).toContain("Forum agent not available");
32083208+ });
32093209+32103210+ it("returns 503 when ForumAgent not authenticated", async () => {
32113211+ const originalAgent = ctx.forumAgent;
32123212+ ctx.forumAgent = { getAgent: () => null } as any;
32133213+ const res = await app.request("/api/admin/theme-policy", {
32143214+ method: "PUT",
32153215+ headers: { "Content-Type": "application/json" },
32163216+ body: JSON.stringify(validBody),
32173217+ });
32183218+ expect(res.status).toBe(503);
32193219+ const body = await res.json();
32203220+ expect(body.error).toBe("Forum agent not authenticated. Please try again later.");
32213221+ expect(mockPutRecord).not.toHaveBeenCalled();
32223222+ ctx.forumAgent = originalAgent;
31653223 });
31663224 });
31673225
+2-1
bruno/AppView API/Admin Themes/Create Theme.bru
···5050 - 400: Missing name/colorScheme/tokens, invalid colorScheme, non-HTTPS fontUrl, token value not a string, malformed JSON
5151 - 401: Not authenticated
5252 - 403: Missing manageThemes permission
5353- - 503: ForumAgent not configured or PDS network error
5353+ - 500: ForumAgent not configured (server configuration issue)
5454+ - 503: ForumAgent not authenticated or PDS network error
5455}
+2-1
bruno/AppView API/Admin Themes/Delete Theme.bru
···3232 - 403: Missing manageThemes permission
3333 - 404: Theme not found
3434 - 409: Theme is the current defaultLightTheme or defaultDarkTheme — update theme policy first
3535- - 503: ForumAgent not configured or PDS network error
3535+ - 500: ForumAgent not configured (server configuration issue)
3636+ - 503: ForumAgent not authenticated or PDS network error
3637}