@@ -15,7 +15,7 @@ import EmailDelivery from "../model/email-delivery";
1515import * as queries from "../queries" ;
1616import * as mail from "../../mail" ;
1717import { AdminSequence , InternalUser } from "@courselit/common-logic" ;
18- import { jwtUtils } from "@courselit/utils" ;
18+ import { getEmailFrom , jwtUtils } from "@courselit/utils" ;
1919import { getUnsubLink } from "../../utils/get-unsub-link" ;
2020import { getSiteUrl } from "../../utils/get-site-url" ;
2121import { sequenceBounceLimit } from "../../constants" ;
@@ -77,6 +77,9 @@ jest.mock("liquidjs", () => {
7777const mockedSendMail = mail . sendMail as jest . MockedFunction <
7878 typeof mail . sendMail
7979> ;
80+ const mockedGetEmailFrom = getEmailFrom as jest . MockedFunction <
81+ typeof getEmailFrom
82+ > ;
8083const mockedJwtUtils = jwtUtils as jest . Mocked < typeof jwtUtils > ;
8184const mockedGetUnsubLink = getUnsubLink as jest . MockedFunction <
8285 typeof getUnsubLink
@@ -100,6 +103,7 @@ describe("processOngoingSequence", () => {
100103 process . env . PROTOCOL = "https" ;
101104 process . env . DOMAIN = "test.com" ;
102105 process . env . NODE_ENV = "test" ;
106+ process . env . EMAIL_FROM = "verified-sender@example.com" ;
103107
104108 // Create test domain
105109 testDomain = await ( DomainModel . create as any ) ( {
@@ -265,6 +269,9 @@ describe("processOngoingSequence", () => {
265269 mockedGetUnsubLink . mockReturnValue (
266270 "https://test.com/api/unsubscribe/unsub-token-123" ,
267271 ) ;
272+ mockedGetEmailFrom . mockImplementation (
273+ ( { name, email } ) => `${ name } <${ email } >` ,
274+ ) ;
268275 mockedJwtUtils . generateToken = jest . fn ( ) . mockReturnValue ( "test-token" ) ;
269276 // renderEmailToHtml is not mocked - we test the real email formatting
270277 mockedSendMail . mockResolvedValue ( undefined ) ;
@@ -466,7 +473,9 @@ describe("processOngoingSequence", () => {
466473 // Verify email was sent
467474 expect ( mockedSendMail ) . toHaveBeenCalledWith (
468475 expect . objectContaining ( {
469- from : expect . stringContaining ( "queue-creator@example.com" ) ,
476+ from : expect . stringContaining (
477+ "verified-sender@example.com" ,
478+ ) ,
470479 to : "queue-user@example.com" ,
471480 subject : "First Email" ,
472481 html : expect . any ( String ) ,
0 commit comments