-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from PermanentOrg/PER-9396-ensure-emails-are-…
…sent PEr-9396 Send the email to mixpanel
- Loading branch information
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* @format */ | ||
import { CookieService } from 'ngx-cookie-service'; | ||
import { TestBed, inject } from '@angular/core/testing'; | ||
import { Router } from '@angular/router'; | ||
import { Shallow } from 'shallow-render'; | ||
|
@@ -67,6 +68,33 @@ describe('AccountService', () => { | |
observer.complete(); | ||
}); | ||
}, | ||
logIn: ( | ||
email: string, | ||
password: string, | ||
rememberMe: boolean, | ||
keepLoggedIn: boolean | ||
) => { | ||
return new Observable((observer) => { | ||
observer.next( | ||
new AuthResponse({ | ||
isSuccessful: true, | ||
Results: [ | ||
{ | ||
data: [ | ||
{ | ||
AccountVO: { | ||
primaryEmail: '[email protected]', | ||
fullName: 'Test User', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}) | ||
); | ||
observer.complete(); | ||
}); | ||
}, | ||
}, | ||
}) | ||
.mock(Router, { | ||
|
@@ -89,7 +117,8 @@ describe('AccountService', () => { | |
}) | ||
.mock(EditService, { | ||
deleteItems: (items: any[]) => Promise.resolve(true), | ||
}); | ||
}) | ||
.mock(CookieService, { set: (key: string, value: string) => {} }); | ||
}); | ||
|
||
it('should be created', () => { | ||
|
@@ -137,6 +166,7 @@ describe('AccountService', () => { | |
|
||
it('should handle successful email verification', async () => { | ||
const { instance } = shallow.createService(); | ||
const trackerSpy = spyOn(instance, 'trackAuthWithMixpanel'); | ||
|
||
const account = new AccountVO({ | ||
primaryEmail: '[email protected]', | ||
|
@@ -150,10 +180,12 @@ describe('AccountService', () => { | |
await instance.verifyEmail('sampleToken'); | ||
expect(instance.getAccount().emailStatus).toBe('status.auth.verified'); | ||
expect(instance.getAccount().keepLoggedIn).toBeTrue(); | ||
expect(trackerSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should handle successful phone verification', async () => { | ||
const { instance } = shallow.createService(); | ||
const trackerSpy = spyOn(instance, 'trackAuthWithMixpanel'); | ||
|
||
const account = new AccountVO({ | ||
primaryEmail: '[email protected]', | ||
|
@@ -167,6 +199,7 @@ describe('AccountService', () => { | |
await instance.verifyEmail('sampleToken'); | ||
expect(instance.getAccount().phoneStatus).toBe('status.auth.verified'); | ||
expect(instance.getAccount().keepLoggedIn).toBeTrue(); | ||
expect(trackerSpy).toHaveBeenCalled(); | ||
}); | ||
it('should update the account storage when a file is uploaded successfully', async () => { | ||
const { instance, inject } = shallow.createService(); | ||
|
@@ -182,6 +215,39 @@ describe('AccountService', () => { | |
await instance.deductAccountStorage(200); | ||
expect(instance.getAccount().spaceLeft).toEqual(99800); | ||
}); | ||
|
||
it('should send the account data to mixpanel after signing up', async () => { | ||
const { instance, inject } = shallow.createService(); | ||
const apiService = inject(ApiService); | ||
const trackerSpy = spyOn(instance, 'trackAuthWithMixpanel'); | ||
const account = await instance.signUp( | ||
'[email protected]', | ||
'Test User', | ||
'password123', | ||
'password123', | ||
true, | ||
true, | ||
'', | ||
'', | ||
true | ||
); | ||
|
||
expect(trackerSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should send the account data to mixpanel after logging in', async () => { | ||
const { instance, inject } = shallow.createService(); | ||
const apiService = inject(ApiService); | ||
const trackerSpy = spyOn(instance, 'trackAuthWithMixpanel'); | ||
const account = await instance.logIn( | ||
'[email protected]', | ||
'password123', | ||
true, | ||
true | ||
); | ||
|
||
expect(trackerSpy).toHaveBeenCalled(); | ||
}); | ||
it('should add storage back after deleting an item', async () => { | ||
const { instance, inject } = shallow.createService(); | ||
const editService = inject(EditService); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters