@@ -9,6 +9,7 @@ const mocks = vi.hoisted(() => ({
99 sgidUserInfo : vi . fn ( ) ,
1010 setAuthCookie : vi . fn ( ) ,
1111 getOrCreateUser : vi . fn ( ) ,
12+ sendOnboardingEmail : vi . fn ( ) ,
1213 updateLastLogin : vi . fn ( ) ,
1314 isWhitelistedEmail : vi . fn ( ) ,
1415 logError : vi . fn ( ) ,
@@ -45,6 +46,7 @@ vi.mock('@opengovsg/sgid-client', () => ({
4546vi . mock ( '@/helpers/auth' , ( ) => ( {
4647 setAuthCookie : mocks . setAuthCookie ,
4748 getOrCreateUser : mocks . getOrCreateUser ,
49+ sendOnboardingEmail : mocks . sendOnboardingEmail ,
4850 updateLastLogin : mocks . updateLastLogin ,
4951} ) )
5052
@@ -91,6 +93,7 @@ describe('Login with SGID', () => {
9193 expect ( mocks . getOrCreateUser ) . toHaveBeenCalledWith (
92949395 )
96+ expect ( mocks . sendOnboardingEmail ) . toHaveBeenCalledWith ( 'abc-def' )
9497 expect ( mocks . updateLastLogin ) . toHaveBeenCalledWith ( 'abc-def' )
9598 expect ( mocks . setAuthCookie ) . toHaveBeenCalledWith ( expect . anything ( ) , {
9699 userId : 'abc-def' ,
@@ -142,6 +145,7 @@ describe('Login with SGID', () => {
142145 const result = await loginWithSgid ( null , STUB_PARAMS , STUB_CONTEXT )
143146
144147 expect ( mocks . getOrCreateUser ) . not . toBeCalled ( )
148+ expect ( mocks . sendOnboardingEmail ) . not . toBeCalled ( )
145149 expect ( mocks . updateLastLogin ) . not . toBeCalled ( )
146150 expect ( mocks . setAuthCookie ) . not . toBeCalled ( )
147151 expect ( result . publicOfficerEmployments ) . toEqual ( [ ] )
@@ -180,6 +184,7 @@ describe('Login with SGID', () => {
180184 const result = await loginWithSgid ( null , STUB_PARAMS , STUB_CONTEXT )
181185
182186 expect ( mocks . getOrCreateUser ) . toHaveBeenCalledWith ( '[email protected] ' ) 187+ expect ( mocks . sendOnboardingEmail ) . toHaveBeenCalledWith ( 'abc-def' )
183188 expect ( mocks . updateLastLogin ) . toHaveBeenCalledWith ( 'abc-def' )
184189 expect ( mocks . setAuthCookie ) . toHaveBeenCalledWith ( expect . anything ( ) , {
185190 userId : 'abc-def' ,
@@ -259,6 +264,7 @@ describe('Login with SGID', () => {
259264 } ,
260265 )
261266 expect ( mocks . getOrCreateUser ) . not . toBeCalled ( )
267+ expect ( mocks . sendOnboardingEmail ) . not . toBeCalled ( )
262268 expect ( mocks . updateLastLogin ) . not . toBeCalled ( )
263269 expect ( mocks . setAuthCookie ) . not . toBeCalled ( )
264270 } )
@@ -276,6 +282,7 @@ describe('Login with SGID', () => {
276282 event : 'sgid-login-failed-user-info' ,
277283 } )
278284 expect ( mocks . getOrCreateUser ) . not . toBeCalled ( )
285+ expect ( mocks . sendOnboardingEmail ) . not . toBeCalled ( )
279286 expect ( mocks . updateLastLogin ) . not . toBeCalled ( )
280287 expect ( mocks . setAuthCookie ) . not . toBeCalled ( )
281288 } )
0 commit comments