From 2caffe9950dde93ff22bafe99d60453e674a1dc8 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Sat, 15 Nov 2025 12:45:56 +0900 Subject: [PATCH] =?UTF-8?q?test(zip):=20Phase5=20-=20robots/manifest=20?= =?UTF-8?q?=EB=82=B4=EC=9A=A9=20=EA=B2=80=EC=A6=9D=20=EB=B0=8F=20ZIP=20?= =?UTF-8?q?=EB=B9=8C=EB=93=9C=20=EC=8A=A4=EB=AA=A8=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/exporter/zip.validation.phase5.test.ts | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/exporter/zip.validation.phase5.test.ts diff --git a/lib/exporter/zip.validation.phase5.test.ts b/lib/exporter/zip.validation.phase5.test.ts new file mode 100644 index 0000000..ba282ca --- /dev/null +++ b/lib/exporter/zip.validation.phase5.test.ts @@ -0,0 +1,39 @@ +import { describe, it, expect } from 'vitest' +import { buildZip } from '@/lib/exporter/zip' +import { exportPage } from '@/lib/exporter/html' +import { pageSchema, type Page } from '@/lib/schema/page' +import { buildExtrasForPage } from '@/lib/exporter/extras' + +function makePage(): Page { + return pageSchema.parse({ + title: 'ZIP Phase5', + 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('ZIP 검증 Phase5', () => { + it('robots.txt 베이스라인과 site.webmanifest JSON 파싱 검증', async () => { + const page = makePage() + const extras = buildExtrasForPage(page) + + // baseline robots + const robots = Buffer.from(extras['robots.txt']).toString('utf8') + expect(robots).toContain('User-agent: *') + + // manifest JSON parseable + const manifestStr = Buffer.from(extras['site.webmanifest']).toString('utf8') + const manifest = JSON.parse(manifestStr) + expect(manifest && typeof manifest === 'object').toBe(true) + expect(manifest.start_url).toBeDefined() + expect(manifest.display).toBeDefined() + + // ZIP build should succeed + const out = exportPage(page) + const zipBytes = await buildZip({ html: out.html, css: out.css, js: out.js, assets: {}, extras }) + expect(zipBytes.byteLength).toBeGreaterThan(0) + }) +})