From 12239c66524baa81c62adbbd85013a5a91efe71a Mon Sep 17 00:00:00 2001 From: ypshim Date: Thu, 22 Oct 2026 11:42:56 +0900 Subject: [PATCH] =?UTF-8?q?feat(view):=20standing=20input=20and=20names=20?= =?UTF-8?q?for=20the=20P1=20project=20(=EC=9A=B4=EA=B3=A1=EA=B5=90P1=20?= =?UTF-8?q?=C2=B7=20=EC=9A=B4=EA=B3=A1=EA=B5=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The sample button and ?sample=1 fill the project name 운곡교P1 and the bridge name 운곡교. The sample is RAG/운곡교P1입력.xlsx. - Test: the app's copy stays byte-identical to the RAG file (skipped when the RAG folder is absent) and reads one pier, P1, T형, 말뚝기초, 10 bearings. Co-Authored-By: Claude Haiku 5.5 --- src/main.ts | 12 ++++++++++-- tests/sample-input.test.ts | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/sample-input.test.ts diff --git a/src/main.ts b/src/main.ts index d9b6a80..db631a3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1170,9 +1170,18 @@ $('file').addEventListener('change', async (ev) => { setStatus(`엑셀을 읽지 못했습니다: ${(err as Error).message}`); } }); +/** The project's standing input and names (RAG/운곡교P1입력.xlsx → 프로젝트 운곡교P1, 교량 운곡교). */ +const SAMPLE_PROJECT = { name: '운곡교P1', bridge: '운곡교' } as const; + +function fillSampleNames(): void { + $('project-name').value = SAMPLE_PROJECT.name; + $('bridge-name').value = SAMPLE_PROJECT.bridge; +} + $('pick-sample').addEventListener('click', async () => { try { loadBytes(await fetchSample(), '샘플 P1 (운곡교P1입력.xlsx)'); + fillSampleNames(); } catch (err) { setStatus(`샘플을 불러오지 못했습니다: ${(err as Error).message}`); } @@ -1251,8 +1260,7 @@ if (new URLSearchParams(window.location.search).get('sample') === '1') { fetchSample() .then((bytes) => { loadBytes(bytes, '샘플 P1'); - $('project-name').value = '운곡교 P1 샘플'; - $('bridge-name').value = '운곡교'; + fillSampleNames(); applyImport(); }) .catch((err: Error) => setStatus(`샘플을 불러오지 못했습니다: ${err.message}`)); diff --git a/tests/sample-input.test.ts b/tests/sample-input.test.ts new file mode 100644 index 0000000..6a9811a --- /dev/null +++ b/tests/sample-input.test.ts @@ -0,0 +1,25 @@ +import { describe, expect, it } from 'vitest'; +import { existsSync, readFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { parseWorkbook } from '../src/core/parseWorkbook'; +import { loadWorkbook } from './helpers'; + +// The standing input is RAG/운곡교P1입력.xlsx. The app serves a copy in public/samples; the two must stay identical. +const RAG_INPUT = fileURLToPath(new URL('../../../RAG/운곡교P1입력.xlsx', import.meta.url)); +const APP_COPY = fileURLToPath(new URL('../public/samples/운곡교P1입력.xlsx', import.meta.url)); + +describe('표준 입력 파일 (운곡교P1입력.xlsx)', () => { + it('the app sample is byte-identical to RAG/운곡교P1입력.xlsx', () => { + if (!existsSync(RAG_INPUT)) return; // RAG folder not present in this checkout + expect(readFileSync(APP_COPY).equals(readFileSync(RAG_INPUT))).toBe(true); + }); + + it('reads one pier, P1, T형, 말뚝기초, with 10 bearings', () => { + const { piers, issues } = parseWorkbook(loadWorkbook()); + expect(issues).toEqual([]); + expect(piers.map((p) => p.name)).toEqual(['P1']); + expect(piers[0].type).toBe('T형'); + expect(piers[0].foundationType).toBe('말뚝기초'); + expect(piers[0].bearings).toHaveLength(10); + }); +});