diff --git a/apps/web/src/lib/excel.test.ts b/apps/web/src/lib/excel.test.ts index d855684..a3831ad 100644 --- a/apps/web/src/lib/excel.test.ts +++ b/apps/web/src/lib/excel.test.ts @@ -1,14 +1,7 @@ import { describe, expect, it } from "vitest"; -import { - MAX_BROWSER_SPREADSHEET_BYTES, - assertSpreadsheetFile, - parseSpreadsheet, -} from "./excel.js"; +import { MAX_BROWSER_SPREADSHEET_BYTES, assertSpreadsheetFile, parseSpreadsheet } from "./excel.js"; -async function createWorkbookFile( - rows: unknown[][], - fileName = "spreadsheet.xlsx", -): Promise { +async function createWorkbookFile(rows: unknown[][], fileName = "spreadsheet.xlsx"): Promise { const ExcelJS = await import("exceljs"); const workbook = new ExcelJS.Workbook(); const worksheet = workbook.addWorksheet("Sheet1"); @@ -25,11 +18,9 @@ async function createWorkbookFile( describe("excel import helpers", () => { it("parses csv files with quoted values and skips blank rows", async () => { - const file = new File( - ['name,role\n"Alice, A.",Engineer\n\nBob,Producer\n'], - "people.csv", - { type: "text/csv" }, - ); + const file = new File(['name,role\n"Alice, A.",Engineer\n\nBob,Producer\n'], "people.csv", { + type: "text/csv", + }); await expect(parseSpreadsheet(file)).resolves.toEqual([ { name: "Alice, A.", role: "Engineer" }, @@ -38,6 +29,7 @@ describe("excel import helpers", () => { }); it("parses xlsx files and normalizes date cells to ISO strings", async () => { + // ExcelJS dynamic import + workbook writeBuffer is slow on constrained CI runners. const file = await createWorkbookFile([ ["name", "startDate", "active"], ["Alice", new Date("2026-03-30T09:15:00.000Z"), true], @@ -50,7 +42,7 @@ describe("excel import helpers", () => { active: "true", }, ]); - }); + }, 30000); it("rejects duplicate headers in xlsx imports", async () => { const file = await createWorkbookFile([ @@ -59,16 +51,14 @@ describe("excel import helpers", () => { ]); await expect(parseSpreadsheet(file)).rejects.toThrow('duplicate header "name"'); - }); + }, 30000); it("rejects legacy .xls uploads before parsing", () => { const file = new File(["legacy"], "legacy.xls", { type: "application/vnd.ms-excel", }); - expect(() => assertSpreadsheetFile(file)).toThrow( - "Legacy .xls files are not supported.", - ); + expect(() => assertSpreadsheetFile(file)).toThrow("Legacy .xls files are not supported."); }); it("rejects oversized spreadsheet uploads before parsing", () => {