템플릿 정보가 빌더·렌더러·백엔드에 따로 적혀 어긋나 있었다 — 백엔드 기본값이 없는 id 를 가리켰고, 음식점 강조색 오타, 섹션 간격이 빌더와 서버에서 달랐다. - shared/src/data/templates.json: 템플릿 4개(simple·magazine·retro·paper)와 업종별 허용·기본 - shared/lib/catalog.ts · backend/common/template_catalog.py: 같은 JSON 을 읽는다, 모르는 id 는 에러 - 저장·미리보기·발행에서 모르는 id 를 거절한다(site_service · site.py 422 · build_service 실패) - site: 레이아웃 등록표(basic·paper) + LayoutProvider, Shell→Frame, HomePage→SectionList - 연결 안 된 레이아웃 5개, 배치 고르기(variant), 서체 선택, 빌더 canvas/DevShowcase 삭제 - 빌더: 템플릿을 바꾸면 이전 템플릿이 켠 섹션을 끄고 안내 문구를 띄운다 - postgres-init/migrations/0023: stay-retro → retro, 병원 허용 밖은 NULL(운영 미적용) - Dockerfile·worker: 백엔드 이미지에 shared/src/data 복사 - docs: TEMPLATES.md 신설(세 폴더 역할·템플릿 추가·렌더링 순서), DATA_MODEL·ARCHITECTURE 등 갱신 shared·site·frontend tsc 통과, site vitest 통과, 백엔드 DB 없는 테스트 41 passed(DB 테스트 미실행) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import {expect, it} from 'vitest';
|
|
import {renderToStaticMarkup} from 'react-dom/server';
|
|
import type {SitePayload} from '@o2o/shared';
|
|
import {SiteProvider} from '@site/lib/site-context';
|
|
import {LayoutProvider} from '@site/lib/layout';
|
|
import {LAYOUTS} from '@site/layouts';
|
|
import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay';
|
|
import {BlogSection} from './BlogSection';
|
|
|
|
function withPosts(count: number): SitePayload {
|
|
const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD);
|
|
payload.posts = Array.from({length: count}, (_, i) => ({
|
|
postId: `post-${i}`,
|
|
body: `${i}번째 글입니다. 마당에 앉아 쉬기 좋은 날입니다.`,
|
|
publishedAt: `2026-09-${String((i % 28) + 1).padStart(2, '0')}T09:00:00`,
|
|
}));
|
|
return payload;
|
|
}
|
|
|
|
function render(payload: SitePayload) {
|
|
return renderToStaticMarkup(<SiteProvider payload={payload}><LayoutProvider value={LAYOUTS.basic}><BlogSection /></LayoutProvider></SiteProvider>);
|
|
}
|
|
|
|
it('글이 없으면 섹션째 나오지 않는다', () => {
|
|
const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD);
|
|
delete payload.posts;
|
|
expect(render(payload)).toBe('');
|
|
});
|
|
|
|
it('구운 HTML 에 글이 전부 들어간다 — 크롤러는 2페이지를 못 본다', () => {
|
|
const html = render(withPosts(23));
|
|
for (let i = 0; i < 23; i += 1) expect(html).toContain(`${i}번째 글입니다`);
|
|
});
|
|
|
|
it('글 개수와 무관하게 카로셀 하나로 뜬다 — 페이지를 끊지 않는다', () => {
|
|
expect(render(withPosts(23))).toContain('slider-viewport');
|
|
expect(render(withPosts(4))).toContain('slider-viewport');
|
|
expect(render(withPosts(23))).not.toContain('aria-label="글 페이지"');
|
|
});
|
|
|
|
it('날짜 라벨에 월·일·요일이 찍힌다', () => {
|
|
const html = render(withPosts(1));
|
|
expect(html).toContain('2026-09-01T09:00:00');
|
|
expect(html).toContain('9월 1일');
|
|
expect(html).toMatch(/요일/);
|
|
});
|