Update tests to handle domain verification
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user