feat(b07): 횡단 장 안내선 보이기 / 숨기기 단추 — 점선 작도 영역 + 붉은 넘침 틀 · 숨김이면 넘침 토스트 없음(180-3)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01STqEqztUthVFBmEP18wBSz
This commit is contained in:
2026-10-10 11:56:37 +09:00
co-authored by Claude Sonnet 5.5
parent be57e54fff
commit 1ceee943bc
8 changed files with 303 additions and 15 deletions
@@ -1,13 +1,17 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import {
GUIDE_MIN_MM,
type GuideArea,
dragGuideArea,
drawGuide,
getGuide,
isGuideVisible,
pickGuideHandle,
setGuide,
setGuideArea,
setGuideVisible,
} from './guide-area.ts';
import type { ScreenCanvasDrawController } from '../drawControllers/screenCanvas.drawController.ts';
const AREA: GuideArea = [42, 47, 812, 567];
@@ -40,4 +44,39 @@ describe('작도 영역 가이드(169-1 · 169-3)', () => {
expect(dragGuideArea(AREA, 's', { x: 0, y: 9999 })).toEqual([42, 567 - GUIDE_MIN_MM, 812, 567]);
expect(dragGuideArea(AREA, 'e', { x: -100, y: 0 })).toEqual([42, 47, 42 + GUIDE_MIN_MM, 567]);
});
it('안내선 보이기 / 숨기기(180-3) — 숨김이면 점선 영역 · 붉은 틀 안 그림 · 싣기를 거쳐도 이어짐', () => {
const lines = vi.fn();
const controller = {
setOpacity: vi.fn(),
setLineStyles: vi.fn(),
worldToTarget: (point: unknown) => point,
drawLineScreen: lines,
fillRectScreen: vi.fn(),
} as unknown as ScreenCanvasDrawController;
const guide = { area: AREA, marks: [[0, 0, 5, 5] as GuideArea], editable: false };
setGuide(guide);
expect(isGuideVisible()).toBe(true); // 기본 = 보임
drawGuide(controller);
expect(lines).toHaveBeenCalledTimes(8); // 점선 영역 4 변 + 붉은 틀 4 변
setGuideVisible(false);
lines.mockClear();
drawGuide(controller);
expect(lines).not.toHaveBeenCalled();
setGuide(guide); // 장을 다시 실어도 숨김 유지
setGuideArea([0, 0, 100, 50]);
drawGuide(controller);
expect(isGuideVisible()).toBe(false);
expect(lines).not.toHaveBeenCalled();
expect(getGuide()?.marks).toHaveLength(1); // 값은 그대로 — 그리기만 거름
setGuideVisible(true);
drawGuide(controller);
expect(lines).toHaveBeenCalledTimes(8);
setGuideVisible('x'); // 어긋난 값 = 보임
expect(isGuideVisible()).toBe(true);
setGuide(null);
});
});