@@ -119,8 +119,12 @@ describe('Newsletter Confirmation API - GET /api/newsletter/confirm', () => {
119119 expect ( supabaseFromMock ) . toHaveBeenCalledWith ( 'consent_records' )
120120 expect ( supabaseQueryBuilder . update ) . toHaveBeenCalledWith ( { verified : true } )
121121
122- // Verify welcome email was sent
123- expect ( mockSendWelcomeEmail ) . toHaveBeenCalledWith ( 'test@example.com' , 'John' )
122+ // Verify welcome email was sent (force mock disabled by default)
123+ expect ( mockSendWelcomeEmail ) . toHaveBeenCalledWith (
124+ 'test@example.com' ,
125+ 'John' ,
126+ expect . objectContaining ( { forceMockResend : false } ) ,
127+ )
124128
125129 expect ( mockSubscribeToConvertKit ) . toHaveBeenCalledWith (
126130 expect . objectContaining ( { email : 'test@example.com' } ) ,
@@ -142,9 +146,10 @@ describe('Newsletter Confirmation API - GET /api/newsletter/confirm', () => {
142146 const response = await GET ( createRequestContext ( 'http://localhost/api/newsletter/confirm?token=expired-token' ) )
143147 const body = await response . json ( )
144148
145- expect ( response . status ) . toBe ( 400 )
146- expect ( body . error ) . toBeDefined ( )
147- expect ( body . error . message ) . toContain ( 'expired' )
149+ expect ( response . status ) . toBe ( 200 )
150+ expect ( body . success ) . toBe ( false )
151+ expect ( body . status ) . toBe ( 'expired' )
152+ expect ( body . message ) . toContain ( 'expired' )
148153 } )
149154
150155 it ( 'should handle subscription without firstName' , async ( ) => {
@@ -166,7 +171,11 @@ describe('Newsletter Confirmation API - GET /api/newsletter/confirm', () => {
166171
167172 expect ( response . status ) . toBe ( 200 )
168173 expect ( data . success ) . toBe ( true )
169- expect ( mockSendWelcomeEmail ) . toHaveBeenCalledWith ( 'test@example.com' , undefined )
174+ expect ( mockSendWelcomeEmail ) . toHaveBeenCalledWith (
175+ 'test@example.com' ,
176+ undefined ,
177+ expect . objectContaining ( { forceMockResend : false } ) ,
178+ )
170179 } )
171180
172181 it ( 'should handle subscription without ipAddress' , async ( ) => {
0 commit comments