import { afterEach, describe, expect, it, vi } from "vitest"; import { cleanup, render, screen } from "@testing-library/react"; import { TaskLayout } from "./task-layout"; afterEach(cleanup); // Every hop between the task page and the phone header is an optional prop, so // a dropped one is not a type error. This asserts the hop TaskLayout owns: the // repository label reaches the phone layout. `session-mobile-top-bar-repository` // covers what the header does with it. vi.mock("./mobile", () => ({ SessionMobileLayout: ({ repositoryLabel }: { repositoryLabel?: string | null }) => (
), SessionTabletLayout: () =>
, })); vi.mock("@/hooks/use-responsive-breakpoint", () => ({ useResponsiveBreakpoint: () => ({ isMobile: true, usesDesktopWorkbench: false }), })); vi.mock("@/hooks/domains/features/use-feature", () => ({ useFeature: () => true, })); vi.mock("./task-launch-error-context", () => ({ useTaskLaunchErrorContext: () => ({ error: null, repositories: [] }), })); describe("TaskLayout repository label", () => { it("hands the repository label to the phone layout", () => { render(); expect(screen.getByTestId("mobile-layout").getAttribute("data-repository-label")).toBe( "kdlbs/kandev", ); }); it("passes nothing along for a task with no repository", () => { render(); expect(screen.getByTestId("mobile-layout").getAttribute("data-repository-label")).toBe(""); }); });