fix(workstate): normalisation du work-state pour éviter l'onglet Work vide
Normalise l'état Work pour empêcher l'affichage d'un onglet Work vide. QA VERT : tsc --noEmit exit 0 ; vitest run 42 fichiers / 407 tests passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -10,7 +10,10 @@ import {
|
||||
} from "@/adapters/mock";
|
||||
import { leaves } from "@/features/layout/layout";
|
||||
import type { Gateways } from "@/ports";
|
||||
import { ProjectWorkStatePanel } from "./ProjectWorkStatePanel";
|
||||
import {
|
||||
ProjectWorkStatePanel,
|
||||
WorkStatePanelErrorBoundary,
|
||||
} from "./ProjectWorkStatePanel";
|
||||
|
||||
const PROJECT_ID = "project-work-state-test";
|
||||
|
||||
@ -173,7 +176,7 @@ describe("ProjectWorkStatePanel", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("normalizes mock work state without tickets", async () => {
|
||||
it("renders a legacy agent without tickets", async () => {
|
||||
const workState = new MockWorkStateGateway();
|
||||
workState._setProjectWorkState(PROJECT_ID, {
|
||||
agents: [
|
||||
@ -186,20 +189,42 @@ describe("ProjectWorkStatePanel", () => {
|
||||
],
|
||||
});
|
||||
|
||||
renderPanel(workState);
|
||||
|
||||
expect(await screen.findByText("Legacy")).toBeTruthy();
|
||||
expect(screen.getByText("Offline")).toBeTruthy();
|
||||
expect(screen.getByText("Idle")).toBeTruthy();
|
||||
expect(screen.queryByLabelText("Legacy tickets")).toBeNull();
|
||||
});
|
||||
|
||||
it("normalizes missing top-level work state arrays", async () => {
|
||||
const workState = new MockWorkStateGateway();
|
||||
workState._setProjectWorkState(PROJECT_ID, {});
|
||||
|
||||
await expect(workState.getProjectWorkState(PROJECT_ID)).resolves.toEqual({
|
||||
agents: [
|
||||
{
|
||||
agentId: "agent-6",
|
||||
name: "Legacy",
|
||||
profileId: "gemini",
|
||||
busy: { state: "idle" },
|
||||
tickets: [],
|
||||
},
|
||||
],
|
||||
agents: [],
|
||||
conversations: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("renders an error fallback instead of blanking the app when Work throws", () => {
|
||||
function BrokenWorkPanel(): JSX.Element {
|
||||
throw new Error("render exploded");
|
||||
}
|
||||
|
||||
render(
|
||||
<WorkStatePanelErrorBoundary>
|
||||
<BrokenWorkPanel />
|
||||
</WorkStatePanelErrorBoundary>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole("alert").textContent).toContain(
|
||||
"Work panel failed to render.",
|
||||
);
|
||||
expect(screen.getByText("render exploded")).toBeTruthy();
|
||||
expect(screen.getByRole("button", { name: "Retry" })).toBeTruthy();
|
||||
});
|
||||
|
||||
it("renders conversation objective and summary joined by conversation id", async () => {
|
||||
const workState = new MockWorkStateGateway();
|
||||
workState._setProjectWorkState(PROJECT_ID, {
|
||||
|
||||
Reference in New Issue
Block a user