Skip to content

Commit

Permalink
Mes examiner stats (#1411)
Browse files Browse the repository at this point in the history
* WIP: Added new page for examiner stats

* Moved online loader outside of provider, removed spinners on filters

* Changed wording on results data bar

* Changed logic to fix chartless card size

* Added conditional padding to data tables

* WIP: Adding additional unit tests

* WIP: more unit tests

* WIP: Adding additional unit tests

* Adjusted biggest date range to 18 months, added online dates as grayed out options when there is no cached data

* Fixed tests

* Added additional tests

* Adjusted demonstrationMock tests

* minor test fixes

* WIP: Test fixes

* removed mockComponent

* removed mockComponent from module

* WIP: Removed data label from page if there are no tests to display

* Added conditional spacing to sticky label

* Re-added adi2

* WIP: Added N/A data support to cards and expanded the no data card to include terminated tests with no data

* WIP: Adding support for N/A values

* Reformat emergency stop card and the sticky label

* Added more unit tests

* Added updated analytics

* Re-added getStartedTests

* Removed testing mocks and references to them

* Fixed tests

* Added more unit test coverage

* removed focus

* Renamed type on analytic

* Removed unnecessary code

* Fixed an error with duplicate location names

* Added additional unit test

* Fixed an issue where the unguarded functions would cause errors

* Added New doc blocks and removed more redundant code

* Moved the radio button styling to be local

* Removed unneeded tests

* Changed date type to enum

* Fixed tests

* Added another docblock

* Addressing comments

* removed references to navy mode

* Refactored min width

* Refactored isDuring function

* Added guard to handle test centres without names

* Fixed role filter on burger menu

---------

Co-authored-by: ryan <[email protected]>
  • Loading branch information
RLCorp and gittins7 committed Aug 6, 2024
1 parent 4eb8b51 commit dbf6307
Show file tree
Hide file tree
Showing 76 changed files with 6,977 additions and 84 deletions.
268 changes: 265 additions & 3 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@dvsa/mes-config-schema": "1.9.0",
"@dvsa/mes-driver-schema": "^0.0.2",
"@dvsa/mes-journal-schema": "1.3.1",
"@dvsa/mes-microservice-common": "^1.1.9",
"@dvsa/mes-search-schema": "1.3.0",
"@dvsa/mes-test-schema": "3.42.5",
"@ionic-enterprise/auth": "3.9.5",
Expand All @@ -95,6 +96,7 @@
"@popperjs/core": "^2.11.8",
"@sentry/angular-ivy": "7.93.0",
"@sentry/capacitor": "0.17.0",
"apexcharts": "^3.46.0",
"assert": "^2.1.0",
"bootstrap": "^5.3.2",
"browserify-zlib": "^0.2.0",
Expand All @@ -115,6 +117,7 @@
"jsonschema": "^1.4.1",
"lodash-es": "^4.17.21",
"moment": "^2.29.4",
"ng-apexcharts": "^1.9.0",
"ngrx-store-localstorage": "^17.0.0",
"rxjs": "~7.8.1",
"rxjs-compat": "^6.6.7",
Expand Down
46 changes: 45 additions & 1 deletion src/app/__tests__/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ import { SideMenuClosed, SideMenuItemSelected, SideMenuOpened } from '@pages/das
import { AccessibilityService } from '@providers/accessibility/accessibility.service';
import { AccessibilityServiceMock } from '@providers/accessibility/__mocks__/accessibility-service.mock';
import { LOGIN_PAGE } from '@pages/page-names.constants';
import { AppComponent } from '../app.component';
import { AppComponent, Page } from '../app.component';
import { StorageMock } from '@mocks/ionic-mocks/storage.mock';
import { LogHelper } from '@providers/logs/logs-helper';
import { LogHelperMock } from '@providers/logs/__mocks__/logs-helper.mock';
import { ExaminerRole } from '@dvsa/mes-microservice-common/domain/examiner-role';
import { AppConfig } from '@providers/app-config/app-config.model';

describe('AppComponent', () => {
let component: AppComponent;
Expand Down Expand Up @@ -247,6 +249,48 @@ describe('AppComponent', () => {
});
});

describe('getFilteredPages', () => {
it('should return all pages if role is not defined', () => {
spyOn(appConfigProvider, 'getAppConfig').and.returnValue({ role: undefined } as AppConfig);
const pages: Page[] = [
{ title: 'Page1', descriptor: 'Page1' },
{ title: 'Page2', descriptor: 'Page2' },
];
const result = component.getFilteredPages(pages);
expect(result).toEqual(pages);
});

it('should return filtered pages based on role', () => {
spyOn(appConfigProvider, 'getAppConfig').and.returnValue({ role: ExaminerRole.DLG } as AppConfig);
const pages: Page[] = [
{ title: 'Page1', descriptor: 'Page1', hideWhenRole: [ExaminerRole.DLG] },
{ title: 'Page2', descriptor: 'Page2' },
];
const result = component.getFilteredPages(pages);
expect(result).toEqual([{ title: 'Page2', descriptor: 'Page2' }]);
});

it('should return all pages if hideWhenRole is not defined', () => {
spyOn(appConfigProvider, 'getAppConfig').and.returnValue({ role: ExaminerRole.DLG } as AppConfig);
const pages: Page[] = [
{ title: 'Page1', descriptor: 'Page1' },
{ title: 'Page2', descriptor: 'Page2' },
];
const result = component.getFilteredPages(pages);
expect(result).toEqual(pages);
});

it('should return empty array if all pages are hidden for the role', () => {
spyOn(appConfigProvider, 'getAppConfig').and.returnValue({ role: ExaminerRole.DLG } as AppConfig);
const pages: Page[] = [
{ title: 'Page1', descriptor: 'Page1', hideWhenRole: [ExaminerRole.DLG] },
{ title: 'Page2', descriptor: 'Page2', hideWhenRole: [ExaminerRole.DLG] },
];
const result = component.getFilteredPages(pages);
expect(result).toEqual([]);
});
});

describe('initialisePersistentStorage', () => {
it('should call setSecureContainer when in ios', fakeAsync(() => {
spyOn(dataStore, 'createContainer')
Expand Down
6 changes: 6 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DASHBOARD_PAGE,
DELEGATED_REKEY_SEARCH_PAGE,
DELEGATED_REKEY_UPLOAD_OUTCOME_PAGE,
EXAMINER_RECORDS,
FAKE_JOURNAL_PAGE,
JOURNAL_PAGE,
LOGIN_PAGE,
Expand Down Expand Up @@ -38,6 +39,11 @@ const routes: Routes = [
loadChildren: () => import('@pages/pass-certificates/pass-certificates.module')
.then((m) => m.PassCertificatesPageModule),
},
{
path: EXAMINER_RECORDS,
loadChildren: () => import('@pages/examiner-records/examiner-records.module')
.then((m) => m.ExaminerRecordsPageModule),
},
{
path: LOGIN_PAGE,
loadChildren: () => import('./pages/login/login.module').then((m) => m.LoginPageModule),
Expand Down
5 changes: 3 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ion-header>

<ion-content [scrollY]="false" style="--ion-background-color: var(--mes-toolbar-background)">
<ion-item *ngFor="let page of pages | roleFilter" class="menu-item" detail="true" (click)="navPage(page)">
<ion-item *ngFor="let page of getFilteredPages(pages)" class="menu-item" detail="true" (click)="navPage(page)">
<ion-label class="burger-menu-item" [id]="page.descriptor | formatToID: 'side-menu'">{{
page.descriptor
}}</ion-label>
Expand All @@ -19,7 +19,8 @@
slot="end"
color="danger"
id="un-submitted-test-count-badge"
class="burger-menu-item">
class="burger-menu-item"
>
{{ count }}
</ion-badge>
</ion-item>
Expand Down
18 changes: 17 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Capacitor } from '@capacitor/core';
import { AppInfoProvider } from '@providers/app-info/app-info';
import { AppConfigProvider } from '@providers/app-config/app-config';
import { SENTRY_ERRORS } from '@app/sentry-error-handler';
import { DASHBOARD_PAGE, LOGIN_PAGE, UNUPLOADED_TESTS_PAGE } from '@pages/page-names.constants';
import { DASHBOARD_PAGE, EXAMINER_RECORDS, LOGIN_PAGE, UNUPLOADED_TESTS_PAGE } from '@pages/page-names.constants';
import { SideMenuClosed, SideMenuItemSelected, SideMenuOpened } from '@pages/dashboard/dashboard.actions';
import { SlotProvider } from '@providers/slot/slot';
import { DateTimeProvider } from '@providers/date-time/date-time';
Expand All @@ -30,6 +30,7 @@ import { StartSendingCompletedTests, StopSendingCompletedTests } from '@store/te
import { SetupPolling, StopPolling } from '@store/journal/journal.actions';
import { getJournalState } from '@store/journal/journal.reducer';
import { getTests } from '@store/tests/tests.reducer';
import { isAnyOf } from '@shared/helpers/simplifiers';

interface AppComponentPageState {
logoutEnabled$: Observable<boolean>;
Expand Down Expand Up @@ -60,6 +61,11 @@ export class AppComponent extends LogoutBasePageComponent implements OnInit {
showUnSubmittedCount: true,
hideWhenRole: [ExaminerRole.DLG],
},
{
title: EXAMINER_RECORDS,
descriptor: 'Examiner records',
hideWhenRole: [ExaminerRole.DLG],
},
// {
// title: PASS_CERTIFICATES,
// descriptor: 'Missing / spoiled pass certificates',
Expand All @@ -86,6 +92,16 @@ export class AppComponent extends LogoutBasePageComponent implements OnInit {
super(injector);
}

getFilteredPages(pages: Page[]): Page[] {
const role = this.appConfigProvider.getAppConfig()?.role;
if (!role) {
return pages;
}
return pages.filter(
(page) => !isAnyOf(role, (page.hideWhenRole || [])),
);
}

async ngOnInit() {
try {
await this.platform.ready();
Expand Down
11 changes: 11 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ import { AppComponent } from './app.component';
import { RemoteDevToolsProxy } from '../../ngrx-devtool-proxy/remote-devtools-proxy';
import { IonicGestureConfig } from '../gestures/ionic-gesture-config';
import { StoreModel } from '@shared/models/store.model';
import { ExaminerRecordsProvider } from '@providers/examiner-records/examiner-records';
import { CompressionProvider } from '@providers/compression/compression';
import { LoadingProvider } from '@providers/loader/loader';
import { ExaminerRecordsStoreModule } from '@store/examiner-records/examiner-records.module';
import { examinerRecordsReducer } from '@store/examiner-records/examiner-records.reducer';
import { ExaminerRecordsComponentsModule } from '@pages/examiner-records/components/examiner-records-components.module';

export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
Expand All @@ -90,6 +95,7 @@ const reducers: ActionReducerMap<any> = {
tests: testsReducer,
rekeySearch: rekeySearchReducer,
delegatedRekeySearch: delegatedSearchReducer,
examinerRecords: examinerRecordsReducer,
};

const metaReducers: MetaReducer<any, any>[] = [];
Expand Down Expand Up @@ -134,6 +140,7 @@ if (enableRehydrationPlugin) {
AppInfoStoreModule,
ReferenceDataStoreModule,
AppConfigStoreModule,
ExaminerRecordsStoreModule,
LogsStoreModule,
TestCentreJournalStoreModule,
JournalModule,
Expand All @@ -147,6 +154,7 @@ if (enableRehydrationPlugin) {
},
}),
HammerModule,
ExaminerRecordsComponentsModule,
PipesModule,
],
providers: [
Expand All @@ -168,8 +176,11 @@ if (enableRehydrationPlugin) {
useClass: SentryIonicErrorHandler,
},
AppConfigProvider,
ExaminerRecordsProvider,
AuthenticationProvider,
CompressionProvider,
AppInfoProvider,
LoadingProvider,
DateTimeProvider,
SecureStorage,
IsDebug,
Expand Down
2 changes: 2 additions & 0 deletions src/app/pages/dashboard/dashboard.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { JournalRehydrationPage, JournalRehydrationType } from '@store/journal/j
import { getTests } from '@store/tests/tests.reducer';
import { environment } from '@environments/environment';
import { TestersEnvironmentFile } from '@environments/models/environment.model';
import { LoadExaminerRecordsPreferences } from '@store/examiner-records/examiner-records.actions';

interface DashboardPageState {
appVersion$: Observable<string>;
Expand Down Expand Up @@ -161,6 +162,7 @@ export class DashboardPage extends BasePageComponent implements OnInit, ViewDidE
this.store$.dispatch(ClearCandidateLicenceData());
this.store$.dispatch(ClearVehicleData());
this.store$.dispatch(StoreUnuploadedSlotsInTests());
this.store$.dispatch(LoadExaminerRecordsPreferences());
//guard against calling journal if the user type is a delegated examiner
if (!this.isDelegatedExaminer()) {
this.store$.dispatch(journalActions.LoadJournalSilent());
Expand Down
Loading

0 comments on commit dbf6307

Please sign in to comment.