test(order): compare Excel error row as numeric cell

This commit is contained in:
2026-10-02 21:49:48 +08:00
parent 8c1905418e
commit afb02a0a1b
2 changed files with 8 additions and 2 deletions
@@ -253,7 +253,8 @@ function importHarness(fault = '') {
template.set('xl/worksheets/sheet2.xml', `<worksheet><sheetData><row r="1">${cells(['国内仓|CN', '目的仓|US', '海运渠道|SEA'], 1)}</row></sheetData></worksheet>`)
bytes = r.orderZipWrite(template)
} else if (request.path.includes('/error-reports/')) {
bytes = r.orderZipWrite(new Map([['xl/worksheets/sheet1.xml', `<worksheet><sheetData><row r="1">${cells(['Excel行号', '错误代码', '错误说明'], 1)}</row><row r="2">${cells(['3', 'A0422', 'cargo required'], 2)}</row></sheetData></worksheet>`]]))
const physicalRow = fault === 'wrong-error-row' ? '4.0' : '3.0'
bytes = r.orderZipWrite(new Map([['xl/worksheets/sheet1.xml', `<worksheet><sheetData><row r="1">${cells(['Excel行号', '错误代码', '错误说明'], 1)}</row><row r="2">${cells(['3', 'A0422', 'cargo required'], 2).replace(/<c r="A2"[\s\S]*?<\/c>/, `<c r="A2" t="n"><v>${physicalRow}</v></c>`)}</row></sheetData></worksheet>`]]))
} else if (request.method === 'POST') {
const file = request.body.get('file'), body = Buffer.from(await file.arrayBuffer())
if (name.startsWith('PARTIAL')) {
@@ -295,3 +296,8 @@ for (const fault of ['leaked-first-row', 'changed-existing-row']) test(`F04 reje
const { r } = importHarness(fault)
await assert.rejects(() => r.orderExcelImportModule(), /unchanged/)
})
test('F04 still rejects a numeric error row pointing to the successful row', async () => {
const { r } = importHarness('wrong-error-row')
await assert.rejects(() => r.orderExcelImportModule(), /actual Excel error row/)
})
+1 -1
View File
@@ -2408,7 +2408,7 @@ async function orderExcelImportModule() {
assertEqual(status, 200, 'error workbook download')
const rows = orderSheetRows(orderZipRead(bytes))
assertEqual(rows.length, 2, 'header and exactly one failed row')
assertEqual(rows[1].cells[0].text, '3', 'actual Excel error row')
assertEqual(Number(rows[1].cells[0].text), 3, 'actual Excel error row')
assertEqual(rows[1].cells[1].text, 'A0422', 'error report code')
assertEqual(rows[1].cells[2].text, errorData.result.items[0].errorMessage, 'error report exact reason')
}, ({ bytes }) => ({ sizeBytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') }))