Skip to content

Commit e74f80d

Browse files
committed
fix tests
1 parent 11bc043 commit e74f80d

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

client/src/components/AuthDebugger.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,22 @@ const AuthDebugger = ({
6464
useEffect(() => {
6565
if (serverUrl && !authState.oauthTokens) {
6666
const checkTokens = async () => {
67-
const provider = new DebugInspectorOAuthClientProvider(serverUrl);
68-
const existingTokens = await provider.tokens();
69-
if (existingTokens) {
70-
updateAuthState({
71-
oauthTokens: existingTokens,
72-
oauthStep: "complete",
73-
});
67+
try {
68+
const provider = new DebugInspectorOAuthClientProvider(serverUrl);
69+
const existingTokens = await provider.tokens();
70+
if (existingTokens) {
71+
updateAuthState({
72+
oauthTokens: existingTokens,
73+
oauthStep: "complete",
74+
});
75+
}
76+
} catch (error) {
77+
console.error("Failed to load existing OAuth tokens:", error);
7478
}
7579
};
7680
checkTokens();
7781
}
78-
}, [serverUrl]); // Only run when serverUrl changes
82+
}, [serverUrl, updateAuthState, authState.oauthTokens]);
7983

8084
const startOAuthFlow = useCallback(() => {
8185
if (!serverUrl) {

client/src/components/__tests__/AuthDebugger.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe("AuthDebugger", () => {
202202

203203
// Should first discover and save OAuth metadata
204204
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
205-
"https://example.com",
205+
new URL("https://example.com"),
206206
);
207207

208208
// Check that updateAuthState was called with the right info message
@@ -314,6 +314,11 @@ describe("AuthDebugger", () => {
314314
});
315315

316316
expect(updateAuthState).toHaveBeenCalledWith({
317+
authServerUrl: null,
318+
authorizationUrl: null,
319+
isInitiatingAuth: false,
320+
resourceMetadata: null,
321+
resourceMetadataError: null,
317322
oauthTokens: null,
318323
oauthStep: "metadata_discovery",
319324
latestError: null,
@@ -355,7 +360,7 @@ describe("AuthDebugger", () => {
355360
});
356361

357362
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
358-
"https://example.com",
363+
new URL("https://example.com"),
359364
);
360365
});
361366

0 commit comments

Comments
 (0)