v7.0.0-beta.2 release

This commit is contained in:
HeuJung committed 2026-04-20 20:37:49 +09:00
1 parent 6595fd0eb5
commit fa8eba7a0d
1165 files changed
+107118 -762127

No files matched your search

@@ -0,0 +1,172 @@
/**
* @file board-seo-meta.test.tsx
* @description 게시판 레이아웃 SEO meta 설정 구조 검증 (이슈 #78)
*
* 검증 항목:
* 1. boards.json: meta.seo.extensions, page_type, toggle_setting, vars
* 2. index.json: meta.seo.extensions, page_type, toggle_setting, vars, _seo 바인딩
* 3. show.json: meta.seo.extensions, page_type, toggle_setting, vars, _seo 바인딩
*/
import { describe, it, expect } from 'vitest';
import boardsLayout from '../../../layouts/board/boards.json';
import indexLayout from '../../../layouts/board/index.json';
import showLayout from '../../../layouts/board/show.json';
// JSON 내 문자열 포함 여부 검사 헬퍼
function jsonContains(obj: unknown, str: string): boolean {
return JSON.stringify(obj).includes(str);
}
describe('boards.json - SEO meta 설정', () => {
const seo = (boardsLayout as any).meta?.seo;
it('meta.seo가 존재한다', () => {
expect(seo).toBeDefined();
});
it('enabled가 true이다', () => {
expect(seo.enabled).toBe(true);
});
it('extensions에 sirsoft-board 모듈이 포함된다', () => {
const ext = seo.extensions;
expect(Array.isArray(ext)).toBe(true);
const hasSirsoftBoard = ext.some(
(e: any) => e.type === 'module' && e.id === 'sirsoft-board'
);
expect(hasSirsoftBoard, 'sirsoft-board extension이 없다').toBe(true);
});
it('page_type이 boards이다', () => {
expect(seo.page_type).toBe('boards');
});
it('toggle_setting이 seo.seo_boards를 참조한다', () => {
expect(seo.toggle_setting).toBe('$module_settings:sirsoft-board:seo.seo_boards');
});
it('vars에 site_name이 정의된다', () => {
expect(seo.vars).toBeDefined();
expect(seo.vars.site_name).toBe('$core_settings:general.site_name');
});
it('auth_mode가 optional이다 (봇 접근 허용)', () => {
const ds = (boardsLayout as any).data_sources as any[];
const boardListDs = ds?.find((d: any) => d.id === 'boardList');
expect(boardListDs).toBeDefined();
expect(boardListDs.auth_mode).toBe('optional');
});
});
describe('index.json - SEO meta 설정', () => {
const seo = (indexLayout as any).meta?.seo;
it('meta.seo가 존재한다', () => {
expect(seo).toBeDefined();
});
it('enabled가 true이다', () => {
expect(seo.enabled).toBe(true);
});
it('extensions에 sirsoft-board 모듈이 포함된다', () => {
const ext = seo.extensions;
expect(Array.isArray(ext)).toBe(true);
const hasSirsoftBoard = ext.some(
(e: any) => e.type === 'module' && e.id === 'sirsoft-board'
);
expect(hasSirsoftBoard, 'sirsoft-board extension이 없다').toBe(true);
});
it('page_type이 board이다', () => {
expect(seo.page_type).toBe('board');
});
it('toggle_setting이 seo.seo_board를 참조한다', () => {
expect(seo.toggle_setting).toBe('$module_settings:sirsoft-board:seo.seo_board');
});
it('vars에 site_name, board_name, board_description이 정의된다', () => {
const vars = seo.vars;
expect(vars).toBeDefined();
expect(vars.site_name).toBe('$core_settings:general.site_name');
expect(vars.board_name).toContain('board.name');
expect(vars.board_description).toContain('board.description');
});
it('vars 표현식에 fallback(??)이 있다', () => {
const vars = seo.vars;
expect(vars.board_name).toContain('??');
expect(vars.board_description).toContain('??');
});
it('og.description이 _seo 컨텍스트를 참조한다', () => {
const ogDesc = seo.og?.description ?? '';
expect(ogDesc).toContain('_seo');
});
});
describe('show.json - SEO meta 설정', () => {
const seo = (showLayout as any).meta?.seo;
it('meta.seo가 존재한다', () => {
expect(seo).toBeDefined();
});
it('enabled가 true이다', () => {
expect(seo.enabled).toBe(true);
});
it('extensions에 sirsoft-board 모듈이 포함된다', () => {
const ext = seo.extensions;
expect(Array.isArray(ext)).toBe(true);
const hasSirsoftBoard = ext.some(
(e: any) => e.type === 'module' && e.id === 'sirsoft-board'
);
expect(hasSirsoftBoard, 'sirsoft-board extension이 없다').toBe(true);
});
it('page_type이 post이다', () => {
expect(seo.page_type).toBe('post');
});
it('toggle_setting이 seo.seo_post_detail을 참조한다', () => {
expect(seo.toggle_setting).toBe('$module_settings:sirsoft-board:seo.seo_post_detail');
});
it('vars에 site_name, board_name, post_title이 정의된다', () => {
const vars = seo.vars;
expect(vars).toBeDefined();
expect(vars.site_name).toBe('$core_settings:general.site_name');
expect(vars.board_name).toContain('board.name');
expect(vars.post_title).toContain('post.data.title');
});
it('vars 표현식에 fallback(??)이 있다', () => {
const vars = seo.vars;
expect(vars.board_name).toContain('??');
expect(vars.post_title).toContain('??');
});
it('og.title이 _seo 컨텍스트를 참조한다', () => {
const ogTitle = seo.og?.title ?? '';
expect(ogTitle).toContain('_seo');
});
it('og.description이 _seo 컨텍스트를 참조한다', () => {
const ogDesc = seo.og?.description ?? '';
expect(ogDesc).toContain('_seo');
});
it('structured_data.headline이 _seo 컨텍스트를 참조한다', () => {
const headline = seo.structured_data?.headline ?? '';
expect(headline).toContain('_seo');
});
it('data_sources에 post가 정의된다', () => {
const ds = (showLayout as any).data_sources as any[];
const postDs = ds?.find((d: any) => d.id === 'post');
expect(postDs).toBeDefined();
});
});
@@ -6,7 +6,7 @@
* - 기본 렌더링: 페이지 데이터 있을 때 제목/본문/첨부파일 영역 확인
* - 조건부 렌더링: 데이터 없을 때 not_found 영역 표시, 데이터 있을 때 back_button 표시
* - 첨부파일: 없을 때 섹션 미표시, 있을 때 섹션 표시
* - 상태 배지: draft/archived 상태에 따른 배지 조건부 렌더링
* - 버전 배지: 관리자에게만 표시되는 버전 배지 렌더링
* - 관리자 편집 버튼: 관리자만 표시
*
* @vitest-environment jsdom
@@ -95,16 +95,9 @@ const pageShowFixture = {
{
type: 'basic',
name: 'Span',
if: '{{page?.data?.status === "draft"}}',
props: { 'data-testid': 'badge-draft' },
text: 'status_draft',
},
{
type: 'basic',
name: 'Span',
if: '{{page?.data?.status === "archived"}}',
props: { 'data-testid': 'badge-archived' },
text: 'status_archived',
if: '{{_global.currentUser?.is_admin}}',
props: { 'data-testid': 'badge-version' },
text: 'v{{page?.data?.current_version ?? 1}}',
},
{
id: 'page_admin_edit_button',
@@ -202,9 +195,8 @@ function makePageApiResponse(overrides: Record<string, unknown> = {}) {
id: 1,
title: '이용약관',
content: '<p>내용</p>',
status: 'active',
attachments: [],
version: 1,
current_version: 1,
...overrides,
},
},
@@ -279,46 +271,37 @@ describe('page/show.json 레이아웃 렌더링 (Issue #99)', () => {
});
});
describe('상태 배지 조건부 렌더링', () => {
it('active 상태에서는 draft/archived 배지가 표시되지 않는다', async () => {
const testUtils = createLayoutTest(pageShowFixture, { componentRegistry: registry });
testUtils.mockApi('terms', makePageApiResponse({ status: 'active' }));
describe('버전 배지 조건부 렌더링', () => {
it('관리자에게는 버전 배지가 표시된다', async () => {
const testUtils = createLayoutTest(pageShowFixture, {
componentRegistry: registry,
initialState: { _global: { currentUser: { is_admin: true } } },
});
testUtils.mockApi('terms', makePageApiResponse({ current_version: 2 }));
await testUtils.render();
await waitFor(() => {
expect(screen.getByTestId('badge-version')).toBeInTheDocument();
});
expect(screen.getByTestId('badge-version')).toHaveTextContent('v2');
testUtils.cleanup();
});
it('비관리자에게는 버전 배지가 표시되지 않는다', async () => {
const testUtils = createLayoutTest(pageShowFixture, {
componentRegistry: registry,
initialState: { _global: { currentUser: { is_admin: false } } },
});
testUtils.mockApi('terms', makePageApiResponse());
await testUtils.render();
await waitFor(() => {
expect(screen.getByTestId('page-content-card')).toBeInTheDocument();
});
expect(screen.queryByTestId('badge-draft')).not.toBeInTheDocument();
expect(screen.queryByTestId('badge-archived')).not.toBeInTheDocument();
testUtils.cleanup();
});
it('draft 상태에서는 draft 배지가 표시된다', async () => {
const testUtils = createLayoutTest(pageShowFixture, { componentRegistry: registry });
testUtils.mockApi('terms', makePageApiResponse({ status: 'draft' }));
await testUtils.render();
await waitFor(() => {
expect(screen.getByTestId('badge-draft')).toBeInTheDocument();
});
expect(screen.queryByTestId('badge-archived')).not.toBeInTheDocument();
testUtils.cleanup();
});
it('archived 상태에서는 archived 배지가 표시된다', async () => {
const testUtils = createLayoutTest(pageShowFixture, { componentRegistry: registry });
testUtils.mockApi('terms', makePageApiResponse({ status: 'archived' }));
await testUtils.render();
await waitFor(() => {
expect(screen.getByTestId('badge-archived')).toBeInTheDocument();
});
expect(screen.queryByTestId('badge-draft')).not.toBeInTheDocument();
expect(screen.queryByTestId('badge-version')).not.toBeInTheDocument();
testUtils.cleanup();
});