fmt(js): npm run fix on merge (#66348)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -9,20 +9,29 @@ describe('completeMcpDesktopOAuth', () => {
|
||||
const status = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
flow_id: 'flow-1', server_name: 'reports', status: 'authorization_required',
|
||||
authorization_url: 'https://idp.example/authorize', error: null
|
||||
flow_id: 'flow-1',
|
||||
server_name: 'reports',
|
||||
status: 'authorization_required',
|
||||
authorization_url: 'https://idp.example/authorize',
|
||||
error: null
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
flow_id: 'flow-1', server_name: 'reports', status: 'approved',
|
||||
authorization_url: 'https://idp.example/authorize', error: null,
|
||||
flow_id: 'flow-1',
|
||||
server_name: 'reports',
|
||||
status: 'approved',
|
||||
authorization_url: 'https://idp.example/authorize',
|
||||
error: null,
|
||||
tools: [{ name: 'list_reports', description: 'List reports' }]
|
||||
})
|
||||
|
||||
const result = await completeMcpDesktopOAuth({
|
||||
serverName: 'reports',
|
||||
start: vi.fn().mockResolvedValue({
|
||||
flow_id: 'flow-1', server_name: 'reports', status: 'authorization_required',
|
||||
authorization_url: 'https://idp.example/authorize', error: null
|
||||
flow_id: 'flow-1',
|
||||
server_name: 'reports',
|
||||
status: 'authorization_required',
|
||||
authorization_url: 'https://idp.example/authorize',
|
||||
error: null
|
||||
}),
|
||||
status,
|
||||
openExternal,
|
||||
@@ -34,19 +43,23 @@ describe('completeMcpDesktopOAuth', () => {
|
||||
})
|
||||
|
||||
it('retries a transient status failure', async () => {
|
||||
const status = vi
|
||||
.fn()
|
||||
.mockRejectedValueOnce(new Error('temporary network failure'))
|
||||
.mockResolvedValueOnce({
|
||||
flow_id: 'flow-2', server_name: 'reports', status: 'approved',
|
||||
authorization_url: 'https://idp.example/authorize', error: null, tools: []
|
||||
})
|
||||
const status = vi.fn().mockRejectedValueOnce(new Error('temporary network failure')).mockResolvedValueOnce({
|
||||
flow_id: 'flow-2',
|
||||
server_name: 'reports',
|
||||
status: 'approved',
|
||||
authorization_url: 'https://idp.example/authorize',
|
||||
error: null,
|
||||
tools: []
|
||||
})
|
||||
|
||||
const result = await completeMcpDesktopOAuth({
|
||||
serverName: 'reports',
|
||||
start: vi.fn().mockResolvedValue({
|
||||
flow_id: 'flow-2', server_name: 'reports', status: 'authorization_required',
|
||||
authorization_url: 'https://idp.example/authorize', error: null
|
||||
flow_id: 'flow-2',
|
||||
server_name: 'reports',
|
||||
status: 'authorization_required',
|
||||
authorization_url: 'https://idp.example/authorize',
|
||||
error: null
|
||||
}),
|
||||
status,
|
||||
openExternal: vi.fn().mockResolvedValue(undefined),
|
||||
@@ -56,4 +69,4 @@ describe('completeMcpDesktopOAuth', () => {
|
||||
expect(result.status).toBe('approved')
|
||||
expect(status).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -16,8 +16,7 @@ interface CompleteOptions {
|
||||
maxPollFailures?: number
|
||||
}
|
||||
|
||||
const defaultSleep = (milliseconds: number) =>
|
||||
new Promise<void>(resolve => window.setTimeout(resolve, milliseconds))
|
||||
const defaultSleep = (milliseconds: number) => new Promise<void>(resolve => window.setTimeout(resolve, milliseconds))
|
||||
|
||||
export async function completeMcpDesktopOAuth({
|
||||
serverName,
|
||||
@@ -69,4 +68,4 @@ export async function completeMcpDesktopOAuth({
|
||||
|
||||
await sleep(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user