Skip to content

Commit

Permalink
feat: (mes-10280) - move logic for filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsetterfield committed Feb 25, 2025
1 parent e5d0353 commit e185554
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -758,55 +758,4 @@ describe('ExaminerRecordsPage', () => {
expect(component.displayNoDataCard(data)).toBeTrue();
});
});

describe('filterResults', () => {
it('should return only tests with activityCode in [1, 2, 3, 4, 5] and extendedTest is false', () => {
const tests: ExaminerRecordModel[] = [
{ activityCode: 1, extendedTest: false },
{ activityCode: 2, extendedTest: true },
{ activityCode: 3, extendedTest: false },
{ activityCode: 6, extendedTest: false },
{ activityCode: 4, extendedTest: false },
{ activityCode: 5, extendedTest: true },
] as ExaminerRecordModel[];
const result = component.filterResults(tests);
const expectedResults: ExaminerRecordModel[] = [
{ activityCode: 1, extendedTest: false },
{ activityCode: 3, extendedTest: false },
{ activityCode: 4, extendedTest: false },
] as ExaminerRecordModel[];

expect(result).toEqual(expectedResults);
});

it('should return an empty array if no tests match the criteria', () => {
const tests: ExaminerRecordModel[] = [
{ activityCode: 6, extendedTest: false },
{ activityCode: 7, extendedTest: true },
] as ExaminerRecordModel[];
const result = component.filterResults(tests);

expect(result).toEqual([]);
});

it('should return an empty array if input array is empty', () => {
const tests: ExaminerRecordModel[] = [] as ExaminerRecordModel[];
const result = component.filterResults(tests);

expect(result).toEqual([]);
});

it('should return only tests with activityCode in [1, 2, 3, 4, 5] and extendedTest is false when all tests match', () => {
const tests: ExaminerRecordModel[] = [
{ activityCode: 1, extendedTest: false },
{ activityCode: 2, extendedTest: false },
{ activityCode: 3, extendedTest: false },
{ activityCode: 4, extendedTest: false },
{ activityCode: 5, extendedTest: false },
] as ExaminerRecordModel[];
const result = component.filterResults(tests);

expect(result).toEqual(tests);
});
});
});
6 changes: 4 additions & 2 deletions src/app/pages/examiner-records/examiner-records.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export class ExaminerRecordsEffects {
}),
// Remove blank properties from returned records
map(
(examinerHash: string) =>
(examinerHash ? this.compressionProvider.extract(examinerHash) : null) as ExaminerRecordModel[]
(examinerHash: string) => (examinerHash ? this.compressionProvider.extract(examinerHash) : null) as unknown[]
),
map((examinerRecords): ExaminerRecordModel[] => {
return examinerRecords
Expand All @@ -64,6 +63,9 @@ export class ExaminerRecordsEffects {
if (newRecord.extendedTest) {
newRecord.extendedTest = JSON.parse(newRecord.extendedTest);
}
if (newRecord.activityCode) {
newRecord.activityCode = Number(newRecord.activityCode);
}
return newRecord as ExaminerRecordModel;
})
: null;
Expand Down
31 changes: 22 additions & 9 deletions src/app/pages/examiner-records/examiner-records.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<ion-row class="ion-padding">
<ion-col [size]="accessibilityService.getTextZoomClass() === 'text-zoom-x-large' ? 45 : 48">
<ion-row>
<label>Location</label>
<label id="examiner-records-location-label">Location</label>
</ion-row>
<ion-row class="padding-top-10">
<ion-select
Expand All @@ -75,7 +75,7 @@
<ion-col></ion-col>
<ion-col [size]="accessibilityService.getTextZoomClass() === 'text-zoom-x-large' ? 23 : 20">
<ion-row>
<label>Test category</label>
<label id="examiner-records-test-category-label">Test category</label>
</ion-row>
<ion-row class="padding-top-10">
<ion-select
Expand All @@ -98,7 +98,7 @@
<ion-col></ion-col>
<ion-col size="25">
<ion-row>
<label>Date range</label>
<label id="examiner-records-date-range-label">Date range</label>
</ion-row>
<ion-row class="padding-top-10">
<ion-select
Expand Down Expand Up @@ -135,7 +135,7 @@
</ion-col>
<ion-col></ion-col>
<ion-col class="ion-align-items-center display-flex" size="auto">
<label>Hide charts</label>
<label id="examiner-records-hide-chart-label">Hide charts</label>
</ion-col>
<ion-col size="7" class="display-flex ion-float-end ion-align-items-center">
<input
Expand Down Expand Up @@ -457,15 +457,28 @@
<ion-card-title>
<ion-row>
<ion-col>
<ion-text class="des-header-style-4 fault-heading">No data available</ion-text>
<ion-text id="examiner-records-no-data-text" class="des-header-style-4 fault-heading" >No data available</ion-text>
</ion-col>
</ion-row>
</ion-card-title>
</ion-card-header>
<ion-card-content class="mes-text-align-centre">
<ion-text class="mes-data">
No driving test data available for this period.<br /><br />Select another date range.
</ion-text>
<ion-card-content>
<ion-row>
<ion-col class="mes-text-align-centre">
<ion-text id="examiner-records-no-driving-test-data-text" class="mes-data">
No driving test data available for this period.
</ion-text>
</ion-col>
</ion-row>
<ion-row>
</ion-row>
<ion-row>
<ion-col id="examiner-records-select-another-range-text" class="mes-text-align-centre">
<ion-text class="mes-data mes-text-align-centre">
Select another date range.
</ion-text>
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
</ion-content>
Loading

0 comments on commit e185554

Please # to comment.