feat(export): extras 오버라이드 지원(robots/manifest) TDD 및 구현
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { pageSchema, type Page } from '@/lib/schema/page'
|
||||
import { buildExtrasForPage } from '@/lib/exporter/extras'
|
||||
|
||||
function makePage(): Page {
|
||||
return pageSchema.parse({
|
||||
title: 'Overrides Demo',
|
||||
locale: 'en',
|
||||
theme: { primaryColor: '#123456', fontFamily: 'Inter' },
|
||||
sections: [
|
||||
{ type: 'hero', props: { heading: 'Hello', subheading: 'World', imageUrl: 'https://img.example/hero.png' } },
|
||||
],
|
||||
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
||||
seo: { title: 'Overrides', description: 'Desc' },
|
||||
})
|
||||
}
|
||||
|
||||
describe('extras overrides', () => {
|
||||
it('allows overriding robots.txt content', () => {
|
||||
const page = makePage()
|
||||
const extras = buildExtrasForPage(page, {
|
||||
robotsText: 'User-agent: *\nDisallow: /private',
|
||||
})
|
||||
const robots = new TextDecoder().decode(extras['robots.txt'])
|
||||
expect(robots).toContain('Disallow: /private')
|
||||
})
|
||||
|
||||
it('allows overriding manifest fields (name, short_name, start_url, display, theme_color)', () => {
|
||||
const page = makePage()
|
||||
const extras = buildExtrasForPage(page, {
|
||||
manifest: {
|
||||
name: 'Custom Name',
|
||||
short_name: 'Custom',
|
||||
start_url: '/home',
|
||||
display: 'minimal-ui',
|
||||
theme_color: '#abcdef',
|
||||
},
|
||||
})
|
||||
const manifestRaw = new TextDecoder().decode(extras['site.webmanifest'])
|
||||
const manifest = JSON.parse(manifestRaw)
|
||||
expect(manifest.name).toBe('Custom Name')
|
||||
expect(manifest.short_name).toBe('Custom')
|
||||
expect(manifest.start_url).toBe('/home')
|
||||
expect(manifest.display).toBe('minimal-ui')
|
||||
expect(manifest.theme_color).toBe('#abcdef')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user