위임 관리자(부관리자)가 권한·역할·표현식·비밀 콘텐츠 경계를 우회하던 결함군을 계층 대칭성 원칙으로 전건 차단한다. 약한 경로가 정상 응답을 내보내는 것이 유일한 증상이라, 게이트를 생산 지점 한 곳(SSoT)에 두고 같은 데이터를 내보내는 소비 경로 전부가 그 게이트를 경유하도록 맞췄다. - 등급 상한(rank ceiling): 슈퍼관리자 보호·역할/사용자 역할 배정(추가·제거 대칭)·일괄 상태변경·순서변경을 상세 경로와 동일 강도로 재적용. 가드는 DB 쓰기에 선행하여 거부 시 상태 불변. - 레이아웃 표현식: new Function/with 실행을 AST 화이트리스트 평가기로 교체. 비-문자열 computed 키 정규화(normalizeKey)·Object facade(리플렉션 static 제거)·legacy 접근자 차단. 저장측 검증·정적 검사와 3계층 동형. - secret 게이트: 비밀글의 댓글·첨부·문의 독립 경로 재적용, hash 파일서빙 소유권·비밀·발행 상태 검사 통일. - 신뢰 스크립트 호스트: 확장 선언 기반 + same-origin 브라우저 정규화를 런타임·저장측·정적검사 3층 동형화. - 회귀 감지: 단위·Feature·E2E·시나리오 매니페스트 전축 + audit 룰 4종 신설.
151 lines
7.9 KiB
TypeScript
151 lines
7.9 KiB
TypeScript
/**
|
|
* Layout Editor — 속성 편집 모달 + sampleGlobal 체인 회귀.
|
|
*
|
|
* S6-2 검증:
|
|
* - 요소 선택 → ⓘ 메뉴 "속성 설정" → 속성 편집 모달 렌더(스타일 탭 + 컨트롤)
|
|
* - 스타일 컨트롤 조작 → 캔버스 라이브 반영(노드 className/style 패치)
|
|
* - sampleGlobal 체인: 코어 시드 폐기 후 번들 템플릿 editor-spec.json.sampleGlobal
|
|
* 이 _global.currentUser / settings.site_name 을 제공 → 헤더 사이트명이 폴백("Site")
|
|
* 이 아닌 샘플값으로 렌더
|
|
* - guest_only 레이아웃: 템플릿이 currentUser 를 시드해도 비로그인 페이지에서 제외 →
|
|
* "이미 로그인되어 있습니다" 토스트 미발화
|
|
*
|
|
* 축 요약(마커 아님 — 평문): property_modal_open, style_control_patch, sample_global_from_template, guest_only_no_currentUser.
|
|
* 효과 요약(마커 아님 — 평문): modal_visible, canvas_live_patch, site_name_seeded, guest_only_no_redirect_toast.
|
|
*/
|
|
import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth';
|
|
|
|
/** path 로 노드를 합성 마우스 이벤트로 선택한다 — 캔버스 노드는 드래그 핸들이 덮어 실제
|
|
* 마우스 클릭이 가로채이므로, 합성 이벤트 시퀀스로 선택 로직을 직접 트리거한다. */
|
|
async function selectNodeByPath(page: import('@playwright/test').Page, path: string): Promise<boolean> {
|
|
return page.evaluate((p) => {
|
|
const el = document.querySelector(`[data-editor-path="${p}"]`);
|
|
if (!el) return false;
|
|
const r = (el as HTMLElement).getBoundingClientRect();
|
|
for (const t of ['pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click']) {
|
|
el.dispatchEvent(new MouseEvent(t, { bubbles: true, cancelable: true, clientX: r.left + 8, clientY: r.top + 8, view: window }));
|
|
}
|
|
return true;
|
|
}, path);
|
|
}
|
|
|
|
/** 캔버스의 visible 노드 path 목록(앞쪽 N개). 반응형 hidden(mobile_header 등) 제외. */
|
|
async function visibleNodePaths(page: import('@playwright/test').Page, limit: number): Promise<string[]> {
|
|
return page.evaluate((max) => {
|
|
const out: string[] = [];
|
|
for (const el of Array.from(document.querySelectorAll('[data-editor-path]'))) {
|
|
const r = (el as HTMLElement).getBoundingClientRect();
|
|
const path = el.getAttribute('data-editor-path');
|
|
if (path && path !== '2' && r.width > 0 && r.height > 0 && getComputedStyle(el as HTMLElement).display !== 'none') out.push(path);
|
|
if (out.length >= max) break;
|
|
}
|
|
return out;
|
|
}, limit);
|
|
}
|
|
|
|
/** info 어포던스(ⓘ)가 뜨는 첫 노드를 선택한다 — 어포던스 노출은 컴포넌트 종류에 따라 다르므로
|
|
* (잠금/데이터결정 노드는 미노출), visible 노드를 순회하며 ⓘ 가 뜨는 노드를 찾는다. */
|
|
async function selectNodeWithInfoButton(page: import('@playwright/test').Page): Promise<void> {
|
|
const paths = await visibleNodePaths(page, 12);
|
|
for (const path of paths) {
|
|
if (!(await selectNodeByPath(page, path))) continue;
|
|
const info = page.getByTestId('g7le-overlay-info-button');
|
|
if (await info.isVisible().catch(() => false)) return;
|
|
}
|
|
throw new Error('ⓘ 어포던스가 뜨는 캔버스 노드를 찾지 못했습니다');
|
|
}
|
|
|
|
test.describe('@layout-editor 속성 편집 모달 (S6-2)', () => {
|
|
/** @effects modal_visible, canvas_live_patch */
|
|
test('요소 선택 → ⓘ → 속성 설정 → 스타일 탭 컨트롤 렌더 + 패치', async ({ page }) => {
|
|
const token = issueToken('core.templates.layouts.edit');
|
|
await authenticatePage(page, token);
|
|
|
|
await page.goto('/admin/layout-editor/sirsoft-basic?route=%2F');
|
|
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 },
|
|
);
|
|
|
|
// ⓘ 어포던스가 뜨는 첫 노드 선택. 루트("2")는 캔버스 전면을 덮어 제외하고, 어포던스 노출은
|
|
// 컴포넌트 종류에 따라 다르므로(잠금/데이터결정 노드 미노출) visible 노드를 순회해 찾는다.
|
|
await selectNodeWithInfoButton(page);
|
|
|
|
// 선택 오버레이 + ⓘ 버튼 등장 대기
|
|
await page.waitForSelector('[data-testid="g7le-overlay-info-button"]', { timeout: 10_000 });
|
|
await page.getByTestId('g7le-overlay-info-button').click();
|
|
|
|
// 컨텍스트 메뉴 "속성 설정" → 속성 편집 모달
|
|
await page.waitForSelector('[data-testid="g7le-context-menu-edit-props"]', { timeout: 5_000 });
|
|
await page.getByTestId('g7le-context-menu-edit-props').click();
|
|
|
|
// 속성 편집 모달 렌더
|
|
await page.waitForSelector('[data-testid="g7le-property-modal"]', { timeout: 10_000 });
|
|
await expect(page.getByTestId('g7le-property-modal-title')).toBeVisible();
|
|
|
|
// 스타일 탭이 있으면 컨트롤이 렌더되어야 함(편집 가능 속성 보유 노드).
|
|
// 편집 가능 속성 없는 노드면 안내가 표시된다 — 둘 중 하나는 반드시 존재.
|
|
const hasStyleTab = await page.getByTestId('g7le-property-tab-style').count();
|
|
const hasNoEditable = await page.getByTestId('g7le-property-modal-no-editable').count();
|
|
expect(hasStyleTab + hasNoEditable).toBeGreaterThan(0);
|
|
});
|
|
|
|
/** @effects site_name_seeded */
|
|
test('sampleGlobal: 번들 템플릿 시드로 _global.currentUser / settings 가 채워진다 (코어 시드 폐기 후)', async ({ page }) => {
|
|
const token = issueToken('core.templates.layouts.edit');
|
|
await authenticatePage(page, token);
|
|
|
|
await page.goto('/admin/layout-editor/sirsoft-basic?route=%2F');
|
|
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
|
|
await page.waitForSelector('[data-testid="g7le-preview-frame"]', { timeout: 30_000 });
|
|
|
|
// 격리 store 의 _global 이 템플릿 sampleGlobal 로 채워졌는지 — currentUser.uuid + site_name.
|
|
// 코어 시드 폐기 후 이 값은 sirsoft-basic editor-spec.json.sampleGlobal 에서 온다.
|
|
await page.waitForFunction(
|
|
() => {
|
|
const app = (window as unknown as { __templateApp?: { getGlobalState?: () => Record<string, unknown> } }).__templateApp;
|
|
if (!app?.getGlobalState) return false;
|
|
const g = app.getGlobalState();
|
|
const cu = g.currentUser as { uuid?: string } | undefined;
|
|
const settings = g.settings as { general?: { site_name?: string } } | undefined;
|
|
return !!cu?.uuid && !!settings?.general?.site_name;
|
|
},
|
|
{ timeout: 20_000 },
|
|
);
|
|
});
|
|
|
|
/** @effects guest_only_no_redirect_toast */
|
|
test('guest_only 레이아웃: 템플릿 currentUser 시드 제외 → "이미 로그인" 토스트 미발화', async ({ page }) => {
|
|
const token = issueToken('core.templates.layouts.edit');
|
|
await authenticatePage(page, token);
|
|
|
|
const toastTexts: string[] = [];
|
|
page.on('console', (msg) => toastTexts.push(msg.text()));
|
|
|
|
await page.goto('/admin/layout-editor/sirsoft-basic?route=%2Fforgot-password');
|
|
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
|
|
await page.waitForSelector('[data-testid="g7le-preview-frame"]', { timeout: 30_000 });
|
|
|
|
// guest_only 레이아웃은 currentUser 가 격리 store 에서 제외되어야 함.
|
|
await page.waitForFunction(
|
|
() => {
|
|
const app = (window as unknown as { __templateApp?: { getGlobalState?: () => Record<string, unknown> } }).__templateApp;
|
|
if (!app?.getGlobalState) return false;
|
|
const g = app.getGlobalState();
|
|
return g.currentUser === undefined;
|
|
},
|
|
{ timeout: 20_000 },
|
|
);
|
|
|
|
// 캔버스에 "이미 로그인되어 있습니다" 류 토스트가 노출되지 않아야 함.
|
|
const loginToast = await page
|
|
.locator('text=/이미 로그인|already logged in/i')
|
|
.count();
|
|
expect(loginToast).toBe(0);
|
|
});
|
|
});
|