34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { pageSchema, type Page } from '@/lib/schema/page'
|
|
import { exportPage } from '@/lib/exporter/html'
|
|
import { AssetManager } from '@/lib/assets/assetManager'
|
|
|
|
const makeLocalImagePage = async () => {
|
|
const am = new AssetManager({ maxBytes: 1024 * 1024, allowedExts: ['png'] })
|
|
const hero = await am.add({ name: 'hero.png', type: 'image/png', bytes: new Uint8Array([1,2,3]) })
|
|
const page: Page = pageSchema.parse({
|
|
title: 'Local Image',
|
|
locale: 'en',
|
|
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
|
|
sections: [
|
|
{
|
|
type: 'hero',
|
|
props: { heading: 'Hi', subheading: '', imageUrl: `local:${hero.originalName}` },
|
|
},
|
|
],
|
|
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
|
seo: { title: 'Local Image', description: 'd' },
|
|
})
|
|
return { am, page }
|
|
}
|
|
|
|
describe('HTML Exporter - asset rewrite', () => {
|
|
it('local: 프리픽스 이미지는 assets/<hash>.<ext>로 치환된다', async () => {
|
|
const { am, page } = await makeLocalImagePage()
|
|
const out = exportPage(page, { assetManager: am })
|
|
|
|
// assets 경로가 HTML 내 포함되어야 함
|
|
expect(out.html).toMatch(/assets\/[a-f0-9]{8}\.png/)
|
|
})
|
|
})
|