auto: PR for feat/zip-validation-phase5 #31

Merged
jaybe merged 1 commits from feat/zip-validation-phase5 into main 2025-11-14 16:43:39 +00:00
Showing only changes of commit 7a73589ac4 - Show all commits
@@ -0,0 +1,40 @@
import { describe, it, expect } from 'vitest'
import JSZip from 'jszip'
import { exportPage } from '@/lib/exporter/html'
import { buildZip } from '@/lib/exporter/zip'
import { buildExtrasForPage } from '@/lib/exporter/extras'
import { pageSchema, type Page } from '@/lib/schema/page'
function makePage(): Page {
return pageSchema.parse({
title: 'Phase5',
locale: 'en',
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
sections: [],
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
seo: { title: 't', description: 'd' },
})
}
describe('Export ZIP 검증 강화 5차: extras MIME/내용 검증', () => {
it('robots.txt는 텍스트이고, site.webmanifest는 유효한 JSON이다', async () => {
const page = makePage()
const out = exportPage(page)
const extras = buildExtrasForPage(page)
const zipBytes = await buildZip({ html: out.html, css: out.css, js: out.js, assets: {}, extras })
const zip = await JSZip.loadAsync(zipBytes)
// robots.txt 존재 및 텍스트 확인
expect(Object.keys(zip.files)).toContain('robots.txt')
const robots = await zip.files['robots.txt'].async('string')
expect(robots).toMatch(/User-agent: \*/) // baseline
// site.webmanifest 존재 및 JSON 파싱 가능
expect(Object.keys(zip.files)).toContain('site.webmanifest')
const manifestStr = await zip.files['site.webmanifest'].async('string')
const parsed = JSON.parse(manifestStr)
expect(parsed.start_url).toBe('/')
expect(parsed.display).toBe('standalone')
})
})