feat(view): 도면 불러오기 — read the bearing drawing values from an xlsx or csv sheet on ②
The sheet needs the header names No, EL.X, h1 and h2 (case, spaces, dots and units in parentheses are ignored). Rows are checked: No must be a unique positive integer, EL.X must be in metres (30–100), h1 and h2 must be positive mm up to 1000. Any error stops the import with the first messages; a valid sheet fills this pier's drawing values and regenerates the pier. The parser is pure and tested. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e4e141c801
commit
6f32bd96c4
3 files changed
+124
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseDrawingRows } from '../src/core/drawing-import';
|
||||
|
||||
const header = ['No', '열', 'EL.X (m)', 'h1 (mm)', 'h2 (mm)'];
|
||||
|
||||
describe('도면 불러오기 (승인 2026-10-23)', () => {
|
||||
it('reads No, EL.X, h1, h2 from a sheet with a header and ignores other columns', () => {
|
||||
const rows = [['도면 받침', '', '', '', ''], header, [1, '전열', 43.625, 164, 50], [2, '전열', 43.697, 164, 50]];
|
||||
const r = parseDrawingRows(rows);
|
||||
expect(r.errors).toEqual([]);
|
||||
expect(r.rows).toEqual([
|
||||
{ no: 1, elx: 43.625, h1: 164, h2: 50 },
|
||||
{ no: 2, elx: 43.697, h1: 164, h2: 50 },
|
||||
]);
|
||||
});
|
||||
|
||||
it('accepts the header spelled as "EL. X" and in a different order', () => {
|
||||
const rows = [['h2', 'No', 'h1', 'EL. X'], [50, 1, 164, 43.625]];
|
||||
const r = parseDrawingRows(rows);
|
||||
expect(r.errors).toEqual([]);
|
||||
expect(r.rows[0]).toEqual({ no: 1, elx: 43.625, h1: 164, h2: 50 });
|
||||
});
|
||||
|
||||
it('reports a missing header, a duplicate No, and an EL.X given in mm', () => {
|
||||
expect(parseDrawingRows([['x', 'y']]).errors[0]).toContain('머리글');
|
||||
const dup = parseDrawingRows([header, [1, '', 43.6, 164, 50], [1, '', 43.7, 164, 50]]);
|
||||
expect(dup.errors.some((e) => e.includes('중복'))).toBe(true);
|
||||
const mm = parseDrawingRows([header, [1, '', 43625, 164, 50]]);
|
||||
expect(mm.errors.some((e) => e.includes('m 단위'))).toBe(true);
|
||||
expect(mm.rows).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user