From 1d441b17d7f84a4bec14c82b4d5b98f085ed2ba4 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Fri, 14 Nov 2025 20:49:47 +0900 Subject: [PATCH] feat(exporter): SEO/Perf small improvements (canonical, lazy/async hero, dark token) + tests --- MAIN_PLAN.md | 5 +++++ lib/exporter/a11yResponsive.test.ts | 2 +- lib/exporter/html.ts | 4 +++- lib/exporter/seoPerf.tokens.test.ts | 34 +++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 lib/exporter/seoPerf.tokens.test.ts diff --git a/MAIN_PLAN.md b/MAIN_PLAN.md index 47ea38c..57ab142 100644 --- a/MAIN_PLAN.md +++ b/MAIN_PLAN.md @@ -160,6 +160,10 @@ - 스킵링크 등 선행 포커서블 회피: Desktop 버튼에 명시적 `focus()` - 키보드 시나리오: Tab → Mobile 포커스 확인 → Space로 토글 → Shift+Tab → Enter +##### 추가 CI 결과(2025-11-14) +- E2E a11y 스모크 추가: 포커스 아웃라인(3px solid, 브랜드 컬러), 스킵링크 탭 순서(main 포커스 이동) +- Exporter JS에 스킵링크 클릭 시 `#main`에 `tabindex="-1"` 부여 후 `focus()` 처리 → CI 그린 통과 + #### 머지 상태 - 머지 방식: Squash and merge - 브랜치 정리: `feat/ci-verify-run` 삭제 완료 @@ -237,6 +241,7 @@ - [2025-11-13 22:55] BuilderClientPage 렌더 중 ref 접근 경고 / useRef.current를 렌더 중 참조하여 ESLint 경고 발생 / FormBuilderPanel 통합 시 `useRef(createFormStore())` 사용 / `useMemo(() => createFormStore(), [])`로 스토어 인스턴스 고정하고 `useSyncExternalStore`에 직접 주입하여 해결 / 렌더 중 ref 접근 금지 원칙 재확인 - [2025-11-14 09:35] Vitest 로그에서 i18n 누락 메시지 경고 확인(en: `builder.action.addSelect/addRadio`, `builder.form.actionUrl/honeypot/minSeconds`) → `messages/en.json`에 키 존재 여부 점검 및 누락 보완 후 재실행, 모든 테스트 그린 유지 - [2025-11-14 09:45] 프리뷰 텍스트 매칭 불안정으로 테스트 실패 → `data-testid` 기반 안정화(`preview-seo-title` 등) 및 텍스트 매칭 지점 `Title:`→`Locale:`로 조정, 전면 그린 + - [2025-11-14 20:30] E2E 실패: 스킵링크 활성화 후 main 포커스 미이동 → Exporter JS에 스킵링크 클릭 핸들러 추가(`tabindex=-1` + `focus()`) → 로컬/CI 모두 그린 ## 의사결정 기록(ADR) - [YYYY-MM-DD] Next.js(App Router) 채택: 생태계/배포/서버리스/SEO 편의성. diff --git a/lib/exporter/a11yResponsive.test.ts b/lib/exporter/a11yResponsive.test.ts index 081b859..270a2e7 100644 --- a/lib/exporter/a11yResponsive.test.ts +++ b/lib/exporter/a11yResponsive.test.ts @@ -41,7 +41,7 @@ describe('Exporter a11y/responsive enhancements', () => { test('hero image alt derives from heading', () => { const out = exportPage(makePage()) expect(out.html).toContain('

Welcome

') - expect(out.html).toContain('Welcome') + expect(out.html).toMatch(/]*src="https:\/\/example\.com\/img\.png"[^>]*alt="Welcome"[^>]*\/>/) }) test('responsive and a11y CSS tokens exist', () => { diff --git a/lib/exporter/html.ts b/lib/exporter/html.ts index 45ce4a0..3eff894 100644 --- a/lib/exporter/html.ts +++ b/lib/exporter/html.ts @@ -108,7 +108,7 @@ function renderHero(section: { props: { heading: string; subheading?: string; im ${subheading ? `

${escapeHtml(subheading)}

` : ''}
- ${escapeHtml(heading)} + ${escapeHtml(heading)}
@@ -237,6 +237,7 @@ function buildHead(page: Page) { return ` + ${escapeHtml(page.seo.title)} @@ -272,6 +273,7 @@ function buildCss(page: Page) { .testimonial blockquote{ margin:0; font-style:italic; color:#1f2937 } .testimonial figcaption{ color:#475569; margin-top:.25rem } @media (max-width: 640px){ .container{ padding: 1rem } h1{ font-size: 1.5rem } } + @media (prefers-color-scheme: dark){ body{ color:#e5e7eb; background:#0b1020 } .feature-item{ background:#0f172a; border-color:#1f2937 } } @media (prefers-reduced-motion: reduce){ *{ transition: none !important; animation: none !important } } ` } diff --git a/lib/exporter/seoPerf.tokens.test.ts b/lib/exporter/seoPerf.tokens.test.ts new file mode 100644 index 0000000..de4d41a --- /dev/null +++ b/lib/exporter/seoPerf.tokens.test.ts @@ -0,0 +1,34 @@ +import { describe, it, expect } from 'vitest' +import { exportPage } from '@/lib/exporter/html' +import { pageSchema, type Page } from '@/lib/schema/page' + +function makePage(): Page { + return pageSchema.parse({ + title: 'SEO/Perf', + locale: 'en', + theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' }, + sections: [ + { type: 'hero', props: { heading: 'Welcome', subheading: 'Sub', imageUrl: 'https://img.example/hero.png' } }, + ], + form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } }, + seo: { title: 'SEO', description: 'Desc' }, + }) +} + +describe('Exporter - small SEO/Perf improvements', () => { + it('includes canonical link and dark mode tokens; hero image lazy/async', () => { + const out = exportPage(makePage()) + const html = out.html + const css = out.css + + // canonical link present in head + expect(html).toMatch(/]+rel="canonical"/) + + // hero image has loading/decoding attributes + expect(html).toMatch(/]*loading="lazy"/) + expect(html).toMatch(/]*decoding="async"/) + + // dark mode media query token exists + expect(css).toMatch(/@media \(prefers-color-scheme: dark\)/) + }) +}) -- 2.52.0