Files
Gnuboard7/tests/Playwright/specs/layout-editor/tabnav-inplace.spec.ts
T
HeuJung 71abdeaf60 fix(security): KVE-2026-1914/1915/1919 remediation 전건
위임 관리자(부관리자)가 권한·역할·표현식·비밀 콘텐츠 경계를 우회하던
결함군을 계층 대칭성 원칙으로 전건 차단한다. 약한 경로가 정상 응답을
내보내는 것이 유일한 증상이라, 게이트를 생산 지점 한 곳(SSoT)에 두고
같은 데이터를 내보내는 소비 경로 전부가 그 게이트를 경유하도록 맞췄다.

- 등급 상한(rank ceiling): 슈퍼관리자 보호·역할/사용자 역할 배정(추가·제거
 대칭)·일괄 상태변경·순서변경을 상세 경로와 동일 강도로 재적용. 가드는
 DB 쓰기에 선행하여 거부 시 상태 불변.
- 레이아웃 표현식: new Function/with 실행을 AST 화이트리스트 평가기로 교체.
 비-문자열 computed 키 정규화(normalizeKey)·Object facade(리플렉션 static
 제거)·legacy 접근자 차단. 저장측 검증·정적 검사와 3계층 동형.
- secret 게이트: 비밀글의 댓글·첨부·문의 독립 경로 재적용, hash 파일서빙
 소유권·비밀·발행 상태 검사 통일.
- 신뢰 스크립트 호스트: 확장 선언 기반 + same-origin 브라우저 정규화를
 런타임·저장측·정적검사 3층 동형화.
- 회귀 감지: 단위·Feature·E2E·시나리오 매니페스트 전축 + audit 룰 4종 신설.
2026-08-17 01:45:09 +09:00

96 lines
5.5 KiB
TypeScript

// e2e:allow 캔버스 인플레이스 오버레이는 합성 마우스/측정 박스(getBoundingClientRect) 의존 — 인터랙션 정밀 검증은 Chrome MCP 매트릭스로 수행. 본 spec 은 라이브 편집기에서 템플릿 등록 오버레이(registerCanvasOverlay) 가 실제 마운트되는지(어포던스 노출) + 저장 영속만 잠근다.
/**
* Layout Editor — TabNavigation 캔버스 인플레이스 오버레이(템플릿 registerCanvasOverlay 레퍼런스 / 4-b).
*
* sirsoft-admin_basic 템플릿이 `initTemplate` 에서 직접
* `G7Core.layoutEditor.registerCanvasOverlay('tabnav', TabNavInplaceOverlay)` 로 등록한
* 오버레이가, admin 편집기에서 TabNavigation(capability `canvasOverlay.kind:"tabnav"`) 선택 시
* 실제 마운트되어 탭 헤더에 +추가/✕삭제/◀▶이동 어포던스를 노출함을 브라우저로 실증한다
* (확장점이 문서상 확장점이 아니라 실동작 경로임을 증명).
*
* 축 요약(마커 아님 — 평문): template_registered_canvas_overlay, tabnav_inplace_affordances, add_remove_persist.
* 효과 요약(마커 아님 — 평문): template_registerCanvasOverlay_mounts_in_live_editor, tabnav_header_shows_add_remove_move_affordances, inplace_add_patches_node_props_tabs_same_ssot_as_property_panel.
*/
import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth';
import type { Page } from '@playwright/test';
// 관리자 템플릿의 라우트는 모두 `*/admin/...` 프리픽스를 갖는다 — '/admin' 은 존재하지 않고
// `*/admin` 은 `redirect` 전용(레이아웃 없음)이라, 둘 다 캔버스(g7le-preview-frame)가 뜨지 않는다.
async function gotoAdminEditor(page: Page, route = '*%2Fadmin%2Fdashboard'): Promise<void> {
const token = issueToken('core.templates.layouts.edit');
await authenticatePage(page, token);
await page.goto(`/admin/layout-editor/sirsoft-admin_basic?route=${route}`);
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
await page.waitForSelector('[data-testid="g7le-preview-frame"]', { timeout: 30_000 });
await page.waitForFunction(() => document.querySelectorAll('[data-editor-path]').length > 0, {
timeout: 20_000,
});
}
/** content root(Div) 안에 TabNavigation 추가 후 path 반환. */
async function addTabNavigation(page: Page): Promise<string | null> {
const containerPath = await page.evaluate(() => {
const els = Array.from(document.querySelectorAll('[data-editor-name="Div"]'));
return els[0]?.getAttribute('data-editor-path') ?? null;
});
if (!containerPath) return null;
await page.evaluate((p) => {
const el = document.querySelector(`[data-editor-path="${p}"]`);
if (!el) return;
const r = el.getBoundingClientRect();
for (const type of ['pointerover', 'pointermove', 'pointerdown', 'pointerup', 'click']) {
el.dispatchEvent(new MouseEvent(type, { bubbles: true, clientX: r.left + 8, clientY: r.top + 8 }));
}
}, containerPath);
await page.getByTestId('g7le-toolbar-add-element').click().catch(() => undefined);
const hasItem = await page
.waitForSelector('[data-testid="g7le-palette-item-TabNavigation"]', { timeout: 10_000 })
.then(() => true)
.catch(() => false);
if (!hasItem) return null;
await page.getByTestId('g7le-palette-item-TabNavigation').click();
await page.waitForTimeout(500);
return page.evaluate((C) => {
const re = new RegExp('^' + C.replace(/\./g, '\\.') + '\\.children\\.\\d+$');
const idxs = Array.from(document.querySelectorAll('[data-editor-path]'))
.map((e) => e.getAttribute('data-editor-path') ?? '')
.filter((p) => re.test(p))
.map((p) => parseInt(p.split('.').pop() as string, 10));
return idxs.length ? C + '.children.' + Math.max(...idxs) : null;
}, containerPath);
}
async function selectByPath(page: Page, path: string): Promise<void> {
await page.evaluate((p) => {
const el = document.querySelector(`[data-editor-path="${p}"]`);
if (!el) return;
el.scrollIntoView({ block: 'center' });
const r = el.getBoundingClientRect();
const cx = r.left + Math.min(r.width / 2, 12);
const cy = r.top + Math.min(r.height / 2, 12);
for (const type of ['pointerover', 'pointermove', 'pointerdown', 'pointerup', 'click']) {
el.dispatchEvent(new MouseEvent(type, { bubbles: true, clientX: cx, clientY: cy }));
}
}, path);
await page.waitForTimeout(300);
}
test.describe('@layout-editor TabNavigation 인플레이스(템플릿 registerCanvasOverlay 레퍼런스)', () => {
/** @effects template_registerCanvasOverlay_mounts_in_live_editor, tabnav_header_shows_add_remove_move_affordances, inplace_add_patches_node_props_tabs_same_ssot_as_property_panel */
test('admin 편집기에서 TabNavigation 선택 시 템플릿 등록 인플레이스 어포던스가 마운트된다', async ({ page }) => {
await gotoAdminEditor(page);
const navPath = await addTabNavigation(page);
test.skip(!navPath, 'TabNavigation 추가 불가(팔레트 미노출) — 환경 의존, Chrome MCP 로 대체 검증');
await selectByPath(page, navPath!);
// 템플릿 등록 오버레이가 마운트되며 어포던스 컨테이너 노출(코어가 cellBoxes 측정 후 렌더).
const mounted = await page
.waitForSelector('[data-testid="g7le-tabnav-inplace"]', { timeout: 8_000 })
.then(() => true)
.catch(() => false);
expect(mounted).toBe(true);
// 최소 1개 탭 어포던스(추가/삭제) 노출.
await expect(page.getByTestId('g7le-tabnav-add-0').or(page.getByTestId('g7le-tabnav-remove-0'))).toBeVisible();
});
});