Skip to content

Commit

Permalink
Removed references to old mot service from frontend (#1814)
Browse files Browse the repository at this point in the history
  • Loading branch information
RLCorp authored Nov 14, 2024
1 parent bd7d192 commit 8a56db3
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 68 deletions.
4 changes: 0 additions & 4 deletions src/app/providers/app-config/__mocks__/app-config.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export class AppConfigProviderMock {
daysToCacheLogs: localEnvironmentMock.daysToCacheLogs,
logoutClearsTestPersistence: localEnvironmentMock.logoutClearsTestPersistence,
logsPostApiKey: localEnvironmentMock.logsPostApiKey,
taxMotApiKey: localEnvironmentMock.taxMotApiKey,
logsApiUrl: localEnvironmentMock.logsApiUrl,
logsAutoSendInterval: localEnvironmentMock.logsAutoSendInterval,
authentication: {
Expand Down Expand Up @@ -59,9 +58,6 @@ export class AppConfigProviderMock {
mot: {
motHistoryUrl: localEnvironmentMock.mot.motHistoryUrl,
},
vehicle: {
taxMotUrl: localEnvironmentMock.vehicle.taxMotUrl,
},
refData: {
testCentreUrl: localEnvironmentMock.refData.testCentreUrl,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ export const environmentResponseMock = {
mot: {
motHistoryUrl: 'https://www.example.com/api/v1/mot/12345',
},
vehicle: {
taxMotUrl: 'https://www.example.com/api/v1/vehicle/12345',
},
refData: {
testCentreUrl: 'some url',
},
Expand Down
3 changes: 0 additions & 3 deletions src/app/providers/app-config/__mocks__/environment.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ export const localEnvironmentMock: LocalEnvironmentFile = {
mot: {
motHistoryUrl: null,
},
vehicle: {
taxMotUrl: null,
},
driver: {
photographUrl: null,
signatureUrl: null,
Expand Down
4 changes: 0 additions & 4 deletions src/app/providers/app-config/app-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type AppConfig = {
daysToCacheLogs: number;
logoutClearsTestPersistence?: boolean;
logsPostApiKey: string;
taxMotApiKey: string;
logsApiUrl: string;
logsAutoSendInterval: number;
authentication: {
Expand Down Expand Up @@ -60,9 +59,6 @@ export type AppConfig = {
mot: {
motHistoryUrl: string;
};
vehicle: {
taxMotUrl: string;
};
refData: {
testCentreUrl: string;
};
Expand Down
5 changes: 0 additions & 5 deletions src/app/providers/app-config/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export class AppConfigProvider {
},
daysToCacheLogs: await this.getManagedConfigValueNumber('daysToCacheLogs'),
logsPostApiKey: await this.getManagedConfigValueString('logsPostApiKey'),
taxMotApiKey: await this.getManagedConfigValueString('taxMotApiKey'),
logsApiUrl: await this.getManagedConfigValueString('logsApiUrl'),
logsAutoSendInterval: await this.getManagedConfigValueNumber('logsAutoSendInterval'),
authentication: {
Expand Down Expand Up @@ -296,7 +295,6 @@ export class AppConfigProvider {
},
logoutClearsTestPersistence: data.logoutClearsTestPersistence,
logsPostApiKey: data.logsPostApiKey,
taxMotApiKey: data.taxMotApiKey,
logsApiUrl: data.logsApiUrl,
logsAutoSendInterval: data.logsAutoSendInterval,
authentication: {
Expand Down Expand Up @@ -351,9 +349,6 @@ export class AppConfigProvider {
photographUrl: data.driver.photographUrl,
standardUrl: data.driver.standardUrl,
},
vehicle: {
taxMotUrl: data.vehicle.taxMotUrl,
},
mot: {
motHistoryUrl: data.mot.motHistoryUrl,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { PracticeModeMOTType } from '@pages/waiting-room-to-car/components/mot-components/practice-mode-mot-modal/practice-mode-mot-modal.component';
Expand Down Expand Up @@ -296,14 +296,6 @@ describe('MotHistoryApiService', () => {
});
});

describe('getRequestHeaders', () => {
it('should return a header with the correct key', () => {
spyOn(vehicleDetailsService['urlProvider'], 'getTaxMotApiKey').and.returnValue('test-key');
const result = vehicleDetailsService['getRequestHeaders']();
expect(result.get('x-api-key')).toBe('test-key');
});
});

describe('getVehicleByIdentifier', () => {
it('should return cached vehicle details if vehicle is cached', (done) => {
spyOn(vehicleDetailsService, 'isResultCached').and.returnValue(true);
Expand All @@ -323,7 +315,6 @@ describe('MotHistoryApiService', () => {

it('should fetch vehicle details from API if vehicle is not cached', (done) => {
spyOn(vehicleDetailsService, 'isResultCached').and.returnValue(false);
spyOn(vehicleDetailsService, 'getRequestHeaders').and.returnValue(new HttpHeaders());
spyOn(vehicleDetailsService['http'], 'get').and.returnValue(
of(
new HttpResponse<MotHistory>({
Expand All @@ -345,7 +336,6 @@ describe('MotHistoryApiService', () => {

it('should handle API error and return default error response', (done) => {
spyOn(vehicleDetailsService, 'isResultCached').and.returnValue(false);
spyOn(vehicleDetailsService, 'getRequestHeaders').and.returnValue(new HttpHeaders());
spyOn(vehicleDetailsService['http'], 'get').and.returnValue(throwError({ status: 500 }));
spyOn(vehicleDetailsService, 'handleError').and.returnValue(
of({
Expand Down
16 changes: 2 additions & 14 deletions src/app/providers/mot-history-api/mot-history-api.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { PracticeModeMOTType } from '@pages/waiting-room-to-car/components/mot-components/practice-mode-mot-modal/practice-mode-mot-modal.component';
import { AppConfigProvider } from '@providers/app-config/app-config';
Expand Down Expand Up @@ -75,10 +75,7 @@ export class MotHistoryApiService {
if (this.isResultCached(vehicleRegistration)) {
return this.getCachedMotHistory();
}

const headers = this.getRequestHeaders();

return this.http.get(this.urlProvider.getMotUrl(vehicleRegistration), { observe: 'response', headers }).pipe(
return this.http.get(this.urlProvider.getMotUrl(vehicleRegistration), { observe: 'response' }).pipe(
tap((response: HttpResponse<MotHistory>) => this.cacheMotHistory(response)),
map((value): MotHistoryWithStatus => this.mapResponseToMotData(value)),
timeout(this.appConfig.getAppConfig().requestTimeout),
Expand All @@ -105,15 +102,6 @@ export class MotHistoryApiService {
return of({ status: 'Already Saved', data: this.motHistoryResponse });
}

/**
* Generates the HTTP headers required for the API request.
*
* @returns {HttpHeaders} The HTTP headers with the API key set.
*/
getRequestHeaders(): HttpHeaders {
return new HttpHeaders().set('x-api-key', this.urlProvider.getTaxMotApiKey());
}

/**
* Caches the vehicle details.
*
Expand Down
2 changes: 0 additions & 2 deletions src/app/providers/url/__mocks__/url.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export class UrlProviderMock {
.createSpy('getCandidateStandardDataUrl')
.and.returnValue('https://www.example.com/standard');

getTaxMotApiKey = jasmine.createSpy().and.returnValue('x-api-key');

getRefDataTestCentreUrl = jasmine.createSpy('getRefDataTestCentreUrl').and.returnValue('https://ref-data/testcentre');

getDelegatedExaminerSearchBookingUrl = jasmine
Expand Down
6 changes: 0 additions & 6 deletions src/app/providers/url/__tests__/url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ describe('UrlProvider', () => {
expect(urlProvider.getLogsServiceApiKey()).toBe('key');
});
});
describe('getTaxMotApiKey', () => {
it('should get taxMotApiKey', () => {
spyOn(urlProvider.appConfigProvider, 'getAppConfig').and.returnValue({ taxMotApiKey: 'key' } as AppConfig);
expect(urlProvider.getTaxMotApiKey()).toBe('key');
});
});
describe('getMotUrl', () => {
it('should get Mot Url', () => {
spyOn(urlProvider.appConfigProvider, 'getAppConfig').and.returnValue({
Expand Down
4 changes: 0 additions & 4 deletions src/app/providers/url/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export class UrlProvider {
return this.appConfigProvider.getAppConfig()?.tests.multipleTestResultsUrl;
}

getTaxMotApiKey(): string {
return this.appConfigProvider.getAppConfig()?.taxMotApiKey;
}

getMotUrl(vehicleRegistration: string): string {
const urlTemplate = this.appConfigProvider.getAppConfig()?.mot.motHistoryUrl;
return urlTemplate.replace('{vrn}', vehicleRegistration);
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const environment: EnvironmentFile = {
enableDevTools: false,
logoutClearsTestPersistence: true,
logsPostApiKey: '',
taxMotApiKey: '7d804a0461126d0ebee4128af69bb8dc',
logsApiUrl: 'https://dev.mes.dev-dvsacloud.uk/v1/logs',
logsAutoSendInterval: 60000,
authentication: {
Expand Down
6 changes: 0 additions & 6 deletions src/environments/environment.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ export const environment: LocalEnvironmentFile = {
photographUrl: 'https://dev.mes.dev-dvsacloud.uk/v1/driver/photograph/{drivingLicenceNumber}',
standardUrl: 'https://dev.mes.dev-dvsacloud.uk/v1/driver/standard',
},
vehicle: {
taxMotUrl: 'https://api.mot.test.smc.dvsacloud.uk/1.0/checkMot',
},
mot: {
motHistoryUrl: 'https://dev.mes.dev-dvsacloud.uk/v1/mot-history/{vrn}',
},
refData: {
testCentreUrl: '/assets/mock/ref-data/local-test-centres.json',
},
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const environment: TestersEnvironmentFile = {
enableDevTools: false,
logoutClearsTestPersistence: true,
logsPostApiKey: '',
taxMotApiKey: '',
logsApiUrl: 'https://dev.mes.dev-dvsacloud.uk/v1/logs',
logsAutoSendInterval: 6000,
authentication: {
Expand Down
4 changes: 0 additions & 4 deletions src/store/app-config/app-config.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const initialState: AppConfig = {
daysToCacheLogs: null,
logoutClearsTestPersistence: null,
logsPostApiKey: null,
taxMotApiKey: null,
logsApiUrl: null,
logsAutoSendInterval: null,
authentication: {
Expand Down Expand Up @@ -61,9 +60,6 @@ export const initialState: AppConfig = {
mot: {
motHistoryUrl: null,
},
vehicle: {
taxMotUrl: null,
},
refData: {
testCentreUrl: null,
},
Expand Down

0 comments on commit 8a56db3

Please sign in to comment.