From 7d7a1b61c080e2ed0b0d97ba2def03488ea61005 Mon Sep 17 00:00:00 2001 From: yiling Date: Sun, 19 Jul 2026 13:27:07 +0800 Subject: [PATCH] test(e2e): add E2E test for renderPdfPagesWorkflow --- packages/e2e/workflow/transcode.test.ts | 72 +++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/packages/e2e/workflow/transcode.test.ts b/packages/e2e/workflow/transcode.test.ts index 2aaf9f53..f8aaacd3 100644 --- a/packages/e2e/workflow/transcode.test.ts +++ b/packages/e2e/workflow/transcode.test.ts @@ -544,5 +544,77 @@ describe.each(['local', 'temporal'] as const)( expect(mediaInfo.sprite.key).toContain('sprite.webp') expect(mediaInfo.frames ?? mediaInfo.metadata?.totalFrames).toBeGreaterThan(0) }, 50000) + + it('should run renderPdfPages workflow for a PDF asset successfully', async () => { + // 1. Seed Database + const team = await prisma.team.create({ + data: { name: 'E2E PDF Pages Team' }, + }) + + const project = await prisma.project.create({ + data: { name: 'E2E PDF Pages Project', teamId: team.id }, + }) + + const storageKey = await prisma.storageKey.create({ + data: { + key: 'projects/e2e/test-pages.pdf', + }, + }) + + const asset = await prisma.asset.create({ + data: { + name: 'test-pages.pdf', + type: 'file', + status: 'uploaded', + mediaType: 'application/pdf', + projectId: project.id, + storageKeyId: storageKey.id, + }, + }) + + // 2. Seed S3 Storage from fixture test.pdf + const pdfPath = path.join(fixturesDir, 'test.pdf') + const pdfBuffer = fs.readFileSync(pdfPath) + await s3Service.putObject( + 'shumai-e2e-test-bucket-transcode', + 'projects/e2e/test-pages.pdf', + pdfBuffer, + pdfBuffer.length, + 'application/pdf', + ) + + // 3. Create Workflow Task + const task = await prisma.workflowTask.create({ + data: { + type: 'transcode_pdf_pages', + status: 'pending', + assetId: asset.id, + projectId: project.id, + teamId: team.id, + payload: { + projectId: project.id, + pdfPages: { + start: 1, + end: 2, + }, + }, + }, + }) + + // 4. Wait for workflow to complete + console.log( + `Submitted E2E PDF Pages Workflow Task. ID: ${task.id}. Awaiting completion...`, + ) + const completedTask = await workflowService.executeWait(task, 45000) + + // 5. Verification + expect(completedTask.status).toBe('completed') + + // Verify output contains rendered pages + const output = completedTask.output as unknown as { pages: { key: string; page: number }[] } + expect(output).toBeDefined() + expect(output.pages).toBeDefined() + expect(output.pages.length).toBeGreaterThan(0) + }, 50000) }, )