Skip to content

Commit 2f8ab16

Browse files
committed
prettier
1 parent ecefbdd commit 2f8ab16

File tree

3 files changed

+70
-45
lines changed

3 files changed

+70
-45
lines changed

client/src/components/AuthDebugger.tsx

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const AuthDebugger = ({ sseUrl, onBack }: AuthDebuggerProps) => {
8282

8383
// Helper function to update specific state properties
8484
const updateState = (updates: Partial<AuthDebuggerState>) => {
85-
setState(prev => ({ ...prev, ...updates }));
85+
setState((prev) => ({ ...prev, ...updates }));
8686
};
8787

8888
// Load OAuth tokens on component mount
@@ -248,7 +248,9 @@ const AuthDebugger = ({ sseUrl, onBack }: AuthDebuggerProps) => {
248248
}
249249
} else if (state.oauthStep === "authorization_code") {
250250
if (!state.authorizationCode || state.authorizationCode.trim() === "") {
251-
updateState({ validationError: "You need to provide an authorization code" });
251+
updateState({
252+
validationError: "You need to provide an authorization code",
253+
});
252254
return;
253255
}
254256
updateState({ validationError: null, oauthStep: "token_request" });
@@ -270,7 +272,9 @@ const AuthDebugger = ({ sseUrl, onBack }: AuthDebuggerProps) => {
270272
}
271273
} catch (error) {
272274
console.error("OAuth flow error:", error);
273-
updateState({ latestError: error instanceof Error ? error : new Error(String(error)) });
275+
updateState({
276+
latestError: error instanceof Error ? error : new Error(String(error)),
277+
});
274278
} finally {
275279
updateState({ isInitiatingAuth: false });
276280
}
@@ -459,7 +463,9 @@ const AuthDebugger = ({ sseUrl, onBack }: AuthDebuggerProps) => {
459463
/>
460464
</div>
461465
{state.validationError && (
462-
<p className="text-xs text-red-600 mt-1">{state.validationError}</p>
466+
<p className="text-xs text-red-600 mt-1">
467+
{state.validationError}
468+
</p>
463469
)}
464470
<p className="text-xs text-muted-foreground mt-1">
465471
Once you've completed authorization in the link, paste the code
@@ -515,7 +521,9 @@ const AuthDebugger = ({ sseUrl, onBack }: AuthDebuggerProps) => {
515521

516522
<div className="space-y-3">
517523
{steps.map((step, idx) => {
518-
const currentStepIdx = steps.findIndex((s) => s.key === state.oauthStep);
524+
const currentStepIdx = steps.findIndex(
525+
(s) => s.key === state.oauthStep,
526+
);
519527
const isComplete = idx <= currentStepIdx;
520528
const isCurrent = step.key === state.oauthStep;
521529

@@ -555,23 +563,28 @@ const AuthDebugger = ({ sseUrl, onBack }: AuthDebuggerProps) => {
555563

556564
<div className="flex gap-3 mt-4">
557565
{state.oauthStep !== "complete" && (
558-
<Button onClick={proceedToNextStep} disabled={state.isInitiatingAuth}>
566+
<Button
567+
onClick={proceedToNextStep}
568+
disabled={state.isInitiatingAuth}
569+
>
559570
{state.isInitiatingAuth
560571
? "Processing..."
561-
: state.oauthStep === "authorization_redirect" && state.authorizationUrl
572+
: state.oauthStep === "authorization_redirect" &&
573+
state.authorizationUrl
562574
? "Open Authorization URL"
563575
: "Continue"}
564576
</Button>
565577
)}
566578

567-
{state.oauthStep === "authorization_redirect" && state.authorizationUrl && (
568-
<Button
569-
variant="outline"
570-
onClick={() => window.open(state.authorizationUrl!, "_blank")}
571-
>
572-
Open in New Tab
573-
</Button>
574-
)}
579+
{state.oauthStep === "authorization_redirect" &&
580+
state.authorizationUrl && (
581+
<Button
582+
variant="outline"
583+
onClick={() => window.open(state.authorizationUrl!, "_blank")}
584+
>
585+
Open in New Tab
586+
</Button>
587+
)}
575588
</div>
576589
</div>
577590
);
@@ -657,4 +670,4 @@ const AuthDebugger = ({ sseUrl, onBack }: AuthDebuggerProps) => {
657670
);
658671
};
659672

660-
export default AuthDebugger;
673+
export default AuthDebugger;

client/src/components/OAuthDebugCallback.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ const OAuthDebugCallback = ({ onConnect }: OAuthCallbackProps) => {
5555
// Finally, trigger navigation back to auth debugger
5656
toast({
5757
title: "Success",
58-
description: "Authorization code received. Please return to the Auth Debugger.",
58+
description:
59+
"Authorization code received. Please return to the Auth Debugger.",
5960
variant: "default",
6061
});
61-
62+
6263
// Call onConnect to navigate back to the auth debugger
6364
onConnect(serverUrl);
6465
};
@@ -85,7 +86,7 @@ const OAuthDebugCallback = ({ onConnect }: OAuthCallbackProps) => {
8586
Please copy this authorization code and return to the Auth Debugger:
8687
</p>
8788
<code className="block p-2 bg-muted rounded-sm overflow-x-auto text-xs">
88-
{callbackParams.successful && 'code' in callbackParams
89+
{callbackParams.successful && "code" in callbackParams
8990
? callbackParams.code
9091
: `No code found: ${callbackParams.error}, ${callbackParams.error_description}`}
9192
</code>

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

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { render, screen, fireEvent, waitFor, act } from "@testing-library/react";
1+
import {
2+
render,
3+
screen,
4+
fireEvent,
5+
waitFor,
6+
act,
7+
} from "@testing-library/react";
28
import "@testing-library/jest-dom";
39
import { describe, it, beforeEach, jest } from "@jest/globals";
410
import AuthDebugger from "../AuthDebugger";
@@ -10,7 +16,7 @@ const mockOAuthTokens = {
1016
token_type: "Bearer",
1117
expires_in: 3600,
1218
refresh_token: "test_refresh_token",
13-
scope: "test_scope"
19+
scope: "test_scope",
1420
};
1521

1622
const mockOAuthMetadata = {
@@ -59,14 +65,14 @@ const sessionStorageMock = {
5965
removeItem: jest.fn(),
6066
clear: jest.fn(),
6167
};
62-
Object.defineProperty(window, 'sessionStorage', {
68+
Object.defineProperty(window, "sessionStorage", {
6369
value: sessionStorageMock,
6470
});
6571

6672
// Mock the location.origin
67-
Object.defineProperty(window, 'location', {
73+
Object.defineProperty(window, "location", {
6874
value: {
69-
origin: 'http://localhost:3000',
75+
origin: "http://localhost:3000",
7076
},
7177
});
7278

@@ -79,11 +85,13 @@ describe("AuthDebugger", () => {
7985
beforeEach(() => {
8086
jest.clearAllMocks();
8187
sessionStorageMock.getItem.mockReturnValue(null);
82-
(mockDiscoverOAuthMetadata as jest.Mock).mockResolvedValue(mockOAuthMetadata);
88+
(mockDiscoverOAuthMetadata as jest.Mock).mockResolvedValue(
89+
mockOAuthMetadata,
90+
);
8391
(mockRegisterClient as jest.Mock).mockResolvedValue(mockOAuthClientInfo);
8492
(mockStartAuthorization as jest.Mock).mockResolvedValue({
8593
authorizationUrl: new URL("https://oauth.example.com/authorize"),
86-
codeVerifier: "test_verifier"
94+
codeVerifier: "test_verifier",
8795
});
8896
(mockExchangeAuthorization as jest.Mock).mockResolvedValue(mockOAuthTokens);
8997
});
@@ -92,7 +100,7 @@ describe("AuthDebugger", () => {
92100
return render(
93101
<TooltipProvider>
94102
<AuthDebugger {...defaultProps} {...props} />
95-
</TooltipProvider>
103+
</TooltipProvider>,
96104
);
97105
};
98106

@@ -119,26 +127,27 @@ describe("AuthDebugger", () => {
119127
await act(async () => {
120128
renderAuthDebugger();
121129
});
122-
130+
123131
await act(async () => {
124132
fireEvent.click(screen.getByText("Guided OAuth Flow"));
125133
});
126-
134+
127135
expect(screen.getByText("OAuth Flow Progress")).toBeInTheDocument();
128136
});
129137

130138
it("should show error when OAuth flow is started without sseUrl", async () => {
131139
await act(async () => {
132140
renderAuthDebugger({ sseUrl: "" });
133141
});
134-
142+
135143
await act(async () => {
136144
fireEvent.click(screen.getByText("Guided OAuth Flow"));
137145
});
138-
146+
139147
expect(mockToast).toHaveBeenCalledWith({
140148
title: "Error",
141-
description: "Please enter a server URL in the sidebar before authenticating",
149+
description:
150+
"Please enter a server URL in the sidebar before authenticating",
142151
variant: "destructive",
143152
});
144153
});
@@ -153,11 +162,11 @@ describe("AuthDebugger", () => {
153162
}
154163
return null;
155164
});
156-
165+
157166
await act(async () => {
158167
renderAuthDebugger();
159168
});
160-
169+
161170
await waitFor(() => {
162171
expect(screen.getByText(/Access Token:/)).toBeInTheDocument();
163172
});
@@ -167,22 +176,22 @@ describe("AuthDebugger", () => {
167176
// Mock console to avoid cluttering test output
168177
const originalError = console.error;
169178
console.error = jest.fn();
170-
179+
171180
// Mock getItem to return invalid JSON for tokens
172181
sessionStorageMock.getItem.mockImplementation((key) => {
173182
if (key === "[https://example.com] mcp_tokens") {
174183
return "invalid json";
175184
}
176185
return null;
177186
});
178-
187+
179188
await act(async () => {
180189
renderAuthDebugger();
181190
});
182-
191+
183192
// Component should still render despite the error
184193
expect(screen.getByText("Authentication Settings")).toBeInTheDocument();
185-
194+
186195
// Restore console.error
187196
console.error = originalError;
188197
});
@@ -197,7 +206,7 @@ describe("AuthDebugger", () => {
197206
}
198207
return null;
199208
});
200-
209+
201210
await act(async () => {
202211
renderAuthDebugger();
203212
});
@@ -221,21 +230,23 @@ describe("AuthDebugger", () => {
221230
await act(async () => {
222231
renderAuthDebugger();
223232
});
224-
233+
225234
// Start guided flow
226235
await act(async () => {
227236
fireEvent.click(screen.getByText("Guided OAuth Flow"));
228237
});
229-
238+
230239
// Verify metadata discovery step
231240
expect(screen.getByText("Metadata Discovery")).toBeInTheDocument();
232-
241+
233242
// Click Continue - this should trigger metadata discovery
234243
await act(async () => {
235244
fireEvent.click(screen.getByText("Continue"));
236245
});
237-
238-
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith("https://example.com");
246+
247+
expect(mockDiscoverOAuthMetadata).toHaveBeenCalledWith(
248+
"https://example.com",
249+
);
239250
});
240251
});
241-
});
252+
});

0 commit comments

Comments
 (0)