test(portal): add Vitest setup and public-form tests

Introduces vitest config, jsdom setup, and first suites covering
FieldRenderer dispatch and useConditionalLogic evaluation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 17:21:04 +02:00
parent 4074dce402
commit b159fdcc26
4 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { vi } from 'vitest'
// Deterministic idempotency-key generation for useFormDraft tests.
if (!globalThis.crypto) {
;(globalThis as { crypto: Crypto }).crypto = {
randomUUID: () => '00000000-0000-4000-8000-000000000000',
getRandomValues: (buf: Uint8Array) => {
for (let i = 0; i < buf.length; i++) buf[i] = 0
return buf
},
} as unknown as Crypto
}
// Suppress Vue-router usage in isolated composable tests.
vi.mock('vue-router', () => ({
useRoute: () => ({ params: {}, query: {} }),
useRouter: () => ({ push: vi.fn(), replace: vi.fn() }),
}))