import { describe, it, expect, vi } from "vitest";
import { renderWithProviders, screen, fireEvent } from "@/test/render";
import { ConnectivityErrorScreen } from "./connectivity-error-screen";
describe("ConnectivityErrorScreen", () => {
it("renders the message without a retry button by default", async () => {
await renderWithProviders(, { waitForButton: false });
expect(
await screen.findByRole("heading", { name: /can't reach the server/i }),
).toBeInTheDocument();
expect(screen.queryByRole("button", { name: /retry/i })).not.toBeInTheDocument();
});
it("calls onRetry when the retry button is clicked", async () => {
const onRetry = vi.fn();
await renderWithProviders(, {
waitForButton: false,
});
fireEvent.click(await screen.findByRole("button", { name: /retry/i }));
expect(onRetry).toHaveBeenCalledOnce();
});
});