feat(export): site.webmanifest/robots.txt 자동 생성 및 extras 포함 (TDD)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { pageSchema, type Page } from '@/lib/schema/page'
|
||||
import { buildExtrasForPage } from '@/lib/exporter/extras'
|
||||
|
||||
function makePage(overrides: Partial<Page> = {}): Page {
|
||||
const base: Page = pageSchema.parse({
|
||||
title: 'My Landing',
|
||||
locale: 'en',
|
||||
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
||||
sections: [],
|
||||
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
||||
seo: { title: 'SEO Title', description: 'desc' },
|
||||
})
|
||||
return { ...base, ...overrides }
|
||||
}
|
||||
|
||||
describe('extras 자동 생성: site.webmanifest / robots.txt', () => {
|
||||
it('Page에서 파생된 site.webmanifest JSON과 robots.txt를 extras에 포함한다', async () => {
|
||||
const page = makePage({ title: 'Awesome App', theme: { primaryColor: '#123456', fontFamily: 'Inter' } })
|
||||
const extras = buildExtrasForPage(page)
|
||||
|
||||
// robots.txt 존재 및 베이스라인 확인
|
||||
expect(Object.keys(extras)).toContain('robots.txt')
|
||||
const robots = new TextDecoder().decode(extras['robots.txt'])
|
||||
expect(robots).toMatch(/User-agent: \*/)
|
||||
|
||||
// manifest 존재 및 필수 키 확인
|
||||
expect(Object.keys(extras)).toContain('site.webmanifest')
|
||||
const manifestStr = new TextDecoder().decode(extras['site.webmanifest'])
|
||||
const manifest = JSON.parse(manifestStr)
|
||||
expect(manifest.name).toBe('Awesome App')
|
||||
expect(manifest.short_name.length).toBeGreaterThan(0)
|
||||
expect(manifest.start_url).toBe('/')
|
||||
expect(manifest.display).toBe('standalone')
|
||||
expect(manifest.theme_color).toBe('#123456')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user