Files
twenty/packages/twenty-website/src/partner-application/partner-application-request-schema.test.ts
T
Abdullah. 569d887d1e [Website] Cut over to the rebuilt site (#21825)
Renaming the package so any further PRs directed to the website are
targeted to the reworked code instead of diverging. Once merged, I will
start preparing this for deployment to dev to test before releasing to
prod. Any improvements will also be applied to this package.

I avoided making significant changes to API routes so nothing breaks,
but will test it thoroughly today to confirm. That said, everything is
ported - double checked.

Big diff PR, impossible to review, but last one! No more rebuilds.
2026-06-19 10:22:46 +02:00

101 lines
2.6 KiB
TypeScript

import { partnerApplicationRequestSchema } from './partner-application-request-schema';
const minimalValid = {
name: 'Ada Lovelace',
email: 'ada@example.com',
company: 'Analytical Engines Ltd',
website: 'https://analyticalengines.example',
city: 'London',
hourlyRate: 150,
projectBudgetMin: 5000,
};
const fullValid = {
...minimalValid,
linkedin: 'https://www.linkedin.com/in/ada',
country: 'UNITED_KINGDOM',
languages: ['ENGLISH', 'FRENCH'],
typeOfTeam: 'SOLO',
partnerScope: ['ADVISORY', 'SOLUTIONING'],
skills: ['React', 'TypeScript'],
applicationNotes: 'Workspace https://app.twenty.com/ws/ada · refs: Acme',
calendarLink: 'https://cal.com/ada',
};
describe('partnerApplicationRequestSchema', () => {
it('accepts the minimal required payload', () => {
expect(
partnerApplicationRequestSchema.safeParse(minimalValid).success,
).toBe(true);
});
it('accepts the full payload', () => {
expect(partnerApplicationRequestSchema.safeParse(fullValid).success).toBe(
true,
);
});
it('rejects an unknown country enum value', () => {
expect(
partnerApplicationRequestSchema.safeParse({
...minimalValid,
country: 'ATLANTIS',
}).success,
).toBe(false);
});
it('rejects an unknown scope enum value', () => {
expect(
partnerApplicationRequestSchema.safeParse({
...minimalValid,
partnerScope: ['NOPE'],
}).success,
).toBe(false);
});
it('rejects unknown top-level keys (strictObject)', () => {
expect(
partnerApplicationRequestSchema.safeParse({
...minimalValid,
countryOther: 'Republic of Examples',
}).success,
).toBe(false);
});
it('rejects an invalid email', () => {
expect(
partnerApplicationRequestSchema.safeParse({
...minimalValid,
email: 'not-an-email',
}).success,
).toBe(false);
});
it('rejects a missing required field', () => {
expect(
partnerApplicationRequestSchema.safeParse({ email: 'ada@example.com' })
.success,
).toBe(false);
});
it('rejects when a newly-required field is missing', () => {
for (const field of ['website', 'city', 'hourlyRate', 'projectBudgetMin']) {
const withoutField = Object.fromEntries(
Object.entries(minimalValid).filter(([key]) => key !== field),
);
expect(
partnerApplicationRequestSchema.safeParse(withoutField).success,
).toBe(false);
}
});
it('rejects a negative hourly rate', () => {
expect(
partnerApplicationRequestSchema.safeParse({
...minimalValid,
hourlyRate: -5,
}).success,
).toBe(false);
});
});