profile-page.test.js
1,583 bytes
| 1 | import request from "supertest"; |
|---|---|
| 2 | import { afterEach, describe, expect, it } from "vitest"; |
| 3 | import { createShare, makeHarness } from "./helpers.js"; |
| 4 | |
| 5 | describe("profile page", () => { |
| 6 | let harness; |
| 7 | afterEach(() => harness.close()); |
| 8 | |
| 9 | it("is public and shows the profile, selected projects, and activity", async () => { |
| 10 | harness = makeHarness(); |
| 11 | const { id } = await createShare(harness, [101, 202]); |
| 12 | const sessionsBefore = harness.store.sessionCount(); |
| 13 | const page = await request(harness.app).get(`/s/${id}`).expect(200); |
| 14 | expect(page.text).toContain("Rasmus"); |
| 15 | expect(page.text).toContain("atlas"); |
| 16 | expect(page.text).toContain("ledger"); |
| 17 | expect(page.text).toContain("Recent work across the snapshot"); |
| 18 | expect(page.text).toContain(`/s/${id}/repositories/101?commit=101`); |
| 19 | expect(page.headers["cache-control"]).toBe("private, no-store"); |
| 20 | expect(page.headers["set-cookie"]).toBeUndefined(); |
| 21 | expect(harness.store.sessionCount()).toBe(sessionsBefore); |
| 22 | }); |
| 23 | |
| 24 | it("provides a GitHub-style repository tab with search and language filters", async () => { |
| 25 | harness = makeHarness(); |
| 26 | const { id } = await createShare(harness, [101, 202]); |
| 27 | const page = await harness.agent |
| 28 | .get(`/s/${id}?tab=repositories&q=expense&language=TypeScript`) |
| 29 | .expect(200); |
| 30 | expect(page.text).toContain('aria-current="page"'); |
| 31 | expect(page.text).toContain("Find a repository"); |
| 32 | expect(page.text).toContain(">ledger</a>"); |
| 33 | expect(page.text).not.toContain(">atlas</a>"); |
| 34 | expect(page.text).toContain("Open repository"); |
| 35 | }); |
| 36 | }); |
| 37 | |