mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 21:04:59 +00:00
fix(transcode): fix missing thumbnail and sprite generation in transcoding workflow
This commit is contained in:
@@ -122,7 +122,14 @@ describe('Transcode Workflow', () => {
|
|||||||
status: AssetStatus.processing,
|
status: AssetStatus.processing,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(mockActivities.updateAssetMediaActivity).toHaveBeenCalled()
|
expect(mockActivities.updateAssetMediaActivity).toHaveBeenCalledWith({
|
||||||
|
assetId: 'asset-1',
|
||||||
|
mediaInfo: expect.objectContaining({
|
||||||
|
thumbnail: expect.objectContaining({
|
||||||
|
key: 't.webp',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
expect(mockActivities.updateAssetStatusActivity).toHaveBeenCalledWith({
|
expect(mockActivities.updateAssetStatusActivity).toHaveBeenCalledWith({
|
||||||
assetId: 'asset-1',
|
assetId: 'asset-1',
|
||||||
status: AssetStatus.processed,
|
status: AssetStatus.processed,
|
||||||
@@ -134,6 +141,74 @@ describe('Transcode Workflow', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should process image transcode and thumbnail successfully', async () => {
|
||||||
|
const task: WorkflowTask = {
|
||||||
|
id: 'task-image',
|
||||||
|
assetId: 'asset-image',
|
||||||
|
type: WorkflowTaskType.transcode,
|
||||||
|
status: WorkflowTaskStatus.pending,
|
||||||
|
output: null,
|
||||||
|
payload: {
|
||||||
|
projectId: 'proj-1',
|
||||||
|
transcode: {
|
||||||
|
imageStrategy: 'single',
|
||||||
|
thumbnail: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
heartbeat: null,
|
||||||
|
teamId: 'team-1',
|
||||||
|
projectId: 'proj-1',
|
||||||
|
uid: 'task-uid',
|
||||||
|
model: null,
|
||||||
|
inputTokens: 0,
|
||||||
|
outputTokens: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
mockActivities.getAssetActivity.mockResolvedValue({
|
||||||
|
id: 'asset-image',
|
||||||
|
storageKey: { key: 'image.jpg' },
|
||||||
|
mediaType: 'image/jpeg',
|
||||||
|
})
|
||||||
|
|
||||||
|
mockActivities.getMediaInfoActivity.mockResolvedValue({
|
||||||
|
mimeType: 'image/jpeg',
|
||||||
|
metadata: { originalWidth: 1000, originalHeight: 1000 },
|
||||||
|
videoTranscodes: [],
|
||||||
|
imageTranscodes: [],
|
||||||
|
})
|
||||||
|
|
||||||
|
mockActivities.transcodeImageActivity.mockResolvedValue({
|
||||||
|
key: 't.webp',
|
||||||
|
width: 480,
|
||||||
|
height: 480,
|
||||||
|
format: 'webp',
|
||||||
|
})
|
||||||
|
|
||||||
|
await transcodeMedia(task)
|
||||||
|
|
||||||
|
expect(mockActivities.updateAssetStatusActivity).toHaveBeenCalledWith({
|
||||||
|
assetId: 'asset-image',
|
||||||
|
status: AssetStatus.processing,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(mockActivities.updateAssetMediaActivity).toHaveBeenCalledWith({
|
||||||
|
assetId: 'asset-image',
|
||||||
|
mediaInfo: expect.objectContaining({
|
||||||
|
thumbnail: expect.objectContaining({
|
||||||
|
key: 't.webp',
|
||||||
|
width: 480,
|
||||||
|
height: 480,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
expect(mockActivities.updateAssetStatusActivity).toHaveBeenCalledWith({
|
||||||
|
assetId: 'asset-image',
|
||||||
|
status: AssetStatus.processed,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('should handle failures and update task status with error', async () => {
|
it('should handle failures and update task status with error', async () => {
|
||||||
const task: WorkflowTask = {
|
const task: WorkflowTask = {
|
||||||
id: 'task-fail',
|
id: 'task-fail',
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export async function transcodeMedia(task: WorkflowTask): Promise<void> {
|
|||||||
tmpDir = download.tmpDir
|
tmpDir = download.tmpDir
|
||||||
|
|
||||||
// 5. Get Media Info
|
// 5. Get Media Info
|
||||||
const spec = task.payload as PrismaJson.TaskSpec
|
const spec = task.payload?.transcode || {}
|
||||||
const mediaInfo = await executeActivity(workerQueue, getMediaInfoActivity, {
|
const mediaInfo = await executeActivity(workerQueue, getMediaInfoActivity, {
|
||||||
filePath,
|
filePath,
|
||||||
assetId: asset.id,
|
assetId: asset.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user