33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { cleanup, render, screen } from "@testing-library/react";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import { StateProvider } from "@/components/state-provider";
|
|
import { TaskLoadErrorState } from "./task-page-content";
|
|
|
|
afterEach(cleanup);
|
|
|
|
function renderErrorState(activeId: string | null) {
|
|
render(
|
|
<StateProvider initialState={{ workspaces: { items: [], activeId } }}>
|
|
<TaskLoadErrorState />
|
|
</StateProvider>,
|
|
);
|
|
}
|
|
|
|
describe("TaskLoadErrorState", () => {
|
|
it("preserves the active workspace in the overview destination", () => {
|
|
renderErrorState("ws-1");
|
|
|
|
const link = screen.getByTestId("task-unavailable-overview-link");
|
|
expect(link.getAttribute("href")).toBe("/?home=overview&workspaceId=ws-1");
|
|
expect(link.className).toContain("min-h-11");
|
|
});
|
|
|
|
it("falls back to the unscoped overview when no workspace is active", () => {
|
|
renderErrorState(null);
|
|
|
|
expect(screen.getByTestId("task-unavailable-overview-link").getAttribute("href")).toBe(
|
|
"/?home=overview",
|
|
);
|
|
});
|
|
});
|