47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest'
|
|
import { render, screen, fireEvent } from '@testing-library/react'
|
|
import BuilderClientPage from '@/components/BuilderClientPage'
|
|
|
|
vi.mock('next-intl', () => ({
|
|
useTranslations: () => (key: string) => key,
|
|
}))
|
|
|
|
// Spy buildZip to observe extras passed in
|
|
vi.mock('@/lib/exporter/zip', async (orig) => {
|
|
const mod = await (orig as any)()
|
|
return {
|
|
...mod,
|
|
buildZip: vi.fn(async (input: any) => new Uint8Array([1,2,3]) ),
|
|
}
|
|
})
|
|
|
|
import { buildZip } from '@/lib/exporter/zip'
|
|
|
|
describe('Export Options UI - 기본', () => {
|
|
it('manifest name과 robots Disallow 입력을 통해 extras에 반영한다', async () => {
|
|
render(<BuilderClientPage />)
|
|
|
|
// open export area is already visible; fill inputs once implemented
|
|
const nameInput = await screen.findByLabelText('Manifest Name', { exact: false })
|
|
fireEvent.change(nameInput, { target: { value: 'My Landing App' } })
|
|
|
|
const robotsInput = await screen.findByLabelText('Robots Disallow', { exact: false })
|
|
fireEvent.change(robotsInput, { target: { value: '/secret\n/admin' } })
|
|
|
|
const btn = await screen.findByRole('button', { name: /builder.action.export/i })
|
|
await fireEvent.click(btn)
|
|
|
|
expect(buildZip).toHaveBeenCalled()
|
|
const arg = (buildZip as any).mock.calls[0][0]
|
|
expect(arg.extras).toBeTruthy()
|
|
const extras = arg.extras as Record<string, Uint8Array>
|
|
const robots = Buffer.from(extras['robots.txt']).toString('utf8')
|
|
expect(robots).toContain('Disallow: /secret')
|
|
expect(robots).toContain('Disallow: /admin')
|
|
|
|
const manifestStr = Buffer.from(extras['site.webmanifest']).toString('utf8')
|
|
const manifest = JSON.parse(manifestStr)
|
|
expect(manifest.name).toBe('My Landing App')
|
|
})
|
|
})
|