g1t/apps/web/app/lib/chrome.test.ts
| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { VISITOR_LINKS, projectPages, usesAppShell } from "./chrome.ts"; |
| 5 | |
| 6 | test("someone signed in always gets the sidebar", () => { |
| 7 | for (const path of ["/", "/pricing", "/acme/web", "/explore", "/does/not/exist"]) { |
| 8 | assert.equal(usesAppShell(path, true), true, path); |
| 9 | } |
| 10 | }); |
| 11 | |
| 12 | test("a visitor gets the sidebar on app pages", () => { |
| 13 | for (const path of [ |
| 14 | "/acme/web", |
| 15 | "/acme/web/code", |
| 16 | "/acme/web/issues/4", |
| 17 | "/explore", |
| 18 | "/search", |
| 19 | "/u/ada", |
| 20 | "/acme", |
| 21 | "/nothing/here/at/all", |
| 22 | ]) { |
| 23 | assert.equal(usesAppShell(path, false), true, path); |
| 24 | } |
| 25 | }); |
| 26 | |
| 27 | test("a visitor gets the marketing frame on the front, pricing and sign-in pages", () => { |
| 28 | for (const path of ["/", "/pricing", "/pricing/", "/login", "/register", "/verify", "/forgot", "/reset", "/device", "/oauth/authorize"]) { |
| 29 | assert.equal(usesAppShell(path, false), false, path); |
| 30 | } |
| 31 | }); |
| 32 | |
| 33 | test("a visitor's sidebar offers Explore and Search", () => { |
| 34 | assert.deepEqual(VISITOR_LINKS.map((link) => link.to), ["/explore", "/search"]); |
| 35 | }); |
| 36 | |
| 37 | test("a project's menu hides member-only pages from everyone else", () => { |
| 38 | const visitor = projectPages(false); |
| 39 | assert.deepEqual(visitor.slice(0, 5), ["code", "issues", "pulls", "agents", "actions"]); |
| 40 | for (const page of ["deployments", "security", "settings"] as const) { |
| 41 | assert.ok(!visitor.includes(page), page); |
| 42 | assert.ok(projectPages(true).includes(page), page); |
| 43 | } |
| 44 | }); |