From 6bad4cc77c4f424d524b90fe6b1ac694ec291b70 Mon Sep 17 00:00:00 2001 From: aastha Date: Fri, 20 Dec 2024 15:06:06 +0530 Subject: [PATCH] Minor --- android/.idea/runConfigurations.xml | 9 +++- src/app/auth/sign-in/sign-in.page.html | 1 + .../dashboard/tasks/tasks-2.component.spec.ts | 41 +++++++++++------ .../tasks/tasks.component.setup.spec.ts | 4 +- .../fyle/dashboard/tasks/tasks.component.ts | 46 ++++++++----------- src/environments/environment.ts | 2 +- 6 files changed, 60 insertions(+), 43 deletions(-) diff --git a/android/.idea/runConfigurations.xml b/android/.idea/runConfigurations.xml index 797acea53e..16660f1d80 100644 --- a/android/.idea/runConfigurations.xml +++ b/android/.idea/runConfigurations.xml @@ -3,7 +3,14 @@ diff --git a/src/app/auth/sign-in/sign-in.page.html b/src/app/auth/sign-in/sign-in.page.html index d453b91a88..b67e510f3f 100644 --- a/src/app/auth/sign-in/sign-in.page.html +++ b/src/app/auth/sign-in/sign-in.page.html @@ -7,6 +7,7 @@ height="auto" onloadedmetadata="this.muted = true" oncanplay="this.play()" + poster="../../../assets/images/video-default-background.png" loop > diff --git a/src/app/fyle/dashboard/tasks/tasks-2.component.spec.ts b/src/app/fyle/dashboard/tasks/tasks-2.component.spec.ts index 5d9b781bfb..0c4d7f8a5f 100644 --- a/src/app/fyle/dashboard/tasks/tasks-2.component.spec.ts +++ b/src/app/fyle/dashboard/tasks/tasks-2.component.spec.ts @@ -54,6 +54,9 @@ import { By } from '@angular/platform-browser'; import { OrgUserSettingsService } from 'src/app/core/services/org-user-settings.service'; import { CorporateCreditCardExpenseService } from 'src/app/core/services/corporate-credit-card-expense.service'; import { OrgSettingsService } from 'src/app/core/services/org-settings.service'; +import { CardAddedComponent } from '../../manage-corporate-cards/card-added/card-added.component'; +import { orgSettingsPendingRestrictions } from 'src/app/core/mock-data/org-settings.data'; +import { orgUserSettingsData } from 'src/app/core/mock-data/org-user-settings.data'; export function TestCases2(getTestBed) { return describe('test case set 2', () => { @@ -112,6 +115,8 @@ export function TestCases2(getTestBed) { let addCardPopoverSpy: jasmine.SpyObj; popoverController.create.and.returnValues(Promise.resolve(addCardPopoverSpy)); orgSettingsService = TestBed.inject(OrgSettingsService) as jasmine.SpyObj; + networkService.isOnline.and.returnValue(of(true)); + networkService.connectivityWatcher.and.returnValue(null); })); describe('init():', () => { @@ -200,24 +205,16 @@ export function TestCases2(getTestBed) { }); }); - it('onAddCorporateCardClick(): should open card popover', fakeAsync(() => { - // Mock the observables - component.isVisaRTFEnabled$ = of(true); - component.isMastercardRTFEnabled$ = of(true); - component.isYodleeEnabled$ = of(true); - - // Mock the PopoverController + it('onAddCorporateCardClick(): should open card popover', () => { + orgSettingsService.get.and.returnValue(of(orgSettingsPendingRestrictions)); + orgUserSettingsService.get.and.returnValue(of(orgUserSettingsData)); const addCardPopoverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onDidDismiss']); addCardPopoverSpy.present.and.resolveTo(); addCardPopoverSpy.onDidDismiss.and.resolveTo({}); - popoverController.create.and.resolveTo(addCardPopoverSpy); - // Call the method + fixture.detectChanges(); component.onAddCorporateCardClick(); - tick(); - - // Assert popover creation expect(popoverController.create).toHaveBeenCalledOnceWith({ component: AddCorporateCardComponent, cssClass: 'fy-dialog-popover', @@ -227,8 +224,26 @@ export function TestCases2(getTestBed) { isYodleeEnabled: true, }, }); + }); - expect(addCardPopoverSpy.present).toHaveBeenCalledTimes(1); + it('handleEnrollmentSuccess(): should handle enrollment success and trigger subsequent actions', fakeAsync(() => { + corporateCreditCardExpenseService.clearCache.and.returnValue(of(null)); + + const mockPopover = { + present: jasmine.createSpy('present').and.resolveTo(), + onDidDismiss: jasmine.createSpy('onDidDismiss').and.resolveTo(), + }; + popoverController.create.and.resolveTo(mockPopover as any); + + component.handleEnrollmentSuccess(); + tick(); + + expect(corporateCreditCardExpenseService.clearCache).toHaveBeenCalled(); + expect(popoverController.create).toHaveBeenCalledWith({ + component: CardAddedComponent, + cssClass: 'pop-up-in-center', + }); + expect(mockPopover.present).toHaveBeenCalled(); })); it('onMobileNumberVerificationTaskClick(): should open opt in modal', fakeAsync(() => { diff --git a/src/app/fyle/dashboard/tasks/tasks.component.setup.spec.ts b/src/app/fyle/dashboard/tasks/tasks.component.setup.spec.ts index 548a9a02c7..a7ec9ab4ac 100644 --- a/src/app/fyle/dashboard/tasks/tasks.component.setup.spec.ts +++ b/src/app/fyle/dashboard/tasks/tasks.component.setup.spec.ts @@ -27,7 +27,7 @@ import { OrgService } from 'src/app/core/services/org.service'; import { OrgUserSettingsService } from 'src/app/core/services/org-user-settings.service'; import { CorporateCreditCardExpenseService } from 'src/app/core/services/corporate-credit-card-expense.service'; -describe('TasksComponent', () => { +fdescribe('TasksComponent', () => { const getTestBed = () => { const tasksServiceSpy = jasmine.createSpyObj('TasksService', [ 'getTasks', @@ -70,6 +70,7 @@ describe('TasksComponent', () => { const orgUserSettingsServiceSpy = jasmine.createSpyObj('OrgUserSettingsService', ['get']); const corporateCreditCardExpenseServiceSpy = jasmine.createSpyObj('CorporateCreditCardExpenseService', [ 'getCorporateCards', + 'clearCache', ]); const matSnackBarSpy = jasmine.createSpyObj('MatSnackBar', ['openFromComponent']); const snackbarPropertiesSpy = jasmine.createSpyObj('SnackbarPropertiesService', ['setSnackbarProperties']); @@ -86,7 +87,6 @@ describe('TasksComponent', () => { const popoverControllerSpy = jasmine.createSpyObj('PopoverController', ['create', 'onDidDismiss']); const networkServiceSpy = jasmine.createSpyObj('NetworkService', ['connectivityWatcher', 'isOnline']); - const addCardPopoverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onDidDismiss']); TestBed.configureTestingModule({ declarations: [TasksComponent], imports: [IonicModule.forRoot(), RouterTestingModule], diff --git a/src/app/fyle/dashboard/tasks/tasks.component.ts b/src/app/fyle/dashboard/tasks/tasks.component.ts index 3a1538b145..d059b9d261 100644 --- a/src/app/fyle/dashboard/tasks/tasks.component.ts +++ b/src/app/fyle/dashboard/tasks/tasks.component.ts @@ -105,32 +105,6 @@ export class TasksComponent implements OnInit { ngOnInit(): void { this.setupNetworkWatcher(); - - this.isVisaRTFEnabled$ = this.orgSettingsService - .get() - .pipe( - map( - (orgSettings) => orgSettings.visa_enrollment_settings.allowed && orgSettings.visa_enrollment_settings.enabled - ) - ); - - this.isMastercardRTFEnabled$ = this.orgSettingsService - .get() - .pipe( - map( - (orgSettings) => - orgSettings.mastercard_enrollment_settings.allowed && orgSettings.mastercard_enrollment_settings.enabled - ) - ); - - this.isYodleeEnabled$ = forkJoin([this.orgSettingsService.get(), this.orgUserSettingsService.get()]).pipe( - map( - ([orgSettings, orgUserSettings]) => - orgSettings.bank_data_aggregation_settings.allowed && - orgSettings.bank_data_aggregation_settings.enabled && - orgUserSettings.bank_data_aggregation_settings.enabled - ) - ); } trackTasks(tasks: DashboardTask[]): void { @@ -491,6 +465,26 @@ export class TasksComponent implements OnInit { } onAddCorporateCardClick(): void { + const orgSettings$ = this.orgSettingsService.get(); + this.isVisaRTFEnabled$ = orgSettings$.pipe( + map((orgSettings) => orgSettings.visa_enrollment_settings.allowed && orgSettings.visa_enrollment_settings.enabled) + ); + + this.isMastercardRTFEnabled$ = orgSettings$.pipe( + map( + (orgSettings) => + orgSettings.mastercard_enrollment_settings.allowed && orgSettings.mastercard_enrollment_settings.enabled + ) + ); + + this.isYodleeEnabled$ = forkJoin([orgSettings$, this.orgUserSettingsService.get()]).pipe( + map( + ([orgSettings, orgUserSettings]) => + orgSettings.bank_data_aggregation_settings.allowed && + orgSettings.bank_data_aggregation_settings.enabled && + orgUserSettings.bank_data_aggregation_settings.enabled + ) + ); forkJoin([this.isVisaRTFEnabled$, this.isMastercardRTFEnabled$, this.isYodleeEnabled$]).subscribe( async ([isVisaRTFEnabled, isMastercardRTFEnabled, isYodleeEnabled]) => { const addCorporateCardPopover = await this.popoverController.create({ diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 94ec5fe27e..668c511f4c 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -7,7 +7,7 @@ export const environment = { NAME: '', CLUSTER_DOMAIN: '', ROOT_URL: '', - ROUTER_API_ENDPOINT: '', + ROUTER_API_ENDPOINT: 'https://accounts.fyle.tech', IP_FIND_KEY: '', ANDROID_CLIENT_ID: '', GOOGLE_MAPS_API_KEY: '',