Skip to content

Commit

Permalink
Mes 7539 cp into release 4.1.1 (#501)
Browse files Browse the repository at this point in the history
* updated whitelist to be sourced from config service

# Conflicts:
#	src/app/providers/category-whitelist/category-whitelist.ts

* address linting errors

* address linting errors
  • Loading branch information
andrewsetterfield authored Feb 15, 2022
1 parent 07cd3da commit 902b9a8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 38 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"husky": {
"hooks": {
"pre-commit": "npm run lint:fix",
"pre-push": "run-s test gitSecrets scanRepo"
"pre-push": "run-s test gitSecrets"
}
}
}
2 changes: 1 addition & 1 deletion src/app/providers/app-config/__tests__/app-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('AppConfigProvider', () => {
appConfig.loadRemoteConfig();
tick();

const request = httpMock.expectOne(`${remoteEnvironmentMock.configUrl}?app_version=4.0`);
const request = httpMock.expectOne(`${remoteEnvironmentMock.configUrl}?app_version=4.0.0.0`);
expect(request.request.method).toBe('GET');
request.flush(environmentResponseMock);
}));
Expand Down
2 changes: 1 addition & 1 deletion src/app/providers/app-config/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class AppConfigProvider {
return;
}

this.appInfoProvider.getMajorAndMinorVersionNumber()
this.appInfoProvider.getFullVersionNumber()
.then((version: string) => {
const url = `${this.environmentFile.configUrl}?app_version=${version}`;
this.httpClient.get(url)
Expand Down
2 changes: 2 additions & 0 deletions src/app/providers/app-info/__mocks__/app-info.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export class AppInfoProviderMock {

getVersionNumber = jasmine.createSpy('getVersionNumber').and.returnValue(of('4.0.0'));

getFullVersionNumber = jasmine.createSpy('getVersionNumber').and.returnValue(Promise.resolve('4.0.0.0'));

getMajorAndMinorVersionNumber = jasmine
.createSpy('getMajorAndMinorVersionNumber').and.returnValue(Promise.resolve('4.0'));
}
4 changes: 4 additions & 0 deletions src/app/providers/app-info/app-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export class AppInfoProvider {
return from(this.appVersion.getVersionNumber());
}

public getFullVersionNumber(): Promise<string> {
return this.appVersion.getVersionNumber();
}

public async getMajorAndMinorVersionNumber(): Promise<string> {
const versionNumber = await this.appVersion.getVersionNumber();
const majorVersion = versionNumber.split('.')[0];
Expand Down
35 changes: 1 addition & 34 deletions src/app/providers/category-whitelist/category-whitelist.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,14 @@
import { TestCategory } from '@dvsa/mes-test-schema/category-definitions/common/test-category';
import { Injectable } from '@angular/core';

// list all test categories that are able to be started by the users
export const whiteList: TestCategory[] = [
// TestCategory.ADI2,
TestCategory.B,
// TestCategory.BE,
// TestCategory.C,
// TestCategory.C1,
// TestCategory.CE,
// TestCategory.C1E,
// TestCategory.CM,
// TestCategory.CEM,
// TestCategory.C1M,
// TestCategory.C1EM,
// TestCategory.CCPC,
// TestCategory.DCPC,
// TestCategory.D,
// TestCategory.D1,
// TestCategory.D1E,
// TestCategory.DE,
// TestCategory.EUAM1,
// TestCategory.EUA1M1,
// TestCategory.EUA2M1,
// TestCategory.EUAMM1,
// TestCategory.EUAMM2,
// TestCategory.EUA1M2,
// TestCategory.EUA2M2,
// TestCategory.EUAM2,
// TestCategory.F,
// TestCategory.G,
// TestCategory.H,
// TestCategory.K,
];

@Injectable()
export class CategoryWhitelistProvider {

/**
* Function to check if the passed in Category exists in the category whitelist
* @param category
*/
isWhiteListed(category: TestCategory): boolean {
isWhiteListed(category: TestCategory, whiteList: TestCategory[]): boolean {
return whiteList.some((cat) => {
return cat === category;
});
Expand Down
5 changes: 4 additions & 1 deletion src/components/test-slot/test-slot/test-slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ export class TestSlotComponent implements SlotComponent, OnInit {

canStartTest(): boolean {
return this.slotProvider.canStartTest(this.slot)
&& this.categoryWhitelist.isWhiteListed(this.slot.booking.application.testCategory as TestCategory);
&& this.categoryWhitelist.isWhiteListed(
this.slot.booking.application.testCategory as TestCategory,
this.appConfig.getAppConfig().journal.allowedTestCategories as TestCategory[],
);
}

canViewCandidateDetails(): boolean {
Expand Down

0 comments on commit 902b9a8

Please sign in to comment.