SnowLuma v2.4.2 source snapshot
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
This commit is contained in:
commit
fa9c73363d
1367 files changed
+355735
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createApiClient } from '../src/lib/api/client';
|
||||
|
||||
const tokenStore = {
|
||||
load: () => 'trace-token',
|
||||
save: () => undefined,
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
describe('API client full TRACE export', () => {
|
||||
it('downloads the exact authenticated server text and filename', async () => {
|
||||
const body = 'header\nTRACE recvHex=000102aabbcc\n';
|
||||
const fetchMock = vi.fn().mockResolvedValue(
|
||||
new Response(body, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'text/plain; charset=utf-8',
|
||||
'Content-Disposition': 'attachment; filename="server-trace.log"',
|
||||
},
|
||||
}),
|
||||
);
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
const client = createApiClient({ tokenStore });
|
||||
|
||||
await expect(client.logs.exportTrace()).resolves.toEqual({
|
||||
text: body,
|
||||
filename: 'server-trace.log',
|
||||
});
|
||||
expect(fetchMock).toHaveBeenCalledExactlyOnceWith(
|
||||
'/api/logs/export/trace',
|
||||
expect.objectContaining({
|
||||
headers: new Headers({ 'X-SnowLuma-Token': 'trace-token' }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects a failed export instead of downloading an error body', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn().mockResolvedValue(
|
||||
new Response(JSON.stringify({ message: 'export unavailable' }), {
|
||||
status: 500,
|
||||
statusText: 'Internal Server Error',
|
||||
}),
|
||||
),
|
||||
);
|
||||
const client = createApiClient({ tokenStore });
|
||||
|
||||
await expect(client.logs.exportTrace()).rejects.toMatchObject({
|
||||
status: 500,
|
||||
message: 'export unavailable',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user