Skip to content

Commit 78eaa17

Browse files
Rename History file to HistoryAndNotifications
Rename History.tsx to HistoryAndNotifications.tsx for consistency with component name and update imports. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 7eaa948 commit 78eaa17

File tree

3 files changed

+50
-40
lines changed

3 files changed

+50
-40
lines changed

client/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { z } from "zod";
5252
import "./App.css";
5353
import AuthDebugger from "./components/AuthDebugger";
5454
import ConsoleTab from "./components/ConsoleTab";
55-
import HistoryAndNotifications from "./components/History";
55+
import HistoryAndNotifications from "./components/HistoryAndNotifications";
5656
import PingTab from "./components/PingTab";
5757
import PromptsTab, { Prompt } from "./components/PromptsTab";
5858
import ResourcesTab from "./components/ResourcesTab";

client/src/components/__tests__/History.test.tsx renamed to client/src/components/__tests__/HistoryAndNotifications.test.tsx

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { render, screen, fireEvent } from "@testing-library/react";
2-
import "@testing-library/jest-dom";
32
import { describe, it, expect, jest } from "@jest/globals";
4-
import HistoryAndNotifications from "../History";
3+
import HistoryAndNotifications from "../HistoryAndNotifications";
54
import { ServerNotification } from "@modelcontextprotocol/sdk/types.js";
65

76
// Mock JsonView component
@@ -25,12 +24,19 @@ describe("HistoryAndNotifications", () => {
2524

2625
const mockNotifications: ServerNotification[] = [
2726
{
28-
method: "notification/test1",
29-
params: { message: "First notification" },
27+
method: "notifications/message",
28+
params: {
29+
level: "info" as const,
30+
message: "First notification",
31+
},
3032
},
3133
{
32-
method: "notification/test2",
33-
params: { message: "Second notification" },
34+
method: "notifications/progress",
35+
params: {
36+
progressToken: "test-token",
37+
progress: 50,
38+
message: "Second notification",
39+
},
3440
},
3541
];
3642

@@ -42,8 +48,8 @@ describe("HistoryAndNotifications", () => {
4248
/>,
4349
);
4450

45-
expect(screen.getByText("History")).toBeInTheDocument();
46-
expect(screen.getByText("Server Notifications")).toBeInTheDocument();
51+
expect(screen.getByText("History")).toBeTruthy();
52+
expect(screen.getByText("Server Notifications")).toBeTruthy();
4753
});
4854

4955
it("displays request history items with correct numbering", () => {
@@ -55,8 +61,8 @@ describe("HistoryAndNotifications", () => {
5561
);
5662

5763
// Items should be numbered in reverse order (newest first)
58-
expect(screen.getByText("2. test/method2")).toBeInTheDocument();
59-
expect(screen.getByText("1. test/method1")).toBeInTheDocument();
64+
expect(screen.getByText("2. test/method2")).toBeTruthy();
65+
expect(screen.getByText("1. test/method1")).toBeTruthy();
6066
});
6167

6268
it("displays server notifications with correct numbering", () => {
@@ -68,8 +74,8 @@ describe("HistoryAndNotifications", () => {
6874
);
6975

7076
// Items should be numbered in reverse order (newest first)
71-
expect(screen.getByText("2. notification/test2")).toBeInTheDocument();
72-
expect(screen.getByText("1. notification/test1")).toBeInTheDocument();
77+
expect(screen.getByText("2. notifications/progress")).toBeTruthy();
78+
expect(screen.getByText("1. notifications/message")).toBeTruthy();
7379
});
7480

7581
it("expands and collapses request items when clicked", () => {
@@ -84,16 +90,16 @@ describe("HistoryAndNotifications", () => {
8490

8591
// Initially collapsed - should show ▶ arrows (there are multiple)
8692
expect(screen.getAllByText("▶")).toHaveLength(2);
87-
expect(screen.queryByText("Request:")).not.toBeInTheDocument();
93+
expect(screen.queryByText("Request:")).toBeNull();
8894

8995
// Click to expand
9096
fireEvent.click(firstRequestHeader);
9197

9298
// Should now be expanded - one ▼ and one ▶
93-
expect(screen.getByText("▼")).toBeInTheDocument();
99+
expect(screen.getByText("▼")).toBeTruthy();
94100
expect(screen.getAllByText("▶")).toHaveLength(1);
95-
expect(screen.getByText("Request:")).toBeInTheDocument();
96-
expect(screen.getByText("Response:")).toBeInTheDocument();
101+
expect(screen.getByText("Request:")).toBeTruthy();
102+
expect(screen.getByText("Response:")).toBeTruthy();
97103
});
98104

99105
it("expands and collapses notification items when clicked", () => {
@@ -104,19 +110,21 @@ describe("HistoryAndNotifications", () => {
104110
/>,
105111
);
106112

107-
const firstNotificationHeader = screen.getByText("2. notification/test2");
113+
const firstNotificationHeader = screen.getByText(
114+
"2. notifications/progress",
115+
);
108116

109117
// Initially collapsed
110118
expect(screen.getAllByText("▶")).toHaveLength(2);
111-
expect(screen.queryByText("Details:")).not.toBeInTheDocument();
119+
expect(screen.queryByText("Details:")).toBeNull();
112120

113121
// Click to expand
114122
fireEvent.click(firstNotificationHeader);
115123

116124
// Should now be expanded
117-
expect(screen.getByText("▼")).toBeInTheDocument();
125+
expect(screen.getByText("▼")).toBeTruthy();
118126
expect(screen.getAllByText("▶")).toHaveLength(1);
119-
expect(screen.getByText("Details:")).toBeInTheDocument();
127+
expect(screen.getByText("Details:")).toBeTruthy();
120128
});
121129

122130
it("maintains expanded state when new notifications are added", () => {
@@ -127,18 +135,20 @@ describe("HistoryAndNotifications", () => {
127135
/>,
128136
);
129137

130-
// Find and expand the older notification (should be "1. notification/test1")
131-
const olderNotificationHeader = screen.getByText("1. notification/test1");
138+
// Find and expand the older notification (should be "1. notifications/message")
139+
const olderNotificationHeader = screen.getByText(
140+
"1. notifications/message",
141+
);
132142
fireEvent.click(olderNotificationHeader);
133143

134144
// Verify it's expanded
135-
expect(screen.getByText("Details:")).toBeInTheDocument();
145+
expect(screen.getByText("Details:")).toBeTruthy();
136146

137147
// Add a new notification at the beginning (simulating real behavior)
138148
const newNotifications: ServerNotification[] = [
139149
{
140-
method: "notification/new",
141-
params: { message: "New notification" },
150+
method: "notifications/resources/updated",
151+
params: { uri: "file://test.txt" },
142152
},
143153
...mockNotifications,
144154
];
@@ -152,13 +162,13 @@ describe("HistoryAndNotifications", () => {
152162
);
153163

154164
// The original notification should still be expanded
155-
// It's now numbered as "2. notification/test1" due to the new item
156-
expect(screen.getByText("3. notification/test2")).toBeInTheDocument();
157-
expect(screen.getByText("2. notification/test1")).toBeInTheDocument();
158-
expect(screen.getByText("1. notification/new")).toBeInTheDocument();
165+
// It's now numbered as "2. notifications/message" due to the new item
166+
expect(screen.getByText("3. notifications/progress")).toBeTruthy();
167+
expect(screen.getByText("2. notifications/message")).toBeTruthy();
168+
expect(screen.getByText("1. notifications/resources/updated")).toBeTruthy();
159169

160170
// The originally expanded notification should still show its details
161-
expect(screen.getByText("Details:")).toBeInTheDocument();
171+
expect(screen.getByText("Details:")).toBeTruthy();
162172
});
163173

164174
it("maintains expanded state when new requests are added", () => {
@@ -174,8 +184,8 @@ describe("HistoryAndNotifications", () => {
174184
fireEvent.click(olderRequestHeader);
175185

176186
// Verify it's expanded
177-
expect(screen.getByText("Request:")).toBeInTheDocument();
178-
expect(screen.getByText("Response:")).toBeInTheDocument();
187+
expect(screen.getByText("Request:")).toBeTruthy();
188+
expect(screen.getByText("Response:")).toBeTruthy();
179189

180190
// Add a new request at the beginning
181191
const newRequestHistory = [
@@ -196,21 +206,21 @@ describe("HistoryAndNotifications", () => {
196206

197207
// The original request should still be expanded
198208
// It's now numbered as "2. test/method1" due to the new item
199-
expect(screen.getByText("3. test/method2")).toBeInTheDocument();
200-
expect(screen.getByText("2. test/method1")).toBeInTheDocument();
201-
expect(screen.getByText("1. test/new_method")).toBeInTheDocument();
209+
expect(screen.getByText("3. test/method2")).toBeTruthy();
210+
expect(screen.getByText("2. test/method1")).toBeTruthy();
211+
expect(screen.getByText("1. test/new_method")).toBeTruthy();
202212

203213
// The originally expanded request should still show its details
204-
expect(screen.getByText("Request:")).toBeInTheDocument();
205-
expect(screen.getByText("Response:")).toBeInTheDocument();
214+
expect(screen.getByText("Request:")).toBeTruthy();
215+
expect(screen.getByText("Response:")).toBeTruthy();
206216
});
207217

208218
it("displays empty state messages when no data is available", () => {
209219
render(
210220
<HistoryAndNotifications requestHistory={[]} serverNotifications={[]} />,
211221
);
212222

213-
expect(screen.getByText("No history yet")).toBeInTheDocument();
214-
expect(screen.getByText("No notifications yet")).toBeInTheDocument();
223+
expect(screen.getByText("No history yet")).toBeTruthy();
224+
expect(screen.getByText("No notifications yet")).toBeTruthy();
215225
});
216226
});

0 commit comments

Comments
 (0)