diff --git a/public/samples/운곡교P1입력.xlsx b/public/samples/운곡교P1입력.xlsx new file mode 100644 index 0000000..79adfa0 Binary files /dev/null and b/public/samples/운곡교P1입력.xlsx differ diff --git a/src/main.ts b/src/main.ts index bd2624d..68e61cf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -492,7 +492,7 @@ function openImport(): void { } async function fetchSample(): Promise { - const res = await fetch(new URL('samples/P1.xlsx', document.baseURI)); + const res = await fetch(new URL('samples/운곡교P1입력.xlsx', document.baseURI)); if (!res.ok) throw new Error(`샘플 응답 ${res.status}`); return new Uint8Array(await res.arrayBuffer()); } @@ -535,7 +535,7 @@ $('file').addEventListener('change', async (ev) => { }); $('pick-sample').addEventListener('click', async () => { try { - loadBytes(await fetchSample(), '샘플 P1 (Pier ui_xxx.xlsx)'); + loadBytes(await fetchSample(), '샘플 P1 (운곡교P1입력.xlsx)'); } catch (err) { setStatus(`샘플을 불러오지 못했습니다: ${(err as Error).message}`); } diff --git a/tests/helpers.ts b/tests/helpers.ts index a13a1db..0f81f16 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -4,14 +4,21 @@ import * as XLSX from 'xlsx'; import { parseWorkbook } from '../src/core/parseWorkbook'; import type { PierInput } from '../src/core/types'; -const P1_PATH = fileURLToPath(new URL('../public/samples/P1.xlsx', import.meta.url)); +/** Spec workbook (RAG/Pier ui_xxx.xlsx, sheet intent.PR, all tables on one sheet). Used by single-sheet tests. */ +const SPEC_PATH = fileURLToPath(new URL('../public/samples/P1.xlsx', import.meta.url)); +/** User input (RAG/운곡교P1입력.xlsx, three sheets 교각 · IP · 받침). This is the P1 input used by the app and tests. */ +const INPUT_PATH = fileURLToPath(new URL('../public/samples/운곡교P1입력.xlsx', import.meta.url)); -export function loadWorkbook(path: string = P1_PATH): XLSX.WorkBook { +export function loadWorkbook(path: string = SPEC_PATH): XLSX.WorkBook { return XLSX.read(readFileSync(path), { type: 'buffer' }); } +export function loadInputWorkbook(): XLSX.WorkBook { + return loadWorkbook(INPUT_PATH); +} + export function loadP1(): PierInput { - const { piers, issues } = parseWorkbook(loadWorkbook()); + const { piers, issues } = parseWorkbook(loadInputWorkbook()); if (issues.length) throw new Error(`P1 parse issues: ${JSON.stringify(issues)}`); const p1 = piers.find((p) => p.name === 'P1'); if (!p1) throw new Error('P1 not found'); diff --git a/tests/parse.test.ts b/tests/parse.test.ts index adb3e35..d8c5794 100644 --- a/tests/parse.test.ts +++ b/tests/parse.test.ts @@ -1,7 +1,7 @@ import * as XLSX from 'xlsx'; import { describe, expect, it } from 'vitest'; import { parseWorkbook } from '../src/core/parseWorkbook'; -import { loadP1, loadWorkbook } from './helpers'; +import { loadInputWorkbook, loadP1, loadWorkbook } from './helpers'; describe('parseWorkbook (P1 sheet intent.PR)', () => { it('finds exactly one pier P1 with the input values of the sheet', () => { @@ -92,3 +92,13 @@ describe('three-sheet input (교각 · IP · 받침 on separate sheets, joined b ]); }); }); + +describe('user input file (RAG/운곡교P1입력.xlsx)', () => { + it('has the three sheets 교각 · IP · 받침 and parses to one pier, P1, with no issues', () => { + const wb = loadInputWorkbook(); + expect(wb.SheetNames).toEqual(['교각', 'IP', '받침']); + const { piers, issues } = parseWorkbook(wb); + expect(issues).toEqual([]); + expect(piers.map((p) => [p.name, p.sheet])).toEqual([['P1', '교각']]); + }); +});