From 87578099285b228621be2568ee79985165a3bc56 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Sat, 15 Nov 2025 12:44:41 +0900 Subject: [PATCH] =?UTF-8?q?test(extras):=20robots/manifest=20=EC=98=A4?= =?UTF-8?q?=EB=B2=84=EB=9D=BC=EC=9D=B4=EB=93=9C=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/exporter/extras.overrides.test.ts | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lib/exporter/extras.overrides.test.ts diff --git a/lib/exporter/extras.overrides.test.ts b/lib/exporter/extras.overrides.test.ts new file mode 100644 index 0000000..367dc06 --- /dev/null +++ b/lib/exporter/extras.overrides.test.ts @@ -0,0 +1,45 @@ +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') + }) +})