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')) }) })