Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cb2-12599): ensure additional examiner notes appear in the correc… #1497

Merged
merged 5 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand All @@ -39,9 +39,9 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand All @@ -59,9 +59,9 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand All @@ -77,9 +77,9 @@ jobs:
matrix:
node-version: [18.18.0]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand All @@ -92,25 +92,30 @@ jobs:
runs-on: X64
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_MGMT_ROLE }}
aws-region: ${{ secrets.DVSA_AWS_REGION }}
role-session-name: 'cvs-app-vtm'
- uses: aws-actions/aws-secretsmanager-get-secrets@v1

- uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: sonarqube-gha
parse-json-secrets: true

- name: Install dependencies
run: npm ci --include=optional

- name: Run SonarQube scanner
run: |
npm run sonar-scanner -- \
-Dsonar.host.url=${{ env.SONARQUBE_GHA_URL }} \
-Dsonar.token=${{ env.SONARQUBE_GHA_TOKEN }} \
-Dsonar.login=${{ env.SONARQUBE_GHA_TOKEN }} \
-Dsonar.projectName=${{ github.repository }} \
-Dsonar.projectVersion=1.0.${{ github.run_id }}
-Dsonar.projectVersion=1.0.${{ github.run_id }}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { KeyValue, ViewportScroller } from '@angular/common';
import {
AfterContentInit,
Component, inject, OnDestroy, OnInit,
AfterContentInit, Component, OnDestroy, OnInit, inject,
} from '@angular/core';
import { FormArray, NgControl } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { AdditionalExaminerNotes } from '@dvsa/cvs-type-definitions/types/v3/tech-record/get/hgv/complete';
import { TechRecordType } from '@dvsa/cvs-type-definitions/types/v3/tech-record/tech-record-vehicle-type';
import { BaseControlComponent } from '@forms/components/base-control/base-control.component';
import { CustomControl, CustomFormControl } from '@forms/services/dynamic-form.types';
import { ReasonForEditing } from '@models/vehicle-tech-record.model';
import { Store } from '@ngrx/store';
import { TechnicalRecordService } from '@services/technical-record/technical-record.service';
import { ReplaySubject, takeUntil } from 'rxjs';
import { updateScrollPosition } from '@store/technical-records';
import { TechnicalRecordServiceState } from '@store/technical-records/reducers/technical-record-service.reducer';
import { Store } from '@ngrx/store';
import { ActivatedRoute, Router } from '@angular/router';
import { ReasonForEditing } from '@models/vehicle-tech-record.model';
import { AdditionalExaminerNotes } from '@dvsa/cvs-type-definitions/types/v3/tech-record/get/hgv/complete';
import { ReplaySubject, takeUntil } from 'rxjs';

@Component({
selector: 'app-adr-examiner-notes-history',
Expand Down Expand Up @@ -62,7 +61,9 @@ export class AdrExaminerNotesHistoryEditComponent extends BaseControlComponent i
}

getAdditionalExaminerNotes(): AdditionalExaminerNotes[] {
return this.currentTechRecord?.techRecord_adrDetails_additionalExaminerNotes ?? [];
return (this.currentTechRecord?.techRecord_adrDetails_additionalExaminerNotes ?? []).sort(
(a, b) => +new Date(b.createdAtDate ?? '') - +new Date(a.createdAtDate ?? ''),
);
}

get currentAdrNotesPage(): AdditionalExaminerNotes[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ng-container *ngIf="control">
<ng-container *ngIf="adrNotes">
<ng-container *ngIf="getAdditionalExaminerNotes() as adrNotes">
<section class="govuk-!-margin-top-4">
<label *ngIf="control.meta?.label" class="govuk-label govuk-label--m">
{{ control.meta.label }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ describe('AdrExaminerNotesHistoryViewComponent', () => {
component.currentTechRecord.techRecord_adrDetails_additionalExaminerNotes = [
{ createdAtDate: 'test', lastUpdatedBy: 'test', note: 'test note' },
];
expect(component.adrNotes).toEqual([{ createdAtDate: 'test', lastUpdatedBy: 'test', note: 'test note' }]);
expect(component.getAdditionalExaminerNotes()).toEqual([{ createdAtDate: 'test', lastUpdatedBy: 'test', note: 'test note' }]);
});

it('should return an empty array if the adr examiner notes is undefined', () => {
component.currentTechRecord = { ...MOCK_HGV };
component.currentTechRecord.techRecord_adrDetails_additionalExaminerNotes = undefined;
expect(component.adrNotes).toEqual([]);
expect(component.getAdditionalExaminerNotes()).toEqual([]);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import {
Component, inject, OnDestroy, OnInit,
} from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { BaseControlComponent } from '@forms/components/base-control/base-control.component';
import { AdditionalExaminerNotes } from '@dvsa/cvs-type-definitions/types/v3/tech-record/get/hgv/complete';
import { TechRecordType } from '@dvsa/cvs-type-definitions/types/v3/tech-record/tech-record-vehicle-type';
import { BaseControlComponent } from '@forms/components/base-control/base-control.component';
import { RouterService } from '@services/router/router.service';
import { TechnicalRecordService } from '@services/technical-record/technical-record.service';
import {
map, Observable, Subject, takeUntil,
} from 'rxjs';
import { RouterService } from '@services/router/router.service';

@Component({
selector: 'app-adr-examiner-notes-history-view',
Expand Down Expand Up @@ -47,8 +47,10 @@ export class AdrExaminerNotesHistoryViewComponent extends BaseControlComponent i
this.cdr.detectChanges();
}

get adrNotes(): AdditionalExaminerNotes[] {
return this.currentTechRecord?.techRecord_adrDetails_additionalExaminerNotes ?? [];
getAdditionalExaminerNotes(): AdditionalExaminerNotes[] {
return (this.currentTechRecord?.techRecord_adrDetails_additionalExaminerNotes ?? []).sort(
(a, b) => +new Date(b.createdAtDate ?? '') - +new Date(a.createdAtDate ?? ''),
);
}

get currentAdrNotesPage(): AdditionalExaminerNotes[] {
Expand Down
Loading