Files
kandev/apps/web/components/task/mobile/session-mobile-bottom-nav.test.tsx
T
2026-07-31 14:23:16 +01:00

87 lines
2.4 KiB
TypeScript

import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { SessionMobileBottomNav } from "./session-mobile-bottom-nav";
afterEach(cleanup);
describe("SessionMobileBottomNav", () => {
it("offers a touch-sized review route for linked merge requests", () => {
const onPanelChange = vi.fn();
render(
<SessionMobileBottomNav
activePanel="chat"
onPanelChange={onPanelChange}
hasReview
showStatus
onOpenStatus={vi.fn()}
/>,
);
const review = screen.getByRole("button", { name: "Review" });
expect(review.className).toContain("min-h-11");
fireEvent.click(review);
expect(onPanelChange).toHaveBeenCalledWith("review");
});
it("does not consume navigation space without a linked merge request", () => {
render(
<SessionMobileBottomNav
activePanel="chat"
onPanelChange={vi.fn()}
showStatus
onOpenStatus={vi.fn()}
/>,
);
expect(screen.queryByRole("button", { name: "Review" })).toBeNull();
});
it("opens Status as an action without changing the selected mobile panel", () => {
const onPanelChange = vi.fn();
const onOpenStatus = vi.fn();
render(
<SessionMobileBottomNav
activePanel="chat"
onPanelChange={onPanelChange}
showStatus
onOpenStatus={onOpenStatus}
/>,
);
fireEvent.click(screen.getByRole("button", { name: "Status" }));
expect(onOpenStatus).toHaveBeenCalledOnce();
expect(onPanelChange).not.toHaveBeenCalled();
});
it("describes an active connectivity warning on the Status action", () => {
render(
<SessionMobileBottomNav
activePanel="chat"
onPanelChange={vi.fn()}
showStatus
onOpenStatus={vi.fn()}
connectionIssueSeverity="lost"
/>,
);
const status = screen.getByRole("button", {
name: "Connection lost for at least 10 seconds. Live updates may be stale.",
});
expect(status.getAttribute("data-connection-severity")).toBe("lost");
});
it("does not reserve navigation space when Status is disabled", () => {
render(
<SessionMobileBottomNav
activePanel="chat"
onPanelChange={vi.fn()}
showStatus={false}
onOpenStatus={vi.fn()}
/>,
);
expect(screen.queryByRole("button", { name: "Status" })).toBeNull();
});
});