Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
bistaastha committed Dec 20, 2024
1 parent df00248 commit 6bad4cc
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 43 deletions.
9 changes: 8 additions & 1 deletion android/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/app/auth/sign-in/sign-in.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
height="auto"
onloadedmetadata="this.muted = true"
oncanplay="this.play()"
poster="../../../assets/images/video-default-background.png"
loop
>
<source src="/assets/videos/mobile-onboarding.mp4" type="video/mp4" />
Expand Down
41 changes: 28 additions & 13 deletions src/app/fyle/dashboard/tasks/tasks-2.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -112,6 +115,8 @@ export function TestCases2(getTestBed) {
let addCardPopoverSpy: jasmine.SpyObj<HTMLIonPopoverElement>;
popoverController.create.and.returnValues(Promise.resolve(addCardPopoverSpy));
orgSettingsService = TestBed.inject(OrgSettingsService) as jasmine.SpyObj<OrgSettingsService>;
networkService.isOnline.and.returnValue(of(true));
networkService.connectivityWatcher.and.returnValue(null);
}));

describe('init():', () => {
Expand Down Expand Up @@ -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',
Expand All @@ -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(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/fyle/dashboard/tasks/tasks.component.setup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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']);
Expand All @@ -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],
Expand Down
46 changes: 20 additions & 26 deletions src/app/fyle/dashboard/tasks/tasks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down

0 comments on commit 6bad4cc

Please sign in to comment.