Ship VMID 7811 API (assistance, contact, Stripe checkout), wire donate and forms to API with accessible success UI, static LCP shell with deferred React mount, and perf gate tooling (P0 72/2600ms; world-class 85/2500ms tracked separately). Co-authored-by: Cursor <[email protected]>
31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
import { describe, it } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
|
|
/** Inline validation mirror — keep in sync with server.js validateAssistance */
|
|
function validateAssistance(body) {
|
|
const errors = []
|
|
if (!body?.requestType) errors.push('requestType required')
|
|
if (!body?.studentInfo?.firstName?.trim()) errors.push('studentInfo.firstName required')
|
|
if (!body?.studentInfo?.lastName?.trim()) errors.push('studentInfo.lastName required')
|
|
if (!body?.studentInfo?.school?.trim()) errors.push('studentInfo.school required')
|
|
if (!body?.contactInfo?.parentName?.trim()) errors.push('contactInfo.parentName required')
|
|
if (!body?.contactInfo?.phone?.trim()) errors.push('contactInfo.phone required')
|
|
if (!body?.contactInfo?.email?.trim()) errors.push('contactInfo.email required')
|
|
if (!body?.contactInfo?.relationship?.trim()) errors.push('contactInfo.relationship required')
|
|
if (!body?.details?.trim()) errors.push('details required')
|
|
if (body?.website) errors.push('spam detected')
|
|
return errors
|
|
}
|
|
|
|
describe('assistance validation shape', () => {
|
|
it('requires core fields', () => {
|
|
const errors = validateAssistance({})
|
|
assert.ok(errors.length > 0)
|
|
})
|
|
|
|
it('rejects honeypot', () => {
|
|
const errors = validateAssistance({ website: 'spam' })
|
|
assert.ok(errors.includes('spam detected'))
|
|
})
|
|
})
|