fix(B07): 도각을 배경으로 굳혀 새 선이 잠금 도면층에 떨어지지 않게 한다

- state.setActiveLayerId(): 잠금 도면층(도각·원지반) 요청은 잠금 아닌 첫 층으로
  돌린다. 브리지·자동백업 복구·JSON 가져오기·도면층 패널·리본이 모두 이 함수를
  지나므로 가드를 한 곳에 뒀다. 잠금 아닌 층이 없으면 요청값 유지.
- RibbonWidgets: 「현재 도면층」 목록에서 잠금층을 뺀다(현재 층이 잠금이면 유지).
- Cover 엔진: 표지에 잠금 아닌 「주기」 도면층을 실어 덧그릴 자리를 만든다.
  표지는 엔티티가 전부 도각(잠금)이라 가드만으로는 그릴 곳이 없었다.
- state.resetUndoBaseline(): 도면 적재를 되돌리기 바닥으로 세운다. 첫 Ctrl+Z가
  도면을 싣기 전 빈 상태로 되돌아가 화면이 백지가 되던 결함을 닫는다.
- debug-hook: 검증용 snap() 창구 추가. state.test.ts 3건 신규.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-01 13:58:08 +09:00
co-authored by Claude Opus 5
parent 7377c35b7d
commit 64d944eb0f
7 changed files with 87 additions and 8 deletions
@@ -0,0 +1,48 @@
import { beforeAll, describe, expect, it } from 'vitest';
import type { Entity } from './entities/Entity';
import {
getActiveLayerId,
getEntities,
resetUndoBaseline,
setActiveLayerId,
setEntities,
setLayers,
undo,
} from './state';
const layer = (id: string, isLocked: boolean) => ({
id,
name: id,
isVisible: true,
isLocked,
});
describe('setActiveLayerId', () => {
it('잠금 도면층(배경)은 현재 도면층이 되지 않고 잠금 아닌 첫 층으로 간다', () => {
setLayers([layer('도각', true), layer('계획선', false)]);
setActiveLayerId('도각');
expect(getActiveLayerId()).toBe('계획선');
});
it('잠금 아닌 층이 하나도 없으면 요청값을 그대로 둔다', () => {
setLayers([layer('도각', true)]);
setActiveLayerId('도각');
expect(getActiveLayerId()).toBe('도각');
});
});
describe('resetUndoBaseline', () => {
// 상태 변경 알림만 window로 나간다 — 노드 환경이라 받는 시늉만 시킨다.
beforeAll(() => {
(globalThis as { window?: unknown }).window = { dispatchEvent: () => true };
});
it('기준선을 세운 뒤의 되돌리기는 실은 도면까지만 물러난다', () => {
const loaded = [{ id: 'a' } as unknown as Entity];
setEntities(loaded, false);
resetUndoBaseline();
setEntities([...loaded, { id: 'b' } as unknown as Entity], true);
undo();
expect(getEntities()).toHaveLength(1);
});
});