feat(web): 支持文档页真实提交请求

This commit is contained in:
2026-07-22 00:24:36 +08:00
parent 6b675c406e
commit b04a7d9d3d
7 changed files with 348 additions and 172 deletions
+43
View File
@@ -16,6 +16,7 @@ import {
retireIdentityPairingSecurityEventConflict,
validateIdentityRevision,
} from './api';
import { applyTaskSubmissionMode, runTask } from './lib/run-task';
describe('local login transport', () => {
afterEach(() => {
@@ -316,4 +317,46 @@ describe('API documentation runner transports', () => {
expect(url).toContain('/api/v1/tasks/task-123');
expect(init.method).toBe('GET');
});
it('removes every simulation switch from a real submission while preserving edited parameters', async () => {
const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({ id: 'chatcmpl-real' }), {
status: 200,
headers: { 'Content-Type': 'application/json' },
}));
vi.stubGlobal('fetch', fetchMock);
await runTask(
'sk-test',
{ kind: 'chat.completions', model: 'gpt-fallback', prompt: 'fallback' },
{
submissionMode: 'production',
requestBody: {
model: 'gpt-real',
messages: [{ role: 'user', content: 'edited body' }],
temperature: 0.25,
runMode: 'simulation',
run_mode: 'simulation',
simulation: true,
testMode: true,
test_mode: true,
},
},
);
const [, init] = fetchMock.mock.calls[0] as [string, RequestInit];
expect(JSON.parse(String(init.body))).toEqual({
model: 'gpt-real',
messages: [{ role: 'user', content: 'edited body' }],
temperature: 0.25,
});
});
it('uses canonical simulation parameters without removing a model-specific mode field', () => {
expect(applyTaskSubmissionMode({ model: 'video-model', mode: 'pro', testMode: false }, 'simulation')).toEqual({
model: 'video-model',
mode: 'pro',
runMode: 'simulation',
simulation: true,
});
});
});