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

test(web): add missing network error tests for edit proxy routes (ATB-47)

+20
+20
apps/web/src/routes/__tests__/admin.test.tsx
··· 1209 1209 const location = res.headers.get("location") ?? ""; 1210 1210 expect(location).toContain("error="); 1211 1211 }); 1212 + 1213 + it("redirects with ?error= on network error", async () => { 1214 + setupSession(["space.atbb.permission.manageCategories"]); 1215 + mockFetch.mockRejectedValueOnce(new Error("fetch failed")); 1216 + const routes = await loadAdminRoutes(); 1217 + const res = await routes.request("/admin/structure/categories/5/edit", postForm({ name: "Updated" })); 1218 + expect(res.status).toBe(302); 1219 + const location = res.headers.get("location") ?? ""; 1220 + expect(location).toContain("error="); 1221 + }); 1212 1222 }); 1213 1223 1214 1224 describe("createAdminRoutes — POST /admin/structure/categories/:id/delete", () => { ··· 1530 1540 it("redirects with ?error= on AppView error", async () => { 1531 1541 setupSession(["space.atbb.permission.manageCategories"]); 1532 1542 mockFetch.mockResolvedValueOnce(mockResponse({ error: "Board not found" }, false, 404)); 1543 + const routes = await loadAdminRoutes(); 1544 + const res = await routes.request("/admin/structure/boards/10/edit", postForm({ name: "Updated" })); 1545 + expect(res.status).toBe(302); 1546 + const location = res.headers.get("location") ?? ""; 1547 + expect(location).toContain("error="); 1548 + }); 1549 + 1550 + it("redirects with ?error= on network error", async () => { 1551 + setupSession(["space.atbb.permission.manageCategories"]); 1552 + mockFetch.mockRejectedValueOnce(new Error("fetch failed")); 1533 1553 const routes = await loadAdminRoutes(); 1534 1554 const res = await routes.request("/admin/structure/boards/10/edit", postForm({ name: "Updated" })); 1535 1555 expect(res.status).toBe(302);