test(export-options): Export 옵션 최소 UI 및 extras 연동 TDD 추가
Auto PR / open-pr (push) Successful in 22s
Auto Label PR / add-automerge-label (pull_request) Successful in 7s
CI / test (pull_request) Successful in 58s

This commit is contained in:
2025-11-15 12:53:28 +09:00
parent 2caffe9950
commit 0e09647f2f
2 changed files with 102 additions and 4 deletions
+46
View File
@@ -0,0 +1,46 @@
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')
})
})