收口 Makelore 客户端变更
This commit is contained in:
@@ -187,6 +187,31 @@ describe('auth host api routes', () => {
|
||||
expect(JSON.stringify(response.json())).not.toContain('app:app');
|
||||
});
|
||||
|
||||
it('replaces an upstream HTML gateway error with a concise browser-login message', async () => {
|
||||
const fetchMock = vi.fn().mockResolvedValueOnce(
|
||||
new Response(
|
||||
'<html><head><title>502 Bad Gateway</title></head><body>upstream details</body></html>',
|
||||
{ status: 502, headers: { 'content-type': 'text/html' } },
|
||||
),
|
||||
);
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
const response = createResponse();
|
||||
|
||||
await handleAuthRoutes(
|
||||
createRequest('POST'),
|
||||
response.res,
|
||||
new URL('http://127.0.0.1:13210/api/auth/browser/start'),
|
||||
{} as never,
|
||||
);
|
||||
|
||||
expect(response.statusCode).toBe(502);
|
||||
expect(response.json()).toEqual({
|
||||
success: false,
|
||||
error: '登录服务暂时不可用,请稍后重试。',
|
||||
});
|
||||
expect(JSON.stringify(response.json())).not.toContain('<html>');
|
||||
});
|
||||
|
||||
it('opens Works Square browser authorization and returns the approved desktop token', async () => {
|
||||
const fetchMock = vi.fn()
|
||||
.mockResolvedValueOnce(
|
||||
|
||||
Reference in New Issue
Block a user