| 1 | import { describe, expect, it } from "vitest"; |
| 2 | import { funnelExit, funnelPath } from "./funnel"; |
| 3 | |
| 4 | describe("bounded website acquisition categories", () => { |
| 5 | it("recognizes all mapped documentation without collecting paths", () => { |
| 6 | for (const locale of ["en", "zh", "pt-BR", "pt-br", "ar"]) { |
| 7 | for (const path of ["install", "models", "plugins", "docs/constitution", "docs/runtime-reference"]) expect(funnelPath(`/${locale}/${path}`)).toMatchObject({ documentation: true }); |
| 8 | expect(funnelPath(`/${locale}`)).toEqual({ view: "home_view", documentation: false }); |
| 9 | expect(funnelPath(`/${locale}/docs/guide`)).toEqual({ view: "quickstart_view", documentation: true }); |
| 10 | expect(funnelPath(`/${locale}/contribute`)).toEqual({ view: "contribute_view", documentation: false }); |
| 11 | } |
| 12 | expect(funnelPath("/en/community/docs-club")).toEqual({ view: null, documentation: false }); |
| 13 | expect(funnelPath("/unknown/install")).toEqual({ view: null, documentation: false }); |
| 14 | }); |
| 15 | it("returns only bounded categories for public contribution destinations", () => { |
| 16 | expect(funnelExit("https://github.com/codewhale-hq/CodeWhale/issues/new?template=bug_report.yml")).toBe("issue_exit"); |
| 17 | expect(funnelExit("https://github.com/codewhale-hq/Codewhale/issues/new/choose")).toBe("issue_exit"); |
| 18 | expect(funnelExit("https://github.com/codewhale-hq/CodeWhale/issues?q=is%3Aopen+label%3A%22help+wanted%22")).toBe("help_wanted_exit"); |
| 19 | expect(funnelExit("https://github.com/codewhale-hq/CodeWhale/blob/main/CONTRIBUTING.md#standing-projects")).toBe("guide_exit"); |
| 20 | for (const href of ["https://github.com.evil.test/codewhale-hq/Codewhale/issues/new", "http://github.com/codewhale-hq/Codewhale/issues/new", "javascript:alert(1)", "https://github.com/other/private/issues/new", "/en/docs/guide", "https://github.com/codewhale-hq/Codewhale/issues/123"]) expect(funnelExit(href)).toBeNull(); |
| 21 | }); |
| 22 | }); |
| 23 |