Files
Gnuboard7/tests/Playwright/specs/admin/settings-upload-orphan-cleanup.spec.ts
T
HeuJung cfc2caba1b feat(ckeditor5,board,ecommerce,page,core,admin_basic): 미참조 에디터 업로드 이미지 정리 신설 + 업로드 고아 동종 결함 7건 전수 해소
공개 (@Tuwasduliebst 제보) 대응.

- ckeditor5: 미참조 이미지 정리 엔진 신설 — 참조 판정(hash + 파일명 2토큰,
 filter_reference_sources 훅으로 확장 콘텐츠 등록) + 정리 커맨드(기본 꺼짐 옵트인,
 3중 게이트) + 업로드 관리 화면(권한 분리·참조 배지·개별/선택 삭제) + 기설치본
 설정 백필 upgrade step
- board: 임시 첨부 GC(상시) + 소프트삭제 첨부 영구 정리(옵트인) + 설정 UI,
 저장 payload 누락(F4)·빈 temp 디렉토리 잔존(F5) 수정
- ecommerce: 임시 상품 이미지 GC + 카테고리 삭제 시 이미지 파일 미삭제(S4) 수정
- page: 임시 첨부 GC
- 코어: 고아 첨부 정리 커맨드(옵트인, site_logo 보호) + 사이트 로고 교체 시
 구 로고 재편입 차단(S6) + DB 백업 미구현 501 정직화(B3) + 플러그인 관리자
 메뉴 설치·업데이트 자동 동기화(F1·F7)
- 동반: 플러그인 설정 검증 오류 필드명 라벨화(F3), Toggle 노드 type 정정
 수평 전개(marketing 1.0.2 bump·gdpr·ecommerce), ja 언어팩 4종, API 문서,
 hooks.md, 시나리오 매니페스트 8종, Playwright E2E 4종
2026-08-17 02:44:54 +09:00

100 lines
4.3 KiB
TypeScript

/**
* E2E: 환경설정 > 업로드 — "고아 첨부 정리" 카드 (공개 #115)
*
* @scenario admin_settings_upload_orphan_cleanup
* @effects core_settings_orphan_toggle_default_off, core_settings_orphan_keys_declared
*
* 배경: 폼을 저장하지 않고 나가 소유자 없이 남은 첨부를 매일 파기하는 기능의 운영자 스위치다.
* 사용자 파일을 실제로 지우는 설정이라 "기본 꺼짐" 이 인수 기준이고, 그 상태는 서버 기본값과
* 화면 렌더가 함께 맞아야 성립한다. 단위 테스트(admin-settings-orphan-cleanup)는 레이아웃 JSON
* 의 바인딩 키만 검증하므로, 실제 값이 실려 렌더되는지는 브라우저로만 확인된다.
*
* 검증:
* 1. 업로드 탭에 카드가 마운트되고 항목명·설명이 raw 키가 아닌 번역문으로 표시된다
* 2. 자동 정리 토글이 기본 꺼짐으로 보인다 (설정을 만지지 않은 사이트의 인수 기준)
* 3. 보존기간에 0 을 넣고 저장하면 422 로 거절되고, 안내 문구에 항목명이 사람 말로 나온다
*/
import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth';
const CARD = '#card_orphan_cleanup';
const TOGGLE_ROW = '#field_orphan_cleanup_enabled';
const RETENTION_ROW = '#field_orphan_retention_days';
/** 관리자 환경설정 업로드 탭 진입 */
async function gotoUploadTab(page: import('@playwright/test').Page): Promise<void> {
await page.goto('/admin/settings?tab=upload');
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
await expect(page.locator(CARD)).toBeAttached({ timeout: 20_000 });
}
// @scenario tab=upload, permitted=yes
// @effects core_settings_orphan_keys_declared
test('#115 - 업로드 탭에 "고아 첨부 정리" 카드가 번역문과 함께 마운트된다', async ({ page }) => {
const consoleErrors: string[] = [];
page.on('console', (message) => {
if (message.type() === 'error') consoleErrors.push(message.text());
});
const token = issueToken('core.settings.read', 'core.settings.update');
await authenticatePage(page, token);
await gotoUploadTab(page);
expect(page.url()).not.toMatch(/\/admin\/login/);
const card = page.locator(CARD);
const text = (await card.innerText()).trim();
// 다국어 키가 해석되지 않으면 "$t:admin.settings.upload.orphan_..." 원문이 그대로 노출된다.
expect(text).not.toContain('$t:');
expect(text).not.toContain('orphan_cleanup');
expect(text.length).toBeGreaterThan(0);
await expect(page.locator(TOGGLE_ROW)).toBeAttached();
await expect(page.locator(RETENTION_ROW)).toBeAttached();
expect(consoleErrors).toEqual([]);
});
// @scenario tab=upload, permitted=yes
// @effects core_settings_orphan_toggle_default_off
test('#115 - 자동 정리 토글은 기본 꺼짐으로 렌더된다', async ({ page }) => {
const token = issueToken('core.settings.read', 'core.settings.update');
await authenticatePage(page, token);
await gotoUploadTab(page);
const toggle = page.locator(TOGGLE_ROW).locator('input[type="checkbox"]').first();
await expect(toggle).toBeAttached();
// 설정을 만지지 않은 사이트에서 자동 삭제 0 이 인수 기준이다 — 화면도 그 상태를 보여야 한다.
expect(await toggle.isChecked()).toBe(false);
});
// @scenario tab=upload, permitted=yes, value=invalid
// @effects core_settings_orphan_keys_declared
test('#115 - 보존기간 0 은 항목명이 드러난 안내와 함께 거절된다', async ({ page }) => {
const token = issueToken('core.settings.read', 'core.settings.update');
await authenticatePage(page, token);
await gotoUploadTab(page);
const input = page.locator(RETENTION_ROW).locator('input').first();
await input.fill('0');
const response = page.waitForResponse(
(res) => res.url().includes('/api/admin/settings') && res.request().method() === 'POST',
{ timeout: 20_000 },
);
await page.getByRole('button', { name: /저장|Save/ }).first().click();
const res = await response;
expect(res.status()).toBe(422);
const body = await res.json();
const message = JSON.stringify(body);
// 원시 키(`upload.orphan retention days`)가 그대로 나오면 attributes 정의가 빠진 것이다.
expect(message).not.toContain('orphan retention days');
});