phase 16 implementation
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { demoLeadSchema, demoSubmissionEnvelopeSchema, fleetSizeValues } from '@/lib/demo/schema';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const validLead = {
|
||||
fullName: ' Ada Example ',
|
||||
workEmail: ' ADA@EXAMPLE.TEST ',
|
||||
company: ' Rental Test Labs ',
|
||||
fleetSize: '25-49',
|
||||
market: '',
|
||||
preferredLanguage: 'en',
|
||||
message: ' Reservation workflow ',
|
||||
idempotencyKey: '154249a8-0c3c-4ad8-bda6-91b1ffb361a8',
|
||||
source: 'hero',
|
||||
} as const;
|
||||
|
||||
describe('demo lead schema', () => {
|
||||
it('normalizes approved fields without adding sales-enrichment data', () => {
|
||||
const result = demoLeadSchema.parse(validLead);
|
||||
expect(result).toEqual({
|
||||
...validLead,
|
||||
fullName: 'Ada Example',
|
||||
workEmail: 'ada@example.test',
|
||||
company: 'Rental Test Labs',
|
||||
market: undefined,
|
||||
message: 'Reservation workflow',
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects unknown fields and unsupported fleet sizes', () => {
|
||||
expect(() => demoLeadSchema.parse({ ...validLead, phone: '+1 555 0100' })).toThrow();
|
||||
expect(() => demoLeadSchema.parse({ ...validLead, fleetSize: '5000+' })).toThrow();
|
||||
});
|
||||
|
||||
it('keeps the Phase 9 fleet ranges stable', () => {
|
||||
expect(fleetSizeValues).toEqual(['1-9', '10-24', '25-49', '50-99', '100-249', '250+']);
|
||||
});
|
||||
|
||||
it('rejects transport fields outside the approved envelope', () => {
|
||||
expect(() =>
|
||||
demoSubmissionEnvelopeSchema.parse({
|
||||
lead: validLead,
|
||||
guard: { honeypot: '', startedAtMs: 1, fingerprint: 'nope' },
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user