Update tests to handle domain verification

This commit is contained in:
Dries Augustyns
2025-12-01 15:36:31 +01:00
parent e893960a85
commit 54fde9675c
2 changed files with 28 additions and 0 deletions
@@ -22,6 +22,13 @@ describe('EmailService', () => {
const contact = await factories.createContact({projectId});
contactId = contact.id;
// Create a verified domain for the project (required for sending emails)
await factories.createDomain({
projectId,
domain: 'example.com',
verified: true,
});
// Mock successful SES send by default
vi.mocked(sendRawEmail).mockResolvedValue({
messageId: 'ses-message-123',
+21
View File
@@ -86,6 +86,13 @@ export interface WorkflowStepFactoryOptions {
templateId?: string | null;
}
export interface DomainFactoryOptions {
projectId: string;
domain?: string;
verified?: boolean;
dkimTokens?: unknown;
}
export class TestFactories {
private prisma: PrismaClient;
@@ -545,6 +552,20 @@ export class TestFactories {
},
});
}
/**
* Create a domain
*/
async createDomain(options: DomainFactoryOptions) {
return this.prisma.domain.create({
data: {
projectId: options.projectId,
domain: options.domain || 'example.com',
verified: options.verified ?? true,
dkimTokens: options.dkimTokens || null,
},
});
}
}
// Export lazy-initialized singleton instance