forked from wangziqi/gongxue-base
feat: add import job detail polling
This commit is contained in:
@@ -3133,6 +3133,22 @@ async function testTenantContentAssetsAndImports() {
|
||||
});
|
||||
assert.equal(questionPostCheckStatus.item?.importPostCheck?.status, 'passed', 'post-check result should be readable from job summary');
|
||||
|
||||
const questionImportDetail = await request('/api/tenant-content/imports/detail', {
|
||||
userId: TENANT_ADMIN_USER_ID,
|
||||
query: { jobId: validPreview.job.id },
|
||||
});
|
||||
assert.equal(questionImportDetail.item?.id, validPreview.job.id, 'import detail should return selected job');
|
||||
assert.equal(questionImportDetail.importPostCheck?.status, 'passed', 'import detail should expose post-check summary');
|
||||
assert.equal(questionImportDetail.itemStatusSummary?.inserted, 2, 'import detail should expose item status summary');
|
||||
|
||||
const crossTenantImportDetailDenied = await request('/api/tenant-content/imports/detail', {
|
||||
tenantId: PARTNER_TENANT_ID,
|
||||
userId: PARTNER_TENANT_ADMIN_USER_ID,
|
||||
query: { jobId: validPreview.job.id },
|
||||
expectStatus: 404,
|
||||
});
|
||||
assert.equal(crossTenantImportDetailDenied.code, 'IMPORT_JOB_NOT_FOUND', 'import detail should be tenant isolated');
|
||||
|
||||
const jobs = await request('/api/tenant-content/imports', {
|
||||
userId: TENANT_ADMIN_USER_ID,
|
||||
query: { importType: 'questions', limit: 10 },
|
||||
@@ -3280,6 +3296,15 @@ async function testTenantContentAssetsAndImports() {
|
||||
assert.equal(asyncQuestionQueued.item?.status, 'pending', 'async import should queue the job');
|
||||
assert.equal(asyncQuestionQueued.item?.executionMode, 'async', 'async import response should expose execution mode');
|
||||
|
||||
const queuedImportDetail = await request('/api/tenant-content/imports/detail', {
|
||||
userId: TENANT_ADMIN_USER_ID,
|
||||
query: { jobId: asyncQuestionPreview.job.id },
|
||||
});
|
||||
assert.equal(queuedImportDetail.item?.status, 'pending', 'import detail should expose queued status');
|
||||
assert.equal(queuedImportDetail.worker?.executionMode, 'async', 'import detail should expose async worker metadata');
|
||||
assert.equal(queuedImportDetail.worker?.attemptCount, 0, 'queued import detail should expose attempt count before worker starts');
|
||||
assert.equal(queuedImportDetail.itemStatusSummary?.valid, 1, 'queued import detail should expose preview item statuses');
|
||||
|
||||
const queuedAgain = await request('/api/tenant-content/imports/questions', {
|
||||
userId: TENANT_ADMIN_USER_ID,
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user