Skip to content

Commit bcef1cf

Browse files
os-trumpclaude
andauthored
test(rest): bind exceljs through the typed loadExcelJs() in the import-integration suite (#13498)
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. Claude-Session: https://claude.ai/code/session_01TvqBFLRzXdSPcbusDoED9k Co-authored-by: Claude <noreply@anthropic.com>
1 parent b95ff78 commit bcef1cf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/rest/src/import-integration.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { ObjectQL } from '@objectstack/objectql';
2727
import { SqlDriver } from '@objectstack/driver-sql';
2828
import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol';
2929
import { RestServer } from './rest-server';
30+
import { loadExcelJs } from './xlsx-module.js';
3031

3132
// ---------------------------------------------------------------------------
3233
// The real backend: better-sqlite3 `:memory:`, constructed the canonical way
@@ -322,7 +323,7 @@ describe('import route — real engine + protocol integration', () => {
322323
});
323324

324325
it('parses a native xlsx workbook server-side and coerces cells like csv', async () => {
325-
const ExcelJS: any = (await import('exceljs')).default ?? (await import('exceljs'));
326+
const ExcelJS = await loadExcelJs();
326327
const wb = new ExcelJS.Workbook();
327328
const ws = wb.addWorksheet('Sheet1');
328329
ws.addRow(['ID', '标题', '完成', '优先级', '分数', '截止', '负责人']);
@@ -344,7 +345,7 @@ describe('import route — real engine + protocol integration', () => {
344345
});
345346

346347
it('reads xlsxBase64 without an explicit format and honors the sheet selector', async () => {
347-
const ExcelJS: any = (await import('exceljs')).default ?? (await import('exceljs'));
348+
const ExcelJS = await loadExcelJs();
348349
const wb = new ExcelJS.Workbook();
349350
wb.addWorksheet('Empty'); // decoy first sheet
350351
const ws = wb.addWorksheet('Data');

0 commit comments

Comments
 (0)