545cd0b599
Move task plugin actions and destinations into the shared mobile Plugins menu, preserving a compact task header and accessible touch targets. Add focused mobile coverage, plugin authoring documentation, and process-probe stability handling.
89 lines
2.9 KiB
TypeScript
89 lines
2.9 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { cleanup, render, screen } from "@testing-library/react";
|
|
import { StateProvider } from "@/components/state-provider";
|
|
import { ToastProvider } from "@/components/toast-provider";
|
|
import { TooltipProvider } from "@kandev/ui/tooltip";
|
|
import { SessionMobileTopBar } from "./session-mobile-top-bar";
|
|
|
|
afterEach(cleanup);
|
|
|
|
// Git metrics are not what this file is about; stub the two session-data hooks
|
|
// so the header renders standalone.
|
|
vi.mock("@/hooks/domains/session/use-session-git-status", () => ({
|
|
useSessionGitStatus: () => ({ files: [] }),
|
|
useSessionGitStatusByRepo: () => [],
|
|
}));
|
|
|
|
vi.mock("@/hooks/domains/session/use-session-commits", () => ({
|
|
useSessionCommits: () => ({ commits: [] }),
|
|
}));
|
|
|
|
// Trailing controls the header composes but this file does not exercise.
|
|
vi.mock("@/components/task/port-forward-dialog", () => ({
|
|
PortForwardButton: () => null,
|
|
}));
|
|
|
|
vi.mock("@/components/task/task-top-bar-plugin-actions", () => ({
|
|
TaskTopBarPluginActions: () => null,
|
|
useHasTaskTopBarPluginActions: () => false,
|
|
}));
|
|
|
|
vi.mock("@/components/gitlab/mr-topbar-button", () => ({
|
|
MRTopbarButton: () => null,
|
|
}));
|
|
|
|
vi.mock("@/components/task/task-unarchive-button", () => ({
|
|
TaskUnarchiveButton: ({ mobile }: { mobile?: boolean }) =>
|
|
mobile ? <button data-testid="mobile-unarchive-button">Unarchive</button> : null,
|
|
}));
|
|
|
|
const REPOSITORY_TEST_ID = "mobile-task-repository";
|
|
|
|
function renderTopBar(props: Record<string, unknown> = {}) {
|
|
return render(
|
|
<StateProvider>
|
|
<ToastProvider>
|
|
<TooltipProvider>
|
|
<SessionMobileTopBar
|
|
taskId="task-1"
|
|
workspaceId="ws-1"
|
|
taskTitle="Pin the RDS engine version"
|
|
sessionId="session-1"
|
|
onTaskPickerClick={vi.fn()}
|
|
taskPickerOpen={false}
|
|
{...props}
|
|
/>
|
|
</TooltipProvider>
|
|
</ToastProvider>
|
|
</StateProvider>,
|
|
);
|
|
}
|
|
|
|
describe("SessionMobileTopBar repository", () => {
|
|
it("names the task's repository, so the phone header says which project this is", () => {
|
|
renderTopBar({ repositoryLabel: "kdlbs/kandev" });
|
|
|
|
expect(screen.getByTestId(REPOSITORY_TEST_ID).textContent).toBe("kdlbs/kandev");
|
|
});
|
|
|
|
it("keeps the full repository name reachable on hover when it is truncated", () => {
|
|
renderTopBar({ repositoryLabel: "acme-platform/infra-terraform-modules" });
|
|
|
|
expect(screen.getByTestId(REPOSITORY_TEST_ID).getAttribute("title")).toBe(
|
|
"acme-platform/infra-terraform-modules",
|
|
);
|
|
});
|
|
|
|
it("renders nothing when the task has no repository", () => {
|
|
renderTopBar();
|
|
|
|
expect(screen.queryByTestId(REPOSITORY_TEST_ID)).toBeNull();
|
|
});
|
|
|
|
it("renders the existing unarchive action in the mobile top bar", () => {
|
|
renderTopBar({ isArchived: true });
|
|
|
|
expect(screen.getByTestId("mobile-unarchive-button")).toBeTruthy();
|
|
});
|
|
});
|