issues-pulls.test.js
3,082 bytes
| 1 | import { afterEach, describe, expect, it } from "vitest"; |
|---|---|
| 2 | import { createShare, makeHarness } from "./helpers.js"; |
| 3 | |
| 4 | describe("issues and pull requests", () => { |
| 5 | let harness; |
| 6 | afterEach(() => harness.close()); |
| 7 | |
| 8 | it("shows frozen issue lists, filters, conversations, and labels", async () => { |
| 9 | harness = makeHarness(); |
| 10 | const { id } = await createShare(harness); |
| 11 | |
| 12 | const list = await harness.agent.get(`/s/${id}/repositories/101?tab=issues`).expect(200); |
| 13 | expect(list.text).toContain("Improve atlas keyboard navigation"); |
| 14 | expect(list.text).toContain("accessibility"); |
| 15 | expect(list.text).toContain("?issue=12"); |
| 16 | |
| 17 | const closed = await harness.agent |
| 18 | .get(`/s/${id}/repositories/101?tab=issues&state=closed`) |
| 19 | .expect(200); |
| 20 | expect(closed.text).toContain("No closed issues are included in this snapshot."); |
| 21 | |
| 22 | const detail = await harness.agent.get(`/s/${id}/repositories/101?issue=12`).expect(200); |
| 23 | expect(detail.text).toContain("The file browser should be usable without a mouse."); |
| 24 | expect(detail.text).toContain("Focus should return to the branch button"); |
| 25 | expect(detail.text).toContain("Read only"); |
| 26 | expect(detail.text).not.toMatch(/<form[^>]+method=["']?post/i); |
| 27 | }); |
| 28 | |
| 29 | it("shows frozen pull request reviews and changed-file diffs", async () => { |
| 30 | harness = makeHarness(); |
| 31 | const { id } = await createShare(harness); |
| 32 | |
| 33 | const list = await harness.agent.get(`/s/${id}/repositories/101?tab=pulls`).expect(200); |
| 34 | expect(list.text).toContain("Add atlas keyboard shortcuts"); |
| 35 | expect(list.text).toContain("enhancement"); |
| 36 | expect(list.text).toContain("?pull=14"); |
| 37 | |
| 38 | const detail = await harness.agent.get(`/s/${id}/repositories/101?pull=14`).expect(200); |
| 39 | expect(detail.text).toContain("keyboard-navigation"); |
| 40 | expect(detail.text).toContain("The keyboard flow works as expected."); |
| 41 | expect(detail.text).toContain("Files changed"); |
| 42 | expect(detail.text).toContain("src/index.js"); |
| 43 | expect(detail.text).toContain("export const keyboard = true;"); |
| 44 | expect(detail.text).toMatch(/diff-row-addition[\s\S]*?diff-gutter">2<\/td>/); |
| 45 | }); |
| 46 | |
| 47 | it("finds issues and pull requests through snapshot search", async () => { |
| 48 | harness = makeHarness(); |
| 49 | const { id } = await createShare(harness); |
| 50 | |
| 51 | const issues = await harness.agent.get(`/s/${id}/search?q=without+a+mouse&type=issues`).expect(200); |
| 52 | expect(issues.text).toContain("Improve atlas keyboard navigation"); |
| 53 | expect(issues.text).toContain(`repositories/101?issue=12`); |
| 54 | |
| 55 | const pulls = await harness.agent.get(`/s/${id}/search?q=keyboard+flow&type=pulls`).expect(200); |
| 56 | expect(pulls.text).toContain("Add atlas keyboard shortcuts"); |
| 57 | expect(pulls.text).toContain(`repositories/101?pull=14`); |
| 58 | }); |
| 59 | |
| 60 | it("rejects issue and pull request numbers outside the snapshot", async () => { |
| 61 | harness = makeHarness(); |
| 62 | const { id } = await createShare(harness); |
| 63 | await harness.agent.get(`/s/${id}/repositories/101?issue=999`).expect(404); |
| 64 | await harness.agent.get(`/s/${id}/repositories/101?pull=999`).expect(404); |
| 65 | }); |
| 66 | }); |
| 67 | |