feat: render question exports as assets

This commit is contained in:
Codex
2026-06-29 17:07:24 +08:00
parent 1bcd887731
commit 506d7015a0
23 changed files with 2038 additions and 85 deletions

View File

@@ -2814,6 +2814,45 @@ async function testTenantContentAdmin() {
const exportedQuestionWithAnswer = paperExport.export?.questions?.find(item => item.id === question.item.id);
assert.equal(exportedQuestionWithAnswer?.answerText, '4', 'paper export should include answers when requested');
const pdfExportJob = await request('/api/tenant-content/exports/questions', {
userId: TENANT_ADMIN_USER_ID,
method: 'POST',
body: {
scopeType: 'collection',
scopeId: collection.item.id,
format: 'pdf',
exportType: 'paper',
includeAnswers: false,
includeExplanations: false,
options: {
title: '集成测试 PDF 异步导出',
watermarkText: '仅供内部测试',
publishToAssets: true,
assetVisibility: 'tenant',
},
},
});
assert.equal(pdfExportJob.job?.status, 'pending', 'PDF export should create a pending async export job');
assert.equal(pdfExportJob.export, null, 'PDF export should not return inline binary payload');
const docxExportJob = await request('/api/tenant-content/exports/questions', {
userId: TENANT_ADMIN_USER_ID,
method: 'POST',
body: {
scopeType: 'collection',
scopeId: collection.item.id,
format: 'docx',
exportType: 'paper',
includeAnswers: true,
includeExplanations: true,
options: {
title: '集成测试 Word 异步导出',
watermarkText: '仅供内部测试',
},
},
});
assert.equal(docxExportJob.job?.status, 'pending', 'DOCX export should create a pending async export job');
const partnerExportDenied = await request('/api/tenant-content/exports/questions', {
tenantId: PARTNER_TENANT_ID,
userId: PARTNER_TENANT_ADMIN_USER_ID,
@@ -2831,6 +2870,10 @@ async function testTenantContentAdmin() {
exportJobs.items?.some(item => item.id === exportNoAnswers.job.id && item.questionCount === 1),
'question export jobs should list completed export audit records',
);
const listedPdfJob = exportJobs.items?.find(item => item.id === pdfExportJob.job.id);
assert.equal(listedPdfJob?.status, 'pending', 'question export jobs should expose pending binary export jobs');
assert.equal(listedPdfJob?.assetId, null, 'pending binary export job should not have an asset yet');
assert.equal(listedPdfJob?.attemptCount, 0, 'pending binary export job should expose worker attempt count');
const invalidExportJobsScope = await request('/api/tenant-content/exports/jobs', {
userId: TENANT_ADMIN_USER_ID,
query: { scopeType: 'not_supported' },