Rename the web client's History tab and its supporting code to Protocol so the feature reads as the MCP "Protocol" view. - Tab renders as "Protocol"; INSPECTOR_TAB_IDS, InspectorView tab constants/MonitorTab, TAB_UI_REGISTRY key, and navigation.ts tab id all updated to Protocol. - Rename components + folders: HistoryScreen -> ProtocolScreen, HistoryListPanel -> ProtocolListPanel, HistoryEntry -> ProtocolEntry, HistoryControls -> ProtocolControls, historyUtils -> protocolUtils (plus their tests and stories, and exported types). - Rename App/InspectorView plumbing: historyUi, pinnedHistoryIds, on*History* handlers/props, replayHistoryRequest, isReplayableHistoryMethod, sort/compact scopes, etc. -> Protocol names. - Export filenames use the "protocol" slug (buildExportFilename + ExportKind). Preserved (per issue #1623 decisions): - The in-panel section discriminator keeps its "pinned" | "history" values, and the sub-sections stay labeled Pinned / History. - window.history and core message-log/replay concepts are untouched. npm run ci passes (format, lint, build, unit tests, >=90 per-file coverage gate, smoke, Storybook). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
122 lines
4.4 KiB
TypeScript
122 lines
4.4 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import userEvent from "@testing-library/user-event";
|
|
import type { MessageMethod } from "@inspector/core/mcp/types.js";
|
|
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
|
|
import { ProtocolControls } from "./ProtocolControls";
|
|
|
|
const baseProps = {
|
|
searchText: "",
|
|
availableMethods: ["tools/list", "prompts/list"] as MessageMethod[],
|
|
visibleDirections: { client: true, server: true },
|
|
onSearchChange: vi.fn(),
|
|
onMethodFilterChange: vi.fn(),
|
|
onToggleDirection: vi.fn(),
|
|
onToggleAllDirections: vi.fn(),
|
|
};
|
|
|
|
describe("ProtocolControls", () => {
|
|
it("renders the title and search input", () => {
|
|
renderWithMantine(<ProtocolControls {...baseProps} />);
|
|
expect(screen.getByText("Protocol")).toBeInTheDocument();
|
|
expect(screen.getByPlaceholderText("Search...")).toBeInTheDocument();
|
|
});
|
|
|
|
it("invokes onSearchChange when typing in the search input", async () => {
|
|
const user = userEvent.setup();
|
|
const onSearchChange = vi.fn();
|
|
renderWithMantine(
|
|
<ProtocolControls {...baseProps} onSearchChange={onSearchChange} />,
|
|
);
|
|
await user.type(screen.getByPlaceholderText("Search..."), "a");
|
|
expect(onSearchChange).toHaveBeenCalledWith("a");
|
|
});
|
|
|
|
it("clears the search input when the Clear button is clicked", async () => {
|
|
const user = userEvent.setup();
|
|
const onSearchChange = vi.fn();
|
|
renderWithMantine(
|
|
<ProtocolControls
|
|
{...baseProps}
|
|
searchText="abc"
|
|
onSearchChange={onSearchChange}
|
|
/>,
|
|
);
|
|
await user.click(screen.getByRole("button", { name: "Clear" }));
|
|
expect(onSearchChange).toHaveBeenCalledWith("");
|
|
});
|
|
|
|
it("keeps the search Clear button out of the keyboard tab order", () => {
|
|
renderWithMantine(<ProtocolControls {...baseProps} searchText="abc" />);
|
|
expect(screen.getByRole("button", { name: "Clear" })).toHaveAttribute(
|
|
"tabindex",
|
|
"-1",
|
|
);
|
|
});
|
|
|
|
it("renders the method filter placeholder", () => {
|
|
renderWithMantine(<ProtocolControls {...baseProps} />);
|
|
expect(screen.getByPlaceholderText("All methods")).toBeInTheDocument();
|
|
});
|
|
|
|
it("displays the active method filter value", () => {
|
|
renderWithMantine(
|
|
<ProtocolControls {...baseProps} methodFilter="tools/list" />,
|
|
);
|
|
const inputs = screen.getAllByDisplayValue("tools/list");
|
|
expect(inputs.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("invokes onMethodFilterChange with undefined when cleared", async () => {
|
|
const user = userEvent.setup();
|
|
const onMethodFilterChange = vi.fn();
|
|
const { container } = renderWithMantine(
|
|
<ProtocolControls
|
|
{...baseProps}
|
|
methodFilter="tools/list"
|
|
onMethodFilterChange={onMethodFilterChange}
|
|
/>,
|
|
);
|
|
const clearButton = container.querySelector(
|
|
"button.mantine-InputClearButton-root",
|
|
) as HTMLButtonElement | null;
|
|
expect(clearButton).not.toBeNull();
|
|
await user.click(clearButton!);
|
|
expect(onMethodFilterChange).toHaveBeenCalledWith(undefined);
|
|
});
|
|
|
|
it("renders the Filter by Message Direction section with both directions", () => {
|
|
renderWithMantine(<ProtocolControls {...baseProps} />);
|
|
expect(screen.getByText("Filter by Message Direction")).toBeInTheDocument();
|
|
expect(
|
|
screen.getByRole("button", { name: "client → server" }),
|
|
).toBeInTheDocument();
|
|
expect(
|
|
screen.getByRole("button", { name: "client ← server" }),
|
|
).toBeInTheDocument();
|
|
});
|
|
|
|
it("toggles a direction's visibility when its button is clicked", async () => {
|
|
const user = userEvent.setup();
|
|
const onToggleDirection = vi.fn();
|
|
renderWithMantine(
|
|
<ProtocolControls {...baseProps} onToggleDirection={onToggleDirection} />,
|
|
);
|
|
// Currently visible → clicking turns it off.
|
|
await user.click(screen.getByRole("button", { name: "client ← server" }));
|
|
expect(onToggleDirection).toHaveBeenCalledWith("server", false);
|
|
});
|
|
|
|
it("invokes onToggleAllDirections from the Deselect/Select All control", async () => {
|
|
const user = userEvent.setup();
|
|
const onToggleAllDirections = vi.fn();
|
|
renderWithMantine(
|
|
<ProtocolControls
|
|
{...baseProps}
|
|
onToggleAllDirections={onToggleAllDirections}
|
|
/>,
|
|
);
|
|
// Both visible → the control reads "Deselect All".
|
|
await user.click(screen.getByRole("button", { name: "Deselect All" }));
|
|
expect(onToggleAllDirections).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|