feat: expand novel IP and production workflows
This commit is contained in:
@@ -29,10 +29,7 @@ function createFile(overrides: Partial<Express.Multer.File> = {}): Express.Multe
|
||||
}
|
||||
|
||||
describe('AssetsService', () => {
|
||||
let prisma: {
|
||||
project: { findUnique: ReturnType<typeof vi.fn> };
|
||||
asset: { create: ReturnType<typeof vi.fn>; findUnique: ReturnType<typeof vi.fn> };
|
||||
};
|
||||
let prisma: any;
|
||||
let storage: Pick<StorageService, 'storePrivateFile' | 'readPrivateFile'>;
|
||||
let projectsService: Pick<ProjectsService, 'assertProjectOwner'>;
|
||||
let service: AssetsService;
|
||||
@@ -45,6 +42,18 @@ describe('AssetsService', () => {
|
||||
asset: {
|
||||
create: vi.fn(),
|
||||
findUnique: vi.fn()
|
||||
},
|
||||
renderTask: {
|
||||
findMany: vi.fn().mockResolvedValue([])
|
||||
},
|
||||
providerLog: {
|
||||
findMany: vi.fn().mockResolvedValue([])
|
||||
},
|
||||
providerConfig: {
|
||||
findUnique: vi.fn().mockResolvedValue(null)
|
||||
},
|
||||
videoClip: {
|
||||
findMany: vi.fn().mockResolvedValue([])
|
||||
}
|
||||
};
|
||||
storage = {
|
||||
@@ -148,4 +157,100 @@ describe('AssetsService', () => {
|
||||
expect(result.filename).toBe('video-300.mp4');
|
||||
expect(result.buffer.toString()).toBe('video bytes');
|
||||
});
|
||||
|
||||
it('returns generation provider and model for direct asset detail', async () => {
|
||||
prisma.asset.findUnique.mockResolvedValue({
|
||||
id: 300n,
|
||||
user_id: 1n,
|
||||
project_id: 100n,
|
||||
asset_type: 'video',
|
||||
file_path: 'local://videos/final.mp4',
|
||||
file_url: null,
|
||||
mime_type: 'video/mp4',
|
||||
width: 1080,
|
||||
height: 1920,
|
||||
duration: 4,
|
||||
size: 11n,
|
||||
hash: 'video-hash',
|
||||
visibility: 'private',
|
||||
status: 'active',
|
||||
created_at: new Date('2026-05-31T00:00:00.000Z')
|
||||
});
|
||||
prisma.renderTask.findMany.mockResolvedValue([
|
||||
{
|
||||
id: 20n,
|
||||
project_id: 100n,
|
||||
episode_id: 10n,
|
||||
shot_id: 8n,
|
||||
task_type: 'live_action_video_clip_generate',
|
||||
provider_id: 13n,
|
||||
status: 'success',
|
||||
input_json: {},
|
||||
input_hash: null,
|
||||
idempotency_key: null,
|
||||
output_asset_id: 300n,
|
||||
provider_request_id: 'task-external-1',
|
||||
retry_count: 0,
|
||||
max_retry: 0,
|
||||
cost_estimate: null,
|
||||
cost_actual: { toString: () => '0.35' },
|
||||
error_code: null,
|
||||
error_message: null,
|
||||
created_at: new Date('2026-05-31T00:00:00.000Z'),
|
||||
started_at: null,
|
||||
finished_at: new Date('2026-05-31T00:00:00.000Z')
|
||||
}
|
||||
]);
|
||||
prisma.providerLog.findMany.mockResolvedValue([
|
||||
{
|
||||
id: 40n,
|
||||
provider_id: 13n,
|
||||
task_id: 20n,
|
||||
project_id: 100n,
|
||||
provider_type: 'VideoProvider',
|
||||
provider_code: 'kling-image-to-video',
|
||||
model_name: 'kling-v2-1',
|
||||
request_json: {},
|
||||
response_json: {},
|
||||
input_size: null,
|
||||
output_size: null,
|
||||
cost_estimate: null,
|
||||
cost_actual: null,
|
||||
status: 'success',
|
||||
error_code: null,
|
||||
error_message: null,
|
||||
started_at: null,
|
||||
finished_at: null,
|
||||
created_at: new Date('2026-05-31T00:00:00.000Z')
|
||||
}
|
||||
]);
|
||||
prisma.providerConfig.findUnique.mockResolvedValue({
|
||||
id: 13n,
|
||||
provider_type: 'VideoProvider',
|
||||
provider_code: 'kling-image-to-video',
|
||||
display_name: '可灵图生视频',
|
||||
mode: 'real',
|
||||
model_name: 'kling-v2-1',
|
||||
config_json: {},
|
||||
fallback_provider_id: null,
|
||||
is_enabled: true,
|
||||
priority: 10,
|
||||
rate_limit_json: {},
|
||||
cost_rule_json: {},
|
||||
created_at: new Date('2026-05-31T00:00:00.000Z'),
|
||||
updated_at: new Date('2026-05-31T00:00:00.000Z')
|
||||
});
|
||||
|
||||
const result = await service.getAssetForUser(user, '300');
|
||||
|
||||
expect(result.generation).toEqual(
|
||||
expect.objectContaining({
|
||||
provider_name: '可灵图生视频',
|
||||
provider_code: 'kling-image-to-video',
|
||||
model_name: 'kling-v2-1',
|
||||
task_id: '20',
|
||||
provider_request_id: 'task-external-1'
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user