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:
18
apps/portal/tests/setup.ts
Normal file
18
apps/portal/tests/setup.ts
Normal 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() }),
|
||||
}))
|
||||
Reference in New Issue
Block a user