Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
bistaastha committed Jan 10, 2025
1 parent 811414b commit d57e521
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 77 deletions.
33 changes: 28 additions & 5 deletions src/app/auth/switch-org/switch-org.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const roles = ['OWNER', 'USER', 'FYLER'];
const email = '[email protected]';
const org_id = 'orNVthTo2Zyo';

describe('SwitchOrgPage', () => {
fdescribe('SwitchOrgPage', () => {
let component: SwitchOrgPage;
let fixture: ComponentFixture<SwitchOrgPage>;
let loaderService: jasmine.SpyObj<LoaderService>;
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('SwitchOrgPage', () => {
const deepLinkServiceSpy = jasmine.createSpyObj('DeepLinkService', ['getExpenseRoute']);
const ldSpy = jasmine.createSpyObj('LaunchDarklyService', ['initializeUser']);
const orgSettingsServiceSpy = jasmine.createSpyObj('OrgSettingsService', ['get']);
const spenderOnboardingServiceSpy = jasmine.createSpyObj('SpenderOnboardingSettings', ['getOnboardingSettings']);
const spenderOnboardingServiceSpy = jasmine.createSpyObj('SpenderOnboardingSettings', ['getOnboardingStatus']);

TestBed.configureTestingModule({
declarations: [SwitchOrgPage, ActiveOrgCardComponent, OrgCardComponent, FyZeroStateComponent],
Expand Down Expand Up @@ -280,7 +280,10 @@ describe('SwitchOrgPage', () => {
component.searchOrgsInput = fixture.debugElement.query(By.css('.smartlook-show'));
component.contentRef = fixture.debugElement.query(By.css('.switch-org__content-container__content-block'));
fixture.detectChanges();
spyOn(component, 'navigateToDashboard').and.callThrough();
spenderOnboardingService.getOnboardingStatus.and.returnValue(
of({ ...onboardingStatusData, state: OnboardingState.COMPLETED })
);
orgSettingsService.get.and.returnValue(of(orgSettingsData));
}));

it('should create', () => {
Expand Down Expand Up @@ -568,6 +571,16 @@ describe('SwitchOrgPage', () => {
}));
});

it('navigateToDashboard(): should navigate to spender onboarding when onboarding status is not complete', fakeAsync(() => {
spenderOnboardingService.getOnboardingStatus.and.returnValue(
of({ ...onboardingStatusData, state: OnboardingState.YET_TO_START })
);
orgSettingsService.get.and.returnValue(of(orgSettingsData));
component.navigateToDashboard();
tick();
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'spender_onboarding']);
}));

describe('navigateToSetupPage():', () => {
it('should navigate to setup page if org the roles has OWNER', () => {
component.navigateToSetupPage(['OWNER']);
Expand All @@ -592,7 +605,12 @@ describe('SwitchOrgPage', () => {
.pipe(
finalize(() => {
expect(loaderService.hideLoader).toHaveBeenCalledTimes(1);
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_dashboard']);
expect(router.navigate).toHaveBeenCalledOnceWith([
'/',
'enterprise',
'my_dashboard',
{ openSMSOptInDialog: undefined },
]);
})
)
.subscribe((res) => {
Expand Down Expand Up @@ -675,7 +693,12 @@ describe('SwitchOrgPage', () => {
tick();
component.navigateBasedOnUserStatus(config).subscribe((res) => {
expect(res).toBeNull();
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_dashboard']);
expect(router.navigate).toHaveBeenCalledOnceWith([
'/',
'enterprise',
'my_dashboard',
{ openSMSOptInDialog: undefined },
]);
});
}));

Expand Down
3 changes: 2 additions & 1 deletion src/app/auth/switch-org/switch-org.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ export class SwitchOrgPage implements OnInit, AfterViewChecked {
forkJoin([this.orgSettingsService.get(), this.spenderOnboardingService.getOnboardingStatus()]).subscribe(
([orgSettings, onboardingStatus]) => {
if (
(orgSettings.visa_enrollment_settings.enabled ||
(orgSettings.corporate_credit_card_settings.enabled ||
orgSettings.visa_enrollment_settings.enabled ||
orgSettings.mastercard_enrollment_settings.enabled ||
orgSettings.amex_feed_enrollment_settings.enabled) &&
onboardingStatus.state !== OnboardingState.COMPLETED
Expand Down
Loading

0 comments on commit d57e521

Please sign in to comment.