This commit is contained in:
@ -9,6 +9,7 @@
|
||||
*/
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
vi.mock("@xterm/xterm", () => ({
|
||||
Terminal: class {
|
||||
@ -54,6 +55,7 @@ import {
|
||||
MockProfileGateway,
|
||||
MockSystemGateway,
|
||||
MockTerminalGateway,
|
||||
MockWorkStateGateway,
|
||||
} from "@/adapters/mock";
|
||||
import { DIProvider } from "@/app/di";
|
||||
import { AnnouncementsProvider } from "@/features/announcements";
|
||||
@ -66,6 +68,7 @@ interface GridSetup {
|
||||
gateways: Gateways;
|
||||
layout: MockLayoutGateway;
|
||||
system: MockSystemGateway;
|
||||
workState: MockWorkStateGateway;
|
||||
}
|
||||
|
||||
async function makeSplitAgentGrid(): Promise<GridSetup> {
|
||||
@ -74,6 +77,7 @@ async function makeSplitAgentGrid(): Promise<GridSetup> {
|
||||
const profileGateway = new MockProfileGateway();
|
||||
const terminal = new MockTerminalGateway();
|
||||
const system = new MockSystemGateway();
|
||||
const workState = new MockWorkStateGateway();
|
||||
await profileGateway.saveProfile(MOCK_REFERENCE_PROFILES[0]);
|
||||
|
||||
const agent = await agentGateway.createAgent("p1", {
|
||||
@ -105,17 +109,22 @@ async function makeSplitAgentGrid(): Promise<GridSetup> {
|
||||
profile: profileGateway,
|
||||
terminal,
|
||||
system,
|
||||
workState,
|
||||
} as unknown as Gateways,
|
||||
layout,
|
||||
system,
|
||||
workState,
|
||||
};
|
||||
}
|
||||
|
||||
function renderGrid(gateways: Gateways) {
|
||||
function renderGrid(
|
||||
gateways: Gateways,
|
||||
props: Partial<ComponentProps<typeof LayoutGrid>> = {},
|
||||
) {
|
||||
return render(
|
||||
<DIProvider gateways={gateways}>
|
||||
<AnnouncementsProvider>
|
||||
<LayoutGrid projectId="p1" cwd="/home/me/proj" />
|
||||
<LayoutGrid projectId="p1" cwd="/home/me/proj" {...props} />
|
||||
</AnnouncementsProvider>
|
||||
</DIProvider>,
|
||||
);
|
||||
@ -197,6 +206,44 @@ describe("LayoutGrid — ticket #48 cell control layering", () => {
|
||||
expect(controls.style.overflow).toBe("hidden");
|
||||
});
|
||||
|
||||
it("keeps busy Cancel above persistent cell controls and removes History (#151, #160)", async () => {
|
||||
const setup = await makeSplitAgentGrid();
|
||||
await setup.layout.mutateLayout("p1", {
|
||||
type: "setCellConversation",
|
||||
target: setup.bId,
|
||||
conversationId: "prior-conv",
|
||||
});
|
||||
setup.workState._setProjectWorkState("p1", {
|
||||
agents: [
|
||||
{
|
||||
agentId: setup.agentId,
|
||||
name: "Worker",
|
||||
profileId: "mock-claude",
|
||||
busy: { state: "busy", sinceMs: 1 },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
renderGrid(setup.gateways, { onOpenConversation: vi.fn() });
|
||||
await flush();
|
||||
|
||||
act(() => setup.system.emit(busy(setup.agentId, true)));
|
||||
|
||||
const cancel = await screen.findByRole("button", {
|
||||
name: `cancel current turn ${setup.bId}`,
|
||||
});
|
||||
const status = cancel.parentElement as HTMLElement;
|
||||
const { controls } = controlsFor(setup.bId);
|
||||
|
||||
expect(status.style.top).toBe("24px");
|
||||
expect(status.style.zIndex).toBe("6");
|
||||
expect(Number(status.style.zIndex)).toBeGreaterThan(Number(controls.style.zIndex));
|
||||
expect(screen.queryByRole("button", {
|
||||
name: `open cell conversation ${setup.bId}`,
|
||||
})).toBeNull();
|
||||
expect(screen.queryByText("History")).toBeNull();
|
||||
});
|
||||
|
||||
it.each<CellAction>(["selector", "split", "close"])(
|
||||
"keeps %s above/clickable over a terminal launch error",
|
||||
async (action) => {
|
||||
|
||||
Reference in New Issue
Block a user