f73f1026cf
补齐外部生成确认请求的 JSON Content-Type 本地屏蔽已确认终态任务避免轮询重复弹窗 单素材导出改为读取 Blob 后触发浏览器下载 序列帧导出按 frame objectKey 换签读取
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
import { requestJson } from '../apiClient';
|
|
import { acknowledgeExternalGenerationTasks } from './externalGenerationClient';
|
|
|
|
vi.mock('../apiClient', () => ({
|
|
BACKGROUND_AUTH_REQUEST_OPTIONS: {
|
|
skipAuth: false,
|
|
},
|
|
requestJson: vi.fn(),
|
|
}));
|
|
|
|
const requestJsonMock = vi.mocked(requestJson);
|
|
|
|
describe('externalGenerationClient', () => {
|
|
beforeEach(() => {
|
|
requestJsonMock.mockReset();
|
|
requestJsonMock.mockResolvedValue({ acknowledgedTasks: [] });
|
|
});
|
|
|
|
it('posts acknowledge requests as JSON', async () => {
|
|
await acknowledgeExternalGenerationTasks({ jobIds: ['job-1'] });
|
|
|
|
expect(requestJsonMock).toHaveBeenCalledWith(
|
|
'/api/runtime/external-generation/jobs/acknowledge',
|
|
expect.objectContaining({
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ jobIds: ['job-1'] }),
|
|
}),
|
|
'确认生成任务通知失败',
|
|
expect.any(Object),
|
|
);
|
|
});
|
|
});
|