File size: 2,169 Bytes
c2a37bc ba4421e c2a37bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import { act, fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import FloatingRouterHelper from "./FloatingRouterHelper";
import { dispatchAppCommand } from "../utils/appCommands";
describe("FloatingRouterHelper", () => {
it("renders one shared help launcher when closed", () => {
render(<FloatingRouterHelper />);
const button = screen.getByRole("button", { name: "Open help and assist launcher" });
expect(button).toHaveTextContent("Help");
expect(screen.queryByText("Get support")).not.toBeInTheDocument();
expect(screen.queryByText("Open router helper")).not.toBeInTheDocument();
});
it("opens the support tab from the support command", () => {
render(<FloatingRouterHelper />);
act(() => {
dispatchAppCommand("support:open");
});
expect(screen.getByRole("tabpanel", { name: "Support tab" })).toBeInTheDocument();
expect(screen.getByRole("tab", { name: "Support" })).toHaveAttribute("aria-selected", "true");
expect(screen.getByRole("link", { name: "Open Slack support" })).toBeInTheDocument();
});
it("opens the assist tab from the helper command", () => {
render(<FloatingRouterHelper />);
act(() => {
dispatchAppCommand("router_helper:open");
});
expect(screen.getByRole("tabpanel", { name: "Assist tab" })).toBeInTheDocument();
expect(screen.getByRole("tab", { name: "Assist" })).toHaveAttribute("aria-selected", "true");
expect(screen.queryByText("SECURITY CHECK")).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Ask assist" })).toBeDisabled();
});
it("lets the user switch between assist and support in one launcher", () => {
render(<FloatingRouterHelper />);
fireEvent.click(screen.getByRole("button", { name: "Open help and assist launcher" }));
fireEvent.click(screen.getByRole("tab", { name: "Support" }));
expect(screen.getByRole("tabpanel", { name: "Support tab" })).toBeInTheDocument();
fireEvent.click(screen.getByRole("tab", { name: "Assist" }));
expect(screen.getByRole("tabpanel", { name: "Assist tab" })).toBeInTheDocument();
});
});
|