diff --git a/android/variables.gradle b/android/variables.gradle index 7224787b87..0fc8f45b1f 100644 --- a/android/variables.gradle +++ b/android/variables.gradle @@ -7,7 +7,6 @@ ext { androidxMaterialVersion = '1.6.1' androidxBrowserVersion = '1.4.0' androidxExifInterfaceVersion = '1.3.3' - firebaseMessagingVersion = '23.0.5' playServicesLocationVersion = '20.0.0' junitVersion = '4.13.2' androidxJunitVersion = '1.1.3' diff --git a/hooks/utils/google-credentials-android.js b/hooks/utils/google-credentials-android.js index de733d5d0b..64e453ca11 100644 --- a/hooks/utils/google-credentials-android.js +++ b/hooks/utils/google-credentials-android.js @@ -4,7 +4,6 @@ module.exports.getGoogleCredentialsAndroid = (NATIVE_CONFIG) => ` { "project_info": { "project_number": "${process.env.FYLE_MOBILE_PROJECT_NUMBER}", - "firebase_url": "${process.env.FYLE_MOBILE_FIREBASE_URL}", "project_id": "${process.env.FYLE_MOBILE_PROJECT_ID}", "storage_bucket": "${process.env.FYLE_MOBILE_STORAGE_BUCKET}" }, diff --git a/hooks/utils/google-credentials-ios.js b/hooks/utils/google-credentials-ios.js index 40d10ef73b..e0828fcf9e 100644 --- a/hooks/utils/google-credentials-ios.js +++ b/hooks/utils/google-credentials-ios.js @@ -33,8 +33,6 @@ module.exports.getGoogleCredentialsIos = (NATIVE_CONFIG) => GOOGLE_APP_ID ${process.env.FYLE_MOBILE_IOS_GOOGLE_APP_ID} - DATABASE_URL - ${process.env.FYLE_MOBILE_FIREBASE_URL} ` \ No newline at end of file diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift index 6f2ea43169..33223ff2ee 100644 --- a/ios/App/App/AppDelegate.swift +++ b/ios/App/App/AppDelegate.swift @@ -1,21 +1,11 @@ import UIKit import Capacitor -import FirebaseCore -import FirebaseInstanceID -import FirebaseMessaging @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - FirebaseApp.configure() - return true - } - func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. diff --git a/src/app/core/models/platform/platform-project.model.ts b/src/app/core/models/platform/platform-project.model.ts new file mode 100644 index 0000000000..e92b323356 --- /dev/null +++ b/src/app/core/models/platform/platform-project.model.ts @@ -0,0 +1,13 @@ +export interface PlatformProject { + id: number; + org_id: string; + created_at: Date; + updated_at: Date; + name: string; + sub_project: string; + code: string; + display_name: string; + description: string; + is_enabled: boolean; + category_ids: number[]; +} diff --git a/src/app/core/models/v2/project-v2.model.ts b/src/app/core/models/v2/project-v2.model.ts index 59edb030b5..8af239ae40 100644 --- a/src/app/core/models/v2/project-v2.model.ts +++ b/src/app/core/models/v2/project-v2.model.ts @@ -1,11 +1,11 @@ export interface ProjectV2 { - ap1_email: string; - ap1_full_name: string; - ap2_email: string; - ap2_full_name: string; + ap1_email?: string; + ap1_full_name?: string; + ap2_email?: string; + ap2_full_name?: string; project_active: boolean; - project_approver1_id: string; - project_approver2_id: string; + project_approver1_id?: string; + project_approver2_id?: string; project_code: string; project_created_at: Date; project_description: string; diff --git a/src/app/core/services/merge-expenses.service.spec.ts b/src/app/core/services/merge-expenses.service.spec.ts index b71ad8c355..76dc820fef 100644 --- a/src/app/core/services/merge-expenses.service.spec.ts +++ b/src/app/core/services/merge-expenses.service.spec.ts @@ -104,7 +104,7 @@ describe('MergeExpensesService', () => { let corporateCreditCardExpenseService: jasmine.SpyObj; let customInputsService: jasmine.SpyObj; let humanizeCurrencyPipe: jasmine.SpyObj; - let projectService: jasmine.SpyObj; + let projectsService: jasmine.SpyObj; let categoriesService: jasmine.SpyObj; let dateService: jasmine.SpyObj; let taxGroupService: jasmine.SpyObj; @@ -121,7 +121,7 @@ describe('MergeExpensesService', () => { ]); const customInputsServiceSpy = jasmine.createSpyObj('CustomInputsService', ['getAll']); const humanizeCurrencyPipeSpy = jasmine.createSpyObj('HumanizeCurrencyPipe', ['transform']); - const projectServiceSpy = jasmine.createSpyObj('ProjectsService', ['getAllActive']); + const projectsServiceSpy = jasmine.createSpyObj('ProjectsService', ['getAllActive']); const categoriesServiceSpy = jasmine.createSpyObj('CategoriesService', ['getAll', 'filterRequired']); const dateServiceSpy = jasmine.createSpyObj('DateService', ['isValidDate']); const taxGroupServiceSpy = jasmine.createSpyObj('TaxGroupService', ['get']); @@ -134,7 +134,7 @@ describe('MergeExpensesService', () => { { provide: CorporateCreditCardExpenseService, useValue: corporateCreditCardExpenseServiceSpy }, { provide: CustomInputsService, useValue: customInputsServiceSpy }, { provide: HumanizeCurrencyPipe, useValue: humanizeCurrencyPipeSpy }, - { provide: ProjectsService, useValue: projectServiceSpy }, + { provide: ProjectsService, useValue: projectsServiceSpy }, { provide: CategoriesService, useValue: categoriesServiceSpy }, { provide: DateService, useValue: dateServiceSpy }, { provide: TaxGroupService, useValue: taxGroupServiceSpy }, @@ -148,7 +148,7 @@ describe('MergeExpensesService', () => { ) as jasmine.SpyObj; customInputsService = TestBed.inject(CustomInputsService) as jasmine.SpyObj; humanizeCurrencyPipe = TestBed.inject(HumanizeCurrencyPipe) as jasmine.SpyObj; - projectService = TestBed.inject(ProjectsService) as jasmine.SpyObj; + projectsService = TestBed.inject(ProjectsService) as jasmine.SpyObj; categoriesService = TestBed.inject(CategoriesService) as jasmine.SpyObj; dateService = TestBed.inject(DateService) as jasmine.SpyObj; taxGroupService = TestBed.inject(TaxGroupService) as jasmine.SpyObj; @@ -404,7 +404,7 @@ describe('MergeExpensesService', () => { describe('formatProjectOptions():', () => { it('should return the project options', (done) => { - projectService.getAllActive.and.returnValue(of(projectsV1Data)); + projectsService.getAllActive.and.returnValue(of(projectsV1Data)); // @ts-ignore mergeExpensesService.formatProjectOptions(projectOptionsData).subscribe((res) => { expect(res).toEqual(projectOptionsData); @@ -413,7 +413,7 @@ describe('MergeExpensesService', () => { }); it('should return the project options with label as project name if id matches with option', (done) => { - projectService.getAllActive.and.returnValue(of(projectsV1Data)); + projectsService.getAllActive.and.returnValue(of(projectsV1Data)); // @ts-ignore mergeExpensesService.formatProjectOptions({ ...projectOptionsData, value: 257528 }).subscribe((res) => { expect(res).toEqual({ label: 'Customer Mapped Project', value: 257528 }); @@ -422,7 +422,7 @@ describe('MergeExpensesService', () => { }); it('should return the project options when project is not present', (done) => { - projectService.getAllActive.and.returnValue(of([])); + projectsService.getAllActive.and.returnValue(of([])); // @ts-ignore mergeExpensesService.formatProjectOptions({ label: null, value: null }).subscribe((res) => { expect(res).toEqual({ label: undefined, value: null }); diff --git a/src/app/core/services/merge-expenses.service.ts b/src/app/core/services/merge-expenses.service.ts index cb5834efdf..c30e2e8225 100644 --- a/src/app/core/services/merge-expenses.service.ts +++ b/src/app/core/services/merge-expenses.service.ts @@ -43,7 +43,7 @@ export class MergeExpensesService { private corporateCreditCardExpenseService: CorporateCreditCardExpenseService, private customInputsService: CustomInputsService, private humanizeCurrency: HumanizeCurrencyPipe, - private projectService: ProjectsService, + private projectsService: ProjectsService, private categoriesService: CategoriesService, private dateService: DateService, private taxGroupService: TaxGroupService @@ -748,7 +748,7 @@ export class MergeExpensesService { } private formatProjectOptions(option: MergeExpensesOption): Observable> { - const projects$ = this.projectService.getAllActive().pipe(shareReplay(1)); + const projects$ = this.projectsService.getAllActive().pipe(shareReplay(1)); return projects$.pipe( map((projects) => { const index = projects.map((project) => project.id).indexOf(option.value); diff --git a/src/app/core/services/projects.service.spec.ts b/src/app/core/services/projects.service.spec.ts index 9d2d1041b9..3152ac6a44 100644 --- a/src/app/core/services/projects.service.spec.ts +++ b/src/app/core/services/projects.service.spec.ts @@ -25,7 +25,7 @@ const fixDate = (data) => })); describe('ProjectsService', () => { - let projectService: ProjectsService; + let projectsService: ProjectsService; let apiService: jasmine.SpyObj; let apiV2Service: jasmine.SpyObj; @@ -46,18 +46,18 @@ describe('ProjectsService', () => { }, ], }); - projectService = TestBed.inject(ProjectsService); + projectsService = TestBed.inject(ProjectsService); apiService = TestBed.inject(ApiService) as jasmine.SpyObj; apiV2Service = TestBed.inject(ApiV2Service) as jasmine.SpyObj; }); it('should be created', () => { - expect(projectService).toBeTruthy(); + expect(projectsService).toBeTruthy(); }); it('should be able to fetch project by id', (done) => { apiV2Service.get.and.returnValue(of(apiV2ResponseSingle)); - projectService.getbyId(257528).subscribe((res) => { + projectsService.getbyId(257528).subscribe((res) => { expect(res).toEqual(fixDate(apiV2ResponseSingle.data)[0]); done(); }); @@ -71,7 +71,7 @@ describe('ProjectsService', () => { it('should be able to fetch all active projects', (done) => { apiService.get.and.returnValue(of(apiResponseActiveOnly)); - projectService.getAllActive().subscribe((res) => { + projectsService.getAllActive().subscribe((res) => { expect(res).toEqual(expectedReponseActiveOnly); done(); }); @@ -86,7 +86,7 @@ describe('ProjectsService', () => { it('should be able to fetch data when no params provided', (done) => { apiV2Service.get.and.returnValue(of(apiV2ResponseMultiple)); - projectService.getByParamsUnformatted({}).subscribe((res) => { + projectsService.getByParamsUnformatted({}).subscribe((res) => { expect(res).toEqual(fixDate(apiV2ResponseMultiple.data)); done(); }); @@ -95,7 +95,7 @@ describe('ProjectsService', () => { it('should be able to fetch data when params are provided', (done) => { apiV2Service.get.and.returnValue(of(apiV2ResponseMultiple)); - const result = projectService.getByParamsUnformatted(testProjectParams); + const result = projectsService.getByParamsUnformatted(testProjectParams); result.subscribe((res) => { expect(res).toEqual(expectedProjectsResponse); @@ -107,19 +107,19 @@ describe('ProjectsService', () => { }); it('should category list after filter as per project passed', () => { - const result = projectService.getAllowedOrgCategoryIds(testProjectV2, testActiveCategoryList); + const result = projectsService.getAllowedOrgCategoryIds(testProjectV2, testActiveCategoryList); expect(result).toEqual(allowedActiveCategories); }); it('should return whole category list if project passed is not present', () => { - const result = projectService.getAllowedOrgCategoryIds(null, testActiveCategoryList); + const result = projectsService.getAllowedOrgCategoryIds(null, testActiveCategoryList); expect(result).toEqual(testActiveCategoryList); }); it('should get project count restricted by a set of category IDs', (done) => { apiService.get.and.returnValue(of(apiResponseActiveOnly)); - const result = projectService.getProjectCount({ categoryIds: testCategoryIds }); + const result = projectsService.getProjectCount({ categoryIds: testCategoryIds }); result.subscribe((res) => { expect(res).toEqual(2); done(); @@ -129,8 +129,8 @@ describe('ProjectsService', () => { it('should get project count not restricted by a set of category IDs', (done) => { apiService.get.and.returnValue(of(apiResponseActiveOnly)); - const resultWithOutParam = projectService.getProjectCount(); - const resultWithParam = projectService.getProjectCount({ categoryIds: null }); + const resultWithOutParam = projectsService.getProjectCount(); + const resultWithParam = projectsService.getProjectCount({ categoryIds: null }); resultWithOutParam.subscribe((res) => { expect(res).toEqual(apiResponseActiveOnly.length); diff --git a/src/app/core/services/projects.service.ts b/src/app/core/services/projects.service.ts index 7b4b8d7081..312a84710c 100644 --- a/src/app/core/services/projects.service.ts +++ b/src/app/core/services/projects.service.ts @@ -9,6 +9,7 @@ import { ProjectV1 } from '../models/v1/extended-project.model'; import { ProjectParams } from '../models/project-params.model'; import { intersection } from 'lodash'; import { OrgCategory } from '../models/v1/org-category.model'; +import { PlatformProject } from '../models/platform/platform-project.model'; @Injectable({ providedIn: 'root', @@ -162,4 +163,39 @@ export class ProjectsService { ) ); } + + transformToV1Response(platformProject: PlatformProject[]): ProjectV1[] { + const projectV1 = platformProject.map((platformProject) => ({ + id: platformProject.id, + created_at: platformProject.created_at, + updated_at: platformProject.updated_at, + name: platformProject.name, + sub_project: platformProject.sub_project, + code: platformProject.code, + org_id: platformProject.org_id, + description: platformProject.description, + active: platformProject.is_enabled, + org_category_ids: platformProject.category_ids, + })); + + return projectV1; + } + + transformToV2Response(platformProject: PlatformProject[]): ProjectV2[] { + const projectV2 = platformProject.map((platformProject) => ({ + project_active: platformProject.is_enabled, + project_code: platformProject.code, + project_created_at: platformProject.created_at, + project_description: platformProject.description, + project_id: platformProject.id, + project_name: platformProject.name, + project_org_category_ids: platformProject.category_ids, + project_org_id: platformProject.org_id, + project_updated_at: platformProject.updated_at, + projectv2_name: platformProject.display_name, + sub_project_name: platformProject.sub_project, + })); + + return projectV2; + } } diff --git a/src/app/core/services/recently-used-items.service.spec.ts b/src/app/core/services/recently-used-items.service.spec.ts index d86f5c2f48..437ab4cde6 100644 --- a/src/app/core/services/recently-used-items.service.spec.ts +++ b/src/app/core/services/recently-used-items.service.spec.ts @@ -20,7 +20,7 @@ import { recentUsedCategoriesRes } from '../mock-data/org-category-list-item.dat describe('RecentlyUsedItemsService', () => { let recentlyUsedItemsService: RecentlyUsedItemsService; let apiService: jasmine.SpyObj; - let projectService: jasmine.SpyObj; + let projectsService: jasmine.SpyObj; beforeEach(() => { TestBed.configureTestingModule({ @@ -38,7 +38,7 @@ describe('RecentlyUsedItemsService', () => { }); recentlyUsedItemsService = TestBed.inject(RecentlyUsedItemsService); apiService = TestBed.inject(ApiService) as jasmine.SpyObj; - projectService = TestBed.inject(ProjectsService) as jasmine.SpyObj; + projectsService = TestBed.inject(ProjectsService) as jasmine.SpyObj; }); it('should be created', () => { @@ -56,14 +56,14 @@ describe('RecentlyUsedItemsService', () => { describe('getRecentlyUsedProjects():', () => { it('should get all the recently used projects', (done) => { - projectService.getByParamsUnformatted.and.returnValue(of(recentlyUsedProjectRes)); + projectsService.getByParamsUnformatted.and.returnValue(of(recentlyUsedProjectRes)); const config = { recentValues: recentlyUsedRes, eou: apiEouRes, categoryIds: ['16558', '16559', '16560', '16561', '16562'], }; recentlyUsedItemsService.getRecentlyUsedProjects(config).subscribe((res) => { - expect(projectService.getByParamsUnformatted).toHaveBeenCalledOnceWith({ + expect(projectsService.getByParamsUnformatted).toHaveBeenCalledOnceWith({ orgId: config.eou.ou.org_id, active: true, sortDirection: 'asc', diff --git a/src/app/core/services/recently-used-items.service.ts b/src/app/core/services/recently-used-items.service.ts index 31521d1ac5..5a0bba0475 100644 --- a/src/app/core/services/recently-used-items.service.ts +++ b/src/app/core/services/recently-used-items.service.ts @@ -13,7 +13,7 @@ import { Currency, CurrencyName } from '../models/currency.model'; providedIn: 'root', }) export class RecentlyUsedItemsService { - constructor(private apiService: ApiService, private projectService: ProjectsService) {} + constructor(private apiService: ApiService, private projectsService: ProjectsService) {} getRecentlyUsed(): Observable { return this.apiService.get('/recently_used'); @@ -30,7 +30,7 @@ export class RecentlyUsedItemsService { config.recentValues.recent_project_ids.length > 0 && config.eou ) { - return this.projectService + return this.projectsService .getByParamsUnformatted({ orgId: config.eou.ou.org_id, active: true, diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts index 4c5f937feb..cdd24df676 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts @@ -296,7 +296,7 @@ export class AddEditMileagePage implements OnInit { private reportService: ReportService, private platformReportService: ReportsService, private fb: FormBuilder, - private projectService: ProjectsService, + private projectsService: ProjectsService, private mileageService: MileageService, private mileageRatesService: MileageRatesService, private transactionsOutboxService: TransactionsOutboxService, @@ -467,7 +467,7 @@ export class AddEditMileagePage implements OnInit { concatMap((project: ProjectV2) => activeCategories$.pipe( map((activeCategories: OrgCategory[]) => - this.projectService.getAllowedOrgCategoryIds(project, activeCategories) + this.projectsService.getAllowedOrgCategoryIds(project, activeCategories) ) ) ), @@ -1160,7 +1160,7 @@ export class AddEditMileagePage implements OnInit { }), switchMap((projectId) => { if (projectId) { - return this.projectService.getbyId(projectId); + return this.projectsService.getbyId(projectId); } else { return of(null); } @@ -1570,7 +1570,7 @@ export class AddEditMileagePage implements OnInit { this.setupFilteredCategories(this.subCategories$); this.projectCategoryIds$ = this.getProjectCategoryIds(); this.isProjectVisible$ = this.projectCategoryIds$.pipe( - switchMap((projectCategoryIds) => this.projectService.getProjectCount({ categoryIds: projectCategoryIds })), + switchMap((projectCategoryIds) => this.projectsService.getProjectCount({ categoryIds: projectCategoryIds })), map((projectCount) => projectCount > 0) ); this.comments$ = this.statusService.find('transactions', this.activatedRoute.snapshot.params.id as string); diff --git a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.setup.spec.ts b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.setup.spec.ts index c271fda5ff..13d6ad472f 100644 --- a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.setup.spec.ts +++ b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.setup.spec.ts @@ -66,7 +66,7 @@ describe('AddEditPerDiemPage', () => { 'removeTransaction', ]); const platformReportsServiceSpy = jasmine.createSpyObj('ReportsService', ['getAllReportsByParams']); - const projectServiceSpy = jasmine.createSpyObj('ProjectService', [ + const projectsServiceSpy = jasmine.createSpyObj('ProjectService', [ 'getAllowedOrgCategoryIds', 'getProjectCount', 'getbyId', @@ -175,7 +175,7 @@ describe('AddEditPerDiemPage', () => { }, { provide: ProjectsService, - useValue: projectServiceSpy, + useValue: projectsServiceSpy, }, { provide: TransactionsOutboxService, diff --git a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts index 5e8d6b7e69..5953205d74 100644 --- a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts +++ b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts @@ -259,7 +259,7 @@ export class AddEditPerDiemPage implements OnInit { private currencyService: CurrencyService, private reportService: ReportService, private platformReportService: ReportsService, - private projectService: ProjectsService, + private projectsService: ProjectsService, private transactionsOutboxService: TransactionsOutboxService, private transactionService: TransactionService, private authService: AuthService, @@ -689,7 +689,7 @@ export class AddEditPerDiemPage implements OnInit { startWith(this.fg.controls.project.value), concatMap((project: ProjectV2) => activeCategories$.pipe( - map((activeCategories) => this.projectService.getAllowedOrgCategoryIds(project, activeCategories)) + map((activeCategories) => this.projectsService.getAllowedOrgCategoryIds(project, activeCategories)) ) ), map((categories) => categories.map((category) => ({ label: category.sub_category, value: category }))) @@ -1008,7 +1008,7 @@ export class AddEditPerDiemPage implements OnInit { this.projectCategoryIds$ = this.getProjectCategoryIds(); this.isProjectVisible$ = this.projectCategoryIds$.pipe( - switchMap((projectCategoryIds) => this.projectService.getProjectCount({ categoryIds: projectCategoryIds })), + switchMap((projectCategoryIds) => this.projectsService.getProjectCount({ categoryIds: projectCategoryIds })), map((projectCount) => projectCount > 0) ); this.comments$ = this.statusService.find('transactions', this.activatedRoute.snapshot.params.id as string); @@ -1309,7 +1309,7 @@ export class AddEditPerDiemPage implements OnInit { }), switchMap((projectId) => { if (projectId) { - return this.projectService.getbyId(projectId); + return this.projectsService.getbyId(projectId); } else { return of(null); } diff --git a/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.spec.ts b/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.spec.ts index 1ae7a1def8..0f3cd2eb22 100644 --- a/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.spec.ts +++ b/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.spec.ts @@ -40,7 +40,7 @@ describe('FyProjectSelectModalComponent', () => { let fixture: ComponentFixture; let modalController: jasmine.SpyObj; let cdr: ChangeDetectorRef; - let projectService: jasmine.SpyObj; + let projectsService: jasmine.SpyObj; let authService: jasmine.SpyObj; let recentLocalStorageItemsService: jasmine.SpyObj; let utilityService: jasmine.SpyObj; @@ -50,7 +50,7 @@ describe('FyProjectSelectModalComponent', () => { beforeEach(waitForAsync(() => { const modalControllerSpy = jasmine.createSpyObj('ModalController', ['dismiss']); - const projectServiceSpy = jasmine.createSpyObj('ProjectsService', ['getbyId', 'getByParamsUnformatted']); + const projectsServiceSpy = jasmine.createSpyObj('ProjectsService', ['getbyId', 'getByParamsUnformatted']); const authServiceSpy = jasmine.createSpyObj('AuthService', ['getEou']); const recentLocalStorageItemsServiceSpy = jasmine.createSpyObj('RecentLocalStorageItemsService', ['get', 'post']); const utilityServiceSpy = jasmine.createSpyObj('UtilityService', ['searchArrayStream']); @@ -76,7 +76,7 @@ describe('FyProjectSelectModalComponent', () => { }, { provide: ProjectsService, - useValue: projectServiceSpy, + useValue: projectsServiceSpy, }, { provide: AuthService, @@ -105,7 +105,7 @@ describe('FyProjectSelectModalComponent', () => { modalController = TestBed.inject(ModalController) as jasmine.SpyObj; cdr = TestBed.inject(ChangeDetectorRef); - projectService = TestBed.inject(ProjectsService) as jasmine.SpyObj; + projectsService = TestBed.inject(ProjectsService) as jasmine.SpyObj; authService = TestBed.inject(AuthService) as jasmine.SpyObj; recentLocalStorageItemsService = TestBed.inject( RecentLocalStorageItemsService @@ -114,13 +114,13 @@ describe('FyProjectSelectModalComponent', () => { orgSettingsService = TestBed.inject(OrgSettingsService) as jasmine.SpyObj; orgUserSettingsService = TestBed.inject(OrgUserSettingsService) as jasmine.SpyObj; - projectService.getbyId.and.returnValue(of(singleProjects1)); + projectsService.getbyId.and.returnValue(of(singleProjects1)); orgSettingsService.get.and.returnValue(of(orgSettingsData)); authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); orgUserSettingsService.get.and.returnValue(of(orgUserSettingsData)); - projectService.getByParamsUnformatted.and.returnValue(of([singleProject2])); + projectsService.getByParamsUnformatted.and.returnValue(of([singleProject2])); component.cacheName = 'projects'; component.defaultValue = true; @@ -138,8 +138,8 @@ describe('FyProjectSelectModalComponent', () => { describe('getProjects():', () => { it('should get projects when current selection is not defined', (done) => { - projectService.getByParamsUnformatted.and.returnValue(of(projects)); - projectService.getbyId.and.returnValue(of(expectedProjects[0].value)); + projectsService.getByParamsUnformatted.and.returnValue(of(projects)); + projectsService.getbyId.and.returnValue(of(expectedProjects[0].value)); authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); component.getProjects('projects').subscribe((res) => { @@ -147,7 +147,7 @@ describe('FyProjectSelectModalComponent', () => { expect(orgSettingsService.get).toHaveBeenCalledTimes(2); expect(authService.getEou).toHaveBeenCalledTimes(2); expect(orgUserSettingsService.get).toHaveBeenCalledTimes(4); - expect(projectService.getByParamsUnformatted).toHaveBeenCalledWith({ + expect(projectsService.getByParamsUnformatted).toHaveBeenCalledWith({ orgId: 'orNVthTo2Zyo', active: true, sortDirection: 'asc', @@ -158,13 +158,13 @@ describe('FyProjectSelectModalComponent', () => { offset: 0, limit: 20, }); - expect(projectService.getbyId).toHaveBeenCalledWith(3943); + expect(projectsService.getbyId).toHaveBeenCalledWith(3943); done(); }); }); it('should get projects when current selection is defined', (done) => { - projectService.getByParamsUnformatted.and.returnValue(of(projects)); + projectsService.getByParamsUnformatted.and.returnValue(of(projects)); component.currentSelection = testProjectV2; fixture.detectChanges(); @@ -173,7 +173,7 @@ describe('FyProjectSelectModalComponent', () => { expect(orgSettingsService.get).toHaveBeenCalledTimes(2); expect(authService.getEou).toHaveBeenCalledTimes(2); expect(orgUserSettingsService.get).toHaveBeenCalledTimes(4); - expect(projectService.getByParamsUnformatted).toHaveBeenCalledWith({ + expect(projectsService.getByParamsUnformatted).toHaveBeenCalledWith({ orgId: 'orNVthTo2Zyo', active: true, sortDirection: 'asc', @@ -184,14 +184,14 @@ describe('FyProjectSelectModalComponent', () => { offset: 0, limit: 20, }); - expect(projectService.getbyId).toHaveBeenCalledWith(3943); + expect(projectsService.getbyId).toHaveBeenCalledWith(3943); done(); }); }); it('should get projects when default value is null and no default projects are available', (done) => { orgSettingsService.get.and.returnValue(of(orgSettingsDataWithoutAdvPro)); - projectService.getbyId.and.returnValue(of(expectedProjects[0].value)); + projectsService.getbyId.and.returnValue(of(expectedProjects[0].value)); component.defaultValue = false; fixture.detectChanges(); @@ -199,7 +199,7 @@ describe('FyProjectSelectModalComponent', () => { expect(orgSettingsService.get).toHaveBeenCalledTimes(2); expect(authService.getEou).toHaveBeenCalledTimes(2); expect(orgUserSettingsService.get).toHaveBeenCalledTimes(4); - expect(projectService.getByParamsUnformatted).toHaveBeenCalledWith({ + expect(projectsService.getByParamsUnformatted).toHaveBeenCalledWith({ orgId: 'orNVthTo2Zyo', active: true, sortDirection: 'asc', @@ -210,7 +210,7 @@ describe('FyProjectSelectModalComponent', () => { offset: 0, limit: 20, }); - expect(projectService.getbyId).toHaveBeenCalledWith(3943); + expect(projectsService.getbyId).toHaveBeenCalledWith(3943); done(); }); }); diff --git a/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.ts b/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.ts index 857130e502..a5581fca4b 100644 --- a/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.ts +++ b/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.ts @@ -46,7 +46,7 @@ export class FyProjectSelectModalComponent implements AfterViewInit { constructor( private modalController: ModalController, private cdr: ChangeDetectorRef, - private projectService: ProjectsService, + private projectsService: ProjectsService, private authService: AuthService, private recentLocalStorageItemsService: RecentLocalStorageItemsService, private utilityService: UtilityService, @@ -63,7 +63,7 @@ export class FyProjectSelectModalComponent implements AfterViewInit { const defaultProject$ = this.orgUserSettingsService.get().pipe( switchMap((orgUserSettings) => { if (orgUserSettings && orgUserSettings.preferences && orgUserSettings.preferences.default_project_id) { - return this.projectService.getbyId(orgUserSettings.preferences.default_project_id); + return this.projectsService.getbyId(orgUserSettings.preferences.default_project_id); } else { return of(null); } @@ -83,7 +83,7 @@ export class FyProjectSelectModalComponent implements AfterViewInit { concatMap((allowedProjectIds) => from(this.authService.getEou()).pipe( switchMap((eou) => - this.projectService.getByParamsUnformatted({ + this.projectsService.getByParamsUnformatted({ orgId: eou.ou.org_id, active: true, sortDirection: 'asc',