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.

test: Settings nav link auth visibility tests

+54
+54
apps/web/src/layouts/__tests__/base.test.tsx
··· 211 211 expect(html).toContain('method="post"'); 212 212 expect(html).toContain("Log out"); 213 213 }); 214 + 215 + it("shows Settings link when authenticated", async () => { 216 + const auth: WebSession = { 217 + authenticated: true, 218 + did: "did:plc:abc123", 219 + handle: "alice.bsky.social", 220 + }; 221 + const authApp = new Hono().get("/", (c) => 222 + c.html( 223 + <BaseLayout auth={auth} resolvedTheme={FALLBACK_THEME}> 224 + content 225 + </BaseLayout> 226 + ) 227 + ); 228 + const res = await authApp.request("/"); 229 + const html = await res.text(); 230 + expect(html).toContain('href="/settings"'); 231 + expect(html).toContain("Settings"); 232 + }); 233 + 234 + it("does not show Settings link when unauthenticated", async () => { 235 + const auth: WebSession = { authenticated: false }; 236 + const unauthApp = new Hono().get("/", (c) => 237 + c.html( 238 + <BaseLayout auth={auth} resolvedTheme={FALLBACK_THEME}> 239 + content 240 + </BaseLayout> 241 + ) 242 + ); 243 + const res = await unauthApp.request("/"); 244 + const html = await res.text(); 245 + expect(html).not.toContain('href="/settings"'); 246 + expect(html).not.toContain("Settings"); 247 + }); 214 248 }); 215 249 216 250 describe("accessibility", () => { ··· 356 390 // Both mobile and desktop nav should have "Log out" 357 391 const logoutMatches = html.match(/Log out/g); 358 392 expect(logoutMatches!.length).toBe(2); 393 + }); 394 + 395 + it("renders Settings link in both desktop and mobile nav when authenticated", async () => { 396 + const auth: WebSession = { 397 + authenticated: true, 398 + did: "did:plc:abc123", 399 + handle: "alice.bsky.social", 400 + }; 401 + const authApp = new Hono().get("/", (c) => 402 + c.html( 403 + <BaseLayout auth={auth} resolvedTheme={FALLBACK_THEME}> 404 + content 405 + </BaseLayout> 406 + ) 407 + ); 408 + const res = await authApp.request("/"); 409 + const html = await res.text(); 410 + // NavContent is rendered twice (desktop + mobile), so the link appears twice 411 + const settingsMatches = [...html.matchAll(/href="\/settings"/g)]; 412 + expect(settingsMatches).toHaveLength(2); 359 413 }); 360 414 }); 361 415 });