46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
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',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
|
sections: [ { type: 'hero', props: { heading: 'Hello', subheading: 'World', imageUrl: 'https://img/h.png' } } ],
|
|
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
|
seo: { title: 't', description: 'd' },
|
|
})
|
|
}
|
|
|
|
describe('extras 오버라이드', () => {
|
|
it('robots.txt Disallow 오버라이드가 반영된다', () => {
|
|
const page = makePage()
|
|
const extras = buildExtrasForPage(page, { robotsText: 'User-agent: *\nDisallow: /admin\nDisallow: /private' })
|
|
const robots = Buffer.from(extras['robots.txt']).toString('utf8')
|
|
expect(robots).toContain('User-agent: *')
|
|
expect(robots).toContain('Disallow: /admin')
|
|
expect(robots).toContain('Disallow: /private')
|
|
})
|
|
|
|
it('manifest 필드 오버라이드(name/short_name/start_url/display/theme_color)가 반영된다', () => {
|
|
const page = makePage()
|
|
const extras = buildExtrasForPage(page, {
|
|
manifest: {
|
|
name: 'My App',
|
|
short_name: 'MyApp',
|
|
start_url: '/start',
|
|
display: 'minimal-ui',
|
|
theme_color: '#123abc',
|
|
},
|
|
})
|
|
const manifestStr = Buffer.from(extras['site.webmanifest']).toString('utf8')
|
|
const manifest = JSON.parse(manifestStr)
|
|
expect(manifest.name).toBe('My App')
|
|
expect(manifest.short_name).toBe('MyApp')
|
|
expect(manifest.start_url).toBe('/start')
|
|
expect(manifest.display).toBe('minimal-ui')
|
|
expect(manifest.theme_color).toBe('#123abc')
|
|
})
|
|
})
|