d7fb7b7a7b
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
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();
|
|
});
|
|
});
|