feat: add Seedance 2.0 models

This commit is contained in:
saturn
2026-04-02 19:16:00 +08:00
parent 9703714b69
commit 71ef6ff818
21 changed files with 811 additions and 38 deletions

View File

@@ -0,0 +1,53 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const getProviderConfigMock = vi.hoisted(() =>
vi.fn(async () => ({
id: 'ark',
apiKey: 'ark-key',
})),
)
const asyncTaskUtilsMock = vi.hoisted(() => ({
queryGeminiBatchStatus: vi.fn(),
queryGoogleVideoStatus: vi.fn(),
querySeedanceVideoStatus: vi.fn(),
}))
vi.mock('@/lib/api-config', () => ({
getProviderConfig: getProviderConfigMock,
getUserModels: vi.fn(),
}))
vi.mock('@/lib/async-submit', () => ({
queryFalStatus: vi.fn(),
}))
vi.mock('@/lib/async-task-utils', () => asyncTaskUtilsMock)
import { pollAsyncTask } from '@/lib/async-poll'
describe('async poll ark task', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('passes through actual video token usage from Ark polling', async () => {
asyncTaskUtilsMock.querySeedanceVideoStatus.mockResolvedValueOnce({
status: 'completed',
videoUrl: 'https://ark.example/result.mp4',
actualVideoTokens: 108000,
})
const result = await pollAsyncTask('ARK:VIDEO:task-1', 'user-1')
expect(getProviderConfigMock).toHaveBeenCalledWith('user-1', 'ark')
expect(asyncTaskUtilsMock.querySeedanceVideoStatus).toHaveBeenCalledWith('task-1', 'ark-key')
expect(result).toEqual({
status: 'completed',
resultUrl: 'https://ark.example/result.mp4',
videoUrl: 'https://ark.example/result.mp4',
actualVideoTokens: 108000,
error: undefined,
})
})
})