From b98388a4280c12cfece33a77eb5344b5d32501df Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 30 Aug 2026 14:22:00 +0000 Subject: [PATCH] test(rest): bind exceljs through the typed loadExcelJs() in the import-integration suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two fixture builders in `import-integration.test.ts` bound exceljs as `const ExcelJS: any = (await import('exceljs')).default ?? (await import('exceljs'))`, so every `new ExcelJS.Workbook()`, `addWorksheet`, `addRow` and `wb.xlsx.writeBuffer()` downstream of them sat outside the type system. The two tests that exercise the server-side .xlsx import path were themselves unchecked against the dependency they drive: a renamed method or a changed arity in exceljs would not have been a compile error here. Both now call `loadExcelJs()` from `src/xlsx-module.ts`, the package's single typed, lazily-loaded exceljs binding. No second accessor is introduced and no runtime behaviour changes — only what tsc is told. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01TvqBFLRzXdSPcbusDoED9k --- packages/rest/src/import-integration.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/rest/src/import-integration.test.ts b/packages/rest/src/import-integration.test.ts index 927511e911..08a02f015e 100644 --- a/packages/rest/src/import-integration.test.ts +++ b/packages/rest/src/import-integration.test.ts @@ -27,6 +27,7 @@ import { ObjectQL } from '@objectstack/objectql'; import { SqlDriver } from '@objectstack/driver-sql'; import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol'; import { RestServer } from './rest-server'; +import { loadExcelJs } from './xlsx-module.js'; // --------------------------------------------------------------------------- // The real backend: better-sqlite3 `:memory:`, constructed the canonical way @@ -322,7 +323,7 @@ describe('import route — real engine + protocol integration', () => { }); it('parses a native xlsx workbook server-side and coerces cells like csv', async () => { - const ExcelJS: any = (await import('exceljs')).default ?? (await import('exceljs')); + const ExcelJS = await loadExcelJs(); const wb = new ExcelJS.Workbook(); const ws = wb.addWorksheet('Sheet1'); ws.addRow(['ID', '标题', '完成', '优先级', '分数', '截止', '负责人']); @@ -344,7 +345,7 @@ describe('import route — real engine + protocol integration', () => { }); it('reads xlsxBase64 without an explicit format and honors the sheet selector', async () => { - const ExcelJS: any = (await import('exceljs')).default ?? (await import('exceljs')); + const ExcelJS = await loadExcelJs(); const wb = new ExcelJS.Workbook(); wb.addWorksheet('Empty'); // decoy first sheet const ws = wb.addWorksheet('Data');