fix: restore server XLS roster conversion

This commit is contained in:
inman committed 2026-08-31 16:04:26 +08:00
1 parent 4ba2d43710
commit d7a821da16
8 files changed
+218 -63

No files matched your search

@@ -48,6 +48,14 @@ test('roster attachment source contract gates claims and scrubs normalized plain
assert.doesNotMatch(source, /raw_(?:file|workbook)_ciphertext|content_base64[^\n]*task_input_attachments/);
});
test('a newly delivered message revalidates previously rejected attachment bytes', async () => {
const source = await readFile(new URL('../src/task-service.ts', import.meta.url), 'utf8');
assert.match(source, /const shouldValidateAttachment = !prior\.rowCount[\s\S]*?=== 'rejected'/u);
assert.match(source, /previousAttachment && text\(previousAttachment\.status\) !== 'rejected'/u);
assert.match(source, /SET source = \$2[\s\S]*?status = 'normalized'[\s\S]*?WHERE id = \$1 AND status = 'rejected'/u);
assert.match(source, /i\.idempotency_key = \$2[\s\S]*?status: 'duplicate' as const/u);
});
test('manual API accepts exactly one bounded inline roster attachment', async () => {
const source = await readFile(new URL('../src/server.ts', import.meta.url), 'utf8');
assert.match(source, /attachments: z\.array\(encodedInputAttachmentSchema\)\.max\(1\)/);
@@ -339,6 +339,21 @@ test('format, MIME, conversion output and technical limits are validated before
}, { convertLegacyXls: async () => Buffer.from('not xlsx') }),
'roster_workbook_conversion_failed'
);
const conversionFailure = await expectRosterError(
() => normalizePassengerRosterWorkbook({
content: legacy,
fileName: 'synthetic.xls',
contentType: 'application/vnd.ms-excel'
}, {
convertLegacyXls: async () => {
throw new PassengerRosterWorkbookError('roster_workbook_conversion_failed', {
conversionErrorCode: 'conversion_output_missing'
});
}
}),
'roster_workbook_conversion_failed'
);
assert.equal(conversionFailure.conversionErrorCode, 'conversion_output_missing');
const macroLegacy = Buffer.concat([legacy, Buffer.from('_VBA_PROJECT_CUR', 'utf16le')]);
await expectRosterError(