inspector/clients/web/src/components/groups/protocolUtils.test.ts
cliffhall ace4250d31 refactor(web): rename "History" tab/feature to "Protocol" (#1623)
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
2026-07-09 19:04:54 -04:00

60 lines
1.6 KiB
TypeScript

import { describe, it, expect } from "vitest";
import type { MessageEntry } from "@inspector/core/mcp/types.js";
import { extractMethod } from "./protocolUtils";
describe("extractMethod", () => {
it("returns the method name for a request entry", () => {
const entry: MessageEntry = {
id: "1",
timestamp: new Date(),
direction: "request",
message: {
jsonrpc: "2.0",
id: 1,
method: "tools/list",
},
};
expect(extractMethod(entry)).toBe("tools/list");
});
it("returns the method name for a notification entry", () => {
const entry: MessageEntry = {
id: "2",
timestamp: new Date(),
direction: "notification",
message: {
jsonrpc: "2.0",
method: "notifications/initialized",
},
};
expect(extractMethod(entry)).toBe("notifications/initialized");
});
it("returns 'response' for a result-response entry without a method", () => {
const entry: MessageEntry = {
id: "3",
timestamp: new Date(),
direction: "response",
message: {
jsonrpc: "2.0",
id: 1,
result: { tools: [] },
},
};
expect(extractMethod(entry)).toBe("response");
});
it("returns 'response' for an error-response entry without a method", () => {
const entry: MessageEntry = {
id: "4",
timestamp: new Date(),
direction: "response",
message: {
jsonrpc: "2.0",
id: 1,
error: { code: -32600, message: "Invalid Request" },
},
};
expect(extractMethod(entry)).toBe("response");
});
});