Skip to content

Commit

Permalink
fix: replace cached EOU object with an API call on opening the App (#…
Browse files Browse the repository at this point in the history
…3167)

* Eou API call on settings page

* fix unit tests

* make refresh EOU call on opening the app

* minor

* fix failing unit test
  • Loading branch information
harshal015 committed Aug 12, 2024
1 parent 2ffd6b6 commit 276e2c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/app/core/services/app-version.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('AppVersionService', () => {

beforeEach(() => {
const apiServiceSpy = jasmine.createSpyObj('ApiService', ['get', 'post']);
const authServiceSpy = jasmine.createSpyObj('AuthService', ['getEou']);
const authServiceSpy = jasmine.createSpyObj('AuthService', ['getEou', 'refreshEou']);
const routerApiServiceSpy = jasmine.createSpyObj('RouterApiService', ['post']);
const loginInfoServiceSpy = jasmine.createSpyObj('LoginInfoService', ['getLastLoggedInVersion']);
TestBed.configureTestingModule({
Expand Down Expand Up @@ -161,14 +161,14 @@ describe('AppVersionService', () => {
beforeEach(() => {
spyOn(appVersionService, 'isSupported').and.returnValue(of({ supported: true }));
loginInfoService.getLastLoggedInVersion.and.returnValue(of('5.50.0'));
authService.getEou.and.resolveTo(apiEouRes);
authService.refreshEou.and.returnValue(of(apiEouRes));
});

it("getUserAppVersionDetails(): should get user's app version details", (done) => {
appVersionService.getUserAppVersionDetails(extendedDeviceInfoMockData).subscribe(() => {
expect(appVersionService.isSupported).toHaveBeenCalledOnceWith(extendedDeviceInfoMockData);
expect(loginInfoService.getLastLoggedInVersion).toHaveBeenCalledTimes(1);
expect(authService.getEou).toHaveBeenCalledTimes(1);
expect(authService.refreshEou).toHaveBeenCalledTimes(1);
});
done();
});
Expand All @@ -178,7 +178,7 @@ describe('AppVersionService', () => {
appVersionService.getUserAppVersionDetails(extendedDeviceInfoMockData).subscribe(() => {
expect(appVersionService.isSupported).toHaveBeenCalledOnceWith(extendedDeviceInfoMockData);
expect(loginInfoService.getLastLoggedInVersion).toHaveBeenCalledTimes(1);
expect(authService.getEou).toHaveBeenCalledTimes(1);
expect(authService.refreshEou).toHaveBeenCalledTimes(1);
});
done();
});
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/app-version.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { filter, map, switchMap } from 'rxjs/operators';
import { ApiService } from './api.service';
import { forkJoin, noop, of, from, Observable } from 'rxjs';
import { forkJoin, noop, of, Observable } from 'rxjs';
import { RouterApiService } from './router-api.service';
import { AppVersion } from '../models/app_version.model';
import { environment } from 'src/environments/environment';
Expand Down Expand Up @@ -81,7 +81,7 @@ export class AppVersionService {
return forkJoin({
appSupportDetails: this.isSupported(deviceInfo),
lastLoggedInVersion: this.loginInfoService.getLastLoggedInVersion(),
eou: from(this.authService.getEou()),
eou: this.authService.refreshEou(),
}).pipe(
filter(
(appVersionDetails: {
Expand Down

0 comments on commit 276e2c0

Please sign in to comment.