收紧序列帧预览恢复校验
Project CI / Repository checks (pull_request) Failing after 13s
Project CI / Backend tests (pull_request) Failing after 9s
Project CI / Frontend tests (pull_request) Successful in 2m56s
Project CI / Native shell tests (pull_request) Failing after 12m17s

taskId 缺失时不恢复关联预览视频

补充序列帧与预览任务标识缺失的恢复测试
This commit is contained in:
2026-08-15 17:02:52 +08:00
parent 90cfdfdf97
commit 4d1c9d9b1b
2 changed files with 45 additions and 2 deletions
@@ -1398,6 +1398,49 @@ describe('ImageCanvasEditorModel', () => {
});
});
it('does not hydrate a preview video when either task id is missing', () => {
const frames = [
{ imageSrc: '/generated/sequence/frame-1.png', width: 480, height: 480 },
{ imageSrc: '/generated/sequence/frame-2.png', width: 480, height: 480 },
];
for (const [animationTaskId, previewTaskId] of [
[undefined, 'animation-task-1'],
['animation-task-1', undefined],
[undefined, undefined],
] as const) {
const sequenceResource = {
imageSrc: frames[0]!.imageSrc,
assetKind: 'character-animation' as const,
imageSequenceFrames: frames,
imageSequenceDurationMs: 4_000,
...(animationTaskId ? { taskId: animationTaskId } : {}),
sourceResourceId: 'resource-preview-video',
};
const previewResource = {
imageSrc: '/generated/video/preview.mp4',
objectKey: 'generated/video/preview.mp4',
assetKind: 'video' as const,
...(previewTaskId ? { taskId: previewTaskId } : {}),
};
const resources: Parameters<typeof hydrateLayer>[1] = new Map();
resources.set('resource-sequence', sequenceResource);
resources.set('resource-preview-video', previewResource);
const hydrated = hydrateLayer(
{
layerId: 'layer-sequence',
resourceId: 'resource-sequence',
title: '角色动作',
sourceType: 'generated',
},
resources,
);
expect(hydrated?.previewVideoPath).toBeNull();
}
});
it('does not hydrate an older action reference as a generated preview video', () => {
const frames = [
{ imageSrc: '/generated/sequence/frame-1.png', width: 480, height: 480 },
@@ -1450,8 +1450,8 @@ export function hydrateLayer(
const animationTaskId = stringOrNull(resource?.taskId);
const previewTaskId = stringOrNull(previewResource.taskId);
if (
animationTaskId &&
previewTaskId &&
!animationTaskId ||
!previewTaskId ||
animationTaskId !== previewTaskId
) {
return undefined;