Files
Aislo/resources/tester/cad/dxf-clip.test.ts
T
eomsangdonandClaude Sonnet 5.5 aaadbd295e test(506-2): 시험 정비 — 낡은 두 시험 글 맞춤 · vitest 실행 설정 · live 시험 켜는 표식
- test_b06_draft_pipe_replay · test_269_panel_form 단언 글을 현재 코드에 맞춤
- vitest.tmp.config.ts: include resources/tester/cad · xstate 별칭 · node 꼴 시험 제외 · dxf-clip 픽스처 경로 import.meta.url
- test_472_6_route_save · design_save: live 는 AISLO_LIVE_DB=1 일 때만

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 12:34:38 +09:00

52 lines
2.3 KiB
TypeScript

/**
* 오토캐드 도형 붙이기 순수 부분(`integration/dxf-clip.ts`) 검증.
* 실행: node --experimental-strip-types resources/tester/cad/dxf-clip.test.ts
* (타입만 가져오는 모듈이라 vitest · jsdom 없이 바로 돎)
*/
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import {
isDxfText,
prepareClip,
} from '../../../B07_DesignDetail/openwebcad/src/integration/dxf-clip.ts';
const sample = readFileSync(new URL('../fixtures/b07_webclip_sample.dxf', import.meta.url), 'utf-8');
assert.equal(isDxfText(sample), true, '견본 DXF 알아봄');
assert.equal(isDxfText(sample.replace(/\n/g, '\r\n')), true, 'CRLF DXF 도 알아봄');
assert.equal(isDxfText('0\nSECTION\n'), true, '앞 공백 없는 DXF');
assert.equal(isDxfText('가나다'), false, '보통 글은 아님');
assert.equal(isDxfText('0\nSECTIONS'), false, 'SECTION 뒤 글자 붙은 것은 아님');
const existing = [{ id: 'L-old', name: '구조물', isVisible: true, isLocked: false }];
const line = (id: string, layer: string) => ({
id,
type: 'Line',
lineColor: '#fff',
lineWidth: 1,
layerId: layer,
shapeData: { startPoint: { x: 0, y: 0 }, endPoint: { x: 1, y: 0 } },
});
const serverEntities = [
line('same', '구조물'),
{
...line('same', '치수글'),
type: 'PolyLine',
shapeData: null,
children: [line('same', '치수글')],
},
];
// biome-ignore lint: 시험 — 서버 JSON 모양 그대로
const out = prepareClip(serverEntities as any, [{ name: '치수글', color: '#00ff00' }], existing);
assert.equal(out.entities[0].layerId, 'L-old', '같은 이름 층은 기존 층으로');
assert.equal(out.newLayers.length, 1, '없는 층만 새로');
assert.equal(out.newLayers[0].name, '치수글');
assert.equal(out.newLayers[0].color, '#00ff00', '새 층은 DXF 층 색');
assert.equal(out.entities[1].layerId, out.newLayers[0].id, '새 층에 잇기');
assert.equal(out.entities[1].children?.[0].layerId, out.newLayers[0].id, '폴리선 속 선도 같은 층');
const ids = [out.entities[0].id, out.entities[1].id, out.entities[1].children?.[0].id];
assert.equal(new Set(ids).size, 3, 'id 는 모두 새로(서로 안 겹침)');
assert.ok(!ids.includes('same'), '서버 id 를 그대로 안 씀');
assert.deepEqual(out.entities[0].shapeData, serverEntities[0].shapeData, '좌표는 원좌표 그대로');
console.log('dxf-clip 시험 통과');