|
| 1 | +import { render } from "@/lib/test-utils"; |
| 2 | +import { screen } from "@testing-library/react"; |
| 3 | +import { describe, expect, it } from "vitest"; |
| 4 | +import { Certificates } from "../Certificates"; |
| 5 | +import userEvent from "@testing-library/user-event"; |
| 6 | + |
| 7 | +describe("Certificates", () => { |
| 8 | + it("should render download certificate", () => { |
| 9 | + render(<Certificates />); |
| 10 | + expect( |
| 11 | + screen.getByRole("heading", { name: "CodeGate CA certificate" }), |
| 12 | + ).toBeVisible(); |
| 13 | + expect( |
| 14 | + screen.getByRole("button", { name: "Download certificate" }), |
| 15 | + ).toBeVisible(); |
| 16 | + expect(screen.getByRole("link", { name: "Learn more" })).toHaveAttribute( |
| 17 | + "href", |
| 18 | + "/certificates/security", |
| 19 | + ); |
| 20 | + |
| 21 | + expect( |
| 22 | + screen.getByRole("heading", { name: "Certificate Management" }), |
| 23 | + ).toBeVisible(); |
| 24 | + |
| 25 | + expect(screen.getByText("macOS")).toBeVisible(); |
| 26 | + expect(screen.getByText("Windows")).toBeVisible(); |
| 27 | + expect(screen.getByText("Linux")).toBeVisible(); |
| 28 | + }); |
| 29 | + |
| 30 | + it("should render macOS certificate installation", async () => { |
| 31 | + render(<Certificates />); |
| 32 | + |
| 33 | + expect( |
| 34 | + screen.getByText( |
| 35 | + "Open the downloaded certificate file. Keychain Access launches and imports the cert automatically.", |
| 36 | + ), |
| 37 | + ).toBeVisible(); |
| 38 | + |
| 39 | + await userEvent.click( |
| 40 | + screen.getByRole("button", { name: "Remove certificate" }), |
| 41 | + ); |
| 42 | + expect(screen.getByText("Launch the Keychain Access app.")).toBeVisible(); |
| 43 | + }); |
| 44 | + |
| 45 | + it("should render Windows certificate installation", async () => { |
| 46 | + render(<Certificates />); |
| 47 | + |
| 48 | + await userEvent.click(screen.getByText("Windows")); |
| 49 | + |
| 50 | + expect( |
| 51 | + screen.getByText("Double-click the downloaded certificate file."), |
| 52 | + ).toBeVisible(); |
| 53 | + |
| 54 | + await userEvent.click( |
| 55 | + screen.getByRole("button", { name: "Remove certificate" }), |
| 56 | + ); |
| 57 | + expect(screen.getByText("certmgr.msc")).toBeVisible(); |
| 58 | + }); |
| 59 | + |
| 60 | + it("should render Linux certificate installation", async () => { |
| 61 | + render(<Certificates />); |
| 62 | + |
| 63 | + await userEvent.click(screen.getByText("Linux")); |
| 64 | + |
| 65 | + expect( |
| 66 | + screen.getByText("/usr/local/share/ca-certificates/codegate.crt"), |
| 67 | + ).toBeVisible(); |
| 68 | + |
| 69 | + await userEvent.click( |
| 70 | + screen.getByRole("button", { name: "Remove certificate" }), |
| 71 | + ); |
| 72 | + expect(screen.getByText("/usr/local/share/ca-certificates/")).toBeVisible(); |
| 73 | + }); |
| 74 | +}); |
0 commit comments