| 1 | import { renderToStaticMarkup } from "react-dom/server"; |
| 2 | import { describe, expect, it } from "vitest"; |
| 3 | import InstallPage from "@/app/[locale]/install/page"; |
| 4 | import { getFacts } from "@/lib/facts"; |
| 5 | import { claimAvailability, runtimeCapabilityContext } from "@/lib/capabilities"; |
| 6 | |
| 7 | async function render(locale: string): Promise<string> { |
| 8 | return renderToStaticMarkup(await InstallPage({ params: Promise.resolve({ locale }) })); |
| 9 | } |
| 10 | |
| 11 | describe("install page", () => { |
| 12 | it("prints the published release version and never a hand-typed one", async () => { |
| 13 | const facts = await getFacts(); |
| 14 | const version = facts.latestPublishedRelease?.version; |
| 15 | expect(version).toBeTruthy(); |
| 16 | const html = await render("en"); |
| 17 | expect(html).toContain(`v${version}`); |
| 18 | expect(html).toContain(`<code>codewhale ${version}</code>`); |
| 19 | }); |
| 20 | |
| 21 | it("shows the uninstall command only when the published release has it", async () => { |
| 22 | const facts = await getFacts(); |
| 23 | const released = claimAvailability({ feature: "unix-uninstall" }, runtimeCapabilityContext(facts)) === "released"; |
| 24 | const html = await render("en"); |
| 25 | expect(html.includes("codewhale uninstall")).toBe(released); |
| 26 | }); |
| 27 | |
| 28 | it("states what the installer adds to the profile and never tells people to open a new terminal because it changed PATH", async () => { |
| 29 | const html = await render("en"); |
| 30 | expect(html).toContain("# >>> codewhale PATH >>>"); |
| 31 | expect(html).toContain("--no-modify-path"); |
| 32 | expect(html).toContain('id="mirrors"'); |
| 33 | expect(html).not.toContain("Open a new terminal if the installer changed your PATH"); |
| 34 | }); |
| 35 | }); |
| 36 |