Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions client/src/components/__tests__/AuthDebugger.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,25 @@ jest.mock("@/lib/auth", () => ({
response_types: ["code"],
client_name: "MCP Inspector",
},
clientInformation: jest.fn(),
saveClientInformation: jest.fn(),
clientInformation: jest.fn().mockImplementation(async () => {
const serverUrl = "https://example.com/mcp";
const preregisteredKey = `[${serverUrl}] ${SESSION_KEYS.PREREGISTERED_CLIENT_INFORMATION}`;
const preregisteredData = sessionStorage.getItem(preregisteredKey);
if (preregisteredData) {
return JSON.parse(preregisteredData);
}
const dynamicKey = `[${serverUrl}] ${SESSION_KEYS.CLIENT_INFORMATION}`;
const dynamicData = sessionStorage.getItem(dynamicKey);
if (dynamicData) {
return JSON.parse(dynamicData);
}
return undefined;
}),
saveClientInformation: jest.fn().mockImplementation((clientInfo) => {
const serverUrl = "https://example.com/mcp";
const key = `[${serverUrl}] ${SESSION_KEYS.CLIENT_INFORMATION}`;
sessionStorage.setItem(key, JSON.stringify(clientInfo));
}),
Comment on lines +80 to +98
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the OAuth scope discovery commits, 2 AuthDebugger tests were failing because the test mocks were too simple. The clientInformation mock always returned undefined instead of checking sessionStorage for preregistered client info, and the saveClientInformation mock did nothing instead of actually saving data. The OAuth flow expected these mocks to behave like the real OAuth client provider by checking sessionStorage for existing client information and saving dynamic registration results when needed. Once we fixed the mocks to simulate this real behavior, the tests started passing again.

saveTokens: jest.fn(),
redirectToAuthorization: jest.fn(),
saveCodeVerifier: jest.fn(),
Expand Down
Loading