import type { AttentionItem } from "@protocol/types"; import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import { beforeAll, describe, expect, it, vi } from "vitest"; import { setLanguage } from "@/lib/i18n"; import { AttentionDialog } from "@/features/chat/attention"; import { sessionFixture } from "./chat-fixtures"; beforeAll(async () => { await setLanguage("en"); }); function attention(overrides: Partial = {}): AttentionItem { return { requestId: "att-1", method: "select", title: "Run this command?", message: "Allow the pending tool call", options: [ { id: "allow-once", label: "Allow once" }, { id: "deny", label: "Deny" }, ], timeoutSec: 10, createdAt: Date.now(), receivedAt: Date.now(), ...overrides, }; } describe("attention dialog", () => { it("renders the server title/options and answers `select` with the option id", async () => { const item = attention(); const onRespond = vi.fn(); render( , ); expect(await screen.findByText("Run this command?")).toBeInTheDocument(); const option = screen.getByRole("button", { name: "Allow once" }); expect(option).toHaveAttribute("data-option-id", "allow-once"); fireEvent.click(option); // `pi.attention.resolve` expects `{value: