Skip to content

Commit

Permalink
Merge pull request #3790 from hmcts/EXUI-1851
Browse files Browse the repository at this point in the history
EXUI 1851
  • Loading branch information
StoneBenHMCTS authored Jul 29, 2024
2 parents 970814d + b342d20 commit 8977f37
Show file tree
Hide file tree
Showing 20 changed files with 1,212 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('HearingEditSummaryComponent', () => {
reasonableAdjustmentChangesRequired: true,
nonReasonableAdjustmentChangesRequired: true,
partyDetailsChangesRequired: true,
hearingWindowChangesRequired: false,
hearingWindowChangesRequired: true,
hearingFacilitiesChangesRequired: true,
partyDetailsAnyChangesRequired: false,
hearingUnavailabilityDatesChanged: false
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('HearingEditSummaryComponent', () => {
reasonableAdjustmentChangesRequired: true,
nonReasonableAdjustmentChangesRequired: true,
partyDetailsChangesRequired: true,
hearingWindowChangesRequired: false,
hearingWindowChangesRequired: true,
hearingFacilitiesChangesRequired: true,
partyDetailsAnyChangesRequired: false,
hearingUnavailabilityDatesChanged: false
Expand Down Expand Up @@ -356,7 +356,9 @@ describe('HearingEditSummaryComponent', () => {
it('should set hearingWindowChangesRequired to false if no hearing window', () => {
hearingsService.propertiesUpdatedOnPageVisit = null;
component.hearingRequestMainModel.hearingDetails.hearingWindow = null;

component.serviceHearingValuesModel.hearingWindow = null;
component.hearingRequestMainModel.hearingDetails.duration = null;
component.serviceHearingValuesModel.duration = null;
component.ngOnInit();
expect(hearingsService.propertiesUpdatedOnPageVisit.afterPageVisit.hearingWindowChangesRequired).toEqual(false);
});
Expand Down Expand Up @@ -610,10 +612,9 @@ describe('HearingEditSummaryComponent', () => {

it('should set the hearingWindowChangesRequired to false', () => {
hearingsService.propertiesUpdatedOnPageVisit = null;
component.hearingRequestMainModel.hearingDetails.hearingWindow = {
firstDateTimeMustBe: '2024-02-01T10:00:00'
};
component.hearingRequestMainModel.hearingDetails.hearingWindow = component.serviceHearingValuesModel.hearingWindow;
component.serviceHearingValuesModel.parties = initialState.hearings.hearingRequestToCompare.hearingRequestMainModel.partyDetails;
component.serviceHearingValuesModel.duration = 60;
component.ngOnInit();
expect(hearingsService.propertiesUpdatedOnPageVisit.afterPageVisit.hearingWindowChangesRequired).toEqual(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,27 @@ export class HearingEditSummaryComponent extends RequestHearingPageFlow implemen
return false;
}
const hearingWindowHMC = this.hearingRequestMainModel.hearingDetails.hearingWindow;

if (this.hearingRequestMainModel.partyDetails) {
if (HearingsUtils.hasPartyUnavailabilityDatesChanged(this.hearingRequestToCompareMainModel.partyDetails, this.serviceHearingValuesModel.parties)){
return true;
}
}
if ((hearingWindowHMC?.firstDateTimeMustBe) ||
(hearingWindowHMC?.dateRangeStart || hearingWindowHMC?.dateRangeEnd)) {
return HearingsUtils.hasPartyUnavailabilityDatesChanged(this.hearingRequestToCompareMainModel.partyDetails, this.serviceHearingValuesModel.parties);
if (HearingsUtils.hasHearingDatesChanged(this.hearingRequestMainModel.hearingDetails.hearingWindow, this.serviceHearingValuesModel.hearingWindow)){
return true;
}
}
if (this.hearingRequestMainModel.hearingDetails.duration){
if (HearingsUtils.hasHearingDurationChanged(this.hearingRequestMainModel.hearingDetails.duration, this.serviceHearingValuesModel.duration)){
return true;
}
}
if (this.hearingRequestMainModel.hearingDetails.hearingPriorityType){
if (HearingsUtils.hasHearingPriorityChanged(this.hearingRequestMainModel.hearingDetails.hearingPriorityType, this.serviceHearingValuesModel.hearingPriorityType)){
return true;
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ <h2 class="govuk-heading-m">
Earliest start date: {{ earliestHearingDate }}
<br>
Latest end date: {{ latestHearingDate }}
<exui-amendment-label *ngIf="hearingDateChanged" [displayLabel]="amendmentLabelEnum.AMENDED">
</exui-amendment-label>
</div>
<div *ngIf="specificDateSelection === radioOptions.YES">
<dt class="heading-h3 bottom-0">The first date of the hearing must be</dt>
{{ firstHearingDate }}
<exui-amendment-label *ngIf="hearingDateChanged" [displayLabel]="amendmentLabelEnum.AMENDED">
</exui-amendment-label>
</div>
</div>
<div class="govuk-summary-list__actions">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { initialState } from '../../../../hearing.test.data';
import { initialState, serviceHearingValuesModel } from '../../../../hearing.test.data';
import { LovRefDataModel } from '../../../../models/lovRefData.model';
import { HearingsService } from '../../../../services/hearings.service';
import { HearingTimingSectionComponent } from './hearing-timing-section.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { UnavailabilityRangeModel } from '../../../../models/unavailabilityRange.model';
import { UnavailabilityType } from '../../../../models/hearings.enum';

describe('HearingTimingSectionComponent', () => {
Expand Down Expand Up @@ -150,8 +149,11 @@ describe('HearingTimingSectionComponent', () => {
});

it('should display amended label for unavailability dates changed', () => {
const unavailabilityDates: UnavailabilityRangeModel[] = [{ unavailableFromDate: '2024-12-10T09:00:00.000Z', unavailableToDate: '2024-12-12T09:00:00.000Z', unavailabilityType: UnavailabilityType.ALL_DAY }];
component.serviceHearingValuesModel.parties[0].unavailabilityRanges = unavailabilityDates;
component.hearingRequestMainModel.partyDetails[0].unavailabilityRanges = [{
unavailableFromDate: '2024-12-10T09:00:00.000Z',
unavailableToDate: '2024-12-12T09:00:00.000Z',
unavailabilityType: UnavailabilityType.ALL_DAY
}];
hearingsService.propertiesUpdatedOnPageVisit = {
hearingId: 'h000001',
caseFlags: initialState.hearings.hearingValues.serviceHearingValuesModel.caseFlags,
Expand All @@ -177,8 +179,11 @@ describe('HearingTimingSectionComponent', () => {
});

it('should display action label for unavailability dates changed', () => {
const unavailabilityDates: UnavailabilityRangeModel[] = [{ unavailableFromDate: '2024-12-10T09:00:00.000Z', unavailableToDate: '2024-12-12T09:00:00.000Z', unavailabilityType: UnavailabilityType.ALL_DAY }];
component.serviceHearingValuesModel.parties[0].unavailabilityRanges = unavailabilityDates;
component.serviceHearingValuesModel.parties[0].unavailabilityRanges = [{
unavailableFromDate: '2024-12-10T09:00:00.000Z',
unavailableToDate: '2024-12-12T09:00:00.000Z',
unavailabilityType: UnavailabilityType.ALL_DAY
}];
hearingsService.propertiesUpdatedOnPageVisit = {
hearingId: 'h000001',
caseFlags: initialState.hearings.hearingValues.serviceHearingValuesModel.caseFlags,
Expand Down Expand Up @@ -301,18 +306,21 @@ describe('HearingTimingSectionComponent', () => {
}
}
};
component.serviceHearingValuesModel = {
...serviceHearingValuesModel, hearingWindow: {
dateRangeStart: '2024-03-22T09:00:00.000Z',
dateRangeEnd: '2024-03-26T09:00:00.000Z'
}
};

component.ngOnInit();
expect(component.hearingDateChanged).toEqual(false);
});

it('should return true if "firstDateTimeMustBe" changed', () => {
component.hearingRequestMainModel = {
...initialState.hearings.hearingRequest.hearingRequestMainModel,
hearingDetails: {
...initialState.hearings.hearingRequest.hearingRequestMainModel.hearingDetails,
hearingWindow: {
firstDateTimeMustBe: '2024-03-22T09:00:00.000Z'
}
component.serviceHearingValuesModel = {
...serviceHearingValuesModel, hearingWindow: {
firstDateTimeMustBe: '2024-03-22T09:00:00.000Z'
}
};
component.hearingRequestToCompareMainModel = {
Expand Down Expand Up @@ -352,20 +360,18 @@ describe('HearingTimingSectionComponent', () => {
});

it('should return false if no hearing window', () => {
component.hearingRequestMainModel = {
...initialState.hearings.hearingRequest.hearingRequestMainModel,
hearingDetails: {
...initialState.hearings.hearingRequest.hearingRequestMainModel.hearingDetails,
hearingWindow: null
}
};
component.hearingRequestToCompareMainModel = {
...initialState.hearings.hearingRequestToCompare.hearingRequestMainModel,
hearingDetails: {
...initialState.hearings.hearingRequestToCompare.hearingRequestMainModel.hearingDetails,
hearingWindow: null
}
};
component.serviceHearingValuesModel = {
...serviceHearingValuesModel,
hearingWindow: {}
};

component.ngOnInit();
expect(component.hearingDateChanged).toEqual(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class HearingTimingSectionComponent implements OnInit {
@Input() public serviceHearingValuesModel: ServiceHearingValuesModel;
@Output() public changeEditHearing = new EventEmitter<EditHearingChangeConfig>();

constructor(private readonly hearingsService: HearingsService) {}
constructor(private readonly hearingsService: HearingsService) {
}

public hearingLength: string;
public specificDate: string;
Expand Down Expand Up @@ -134,20 +135,14 @@ export class HearingTimingSectionComponent implements OnInit {
}

private setAmendmentLabels(): void {
this.hearingLengthChanged = !_.isEqual(
this.hearingRequestToCompareMainModel.hearingDetails.duration,
this.hearingRequestMainModel.hearingDetails.duration
);
this.hearingLengthChanged = HearingsUtils.hasHearingDurationChanged(this.hearingRequestToCompareMainModel.hearingDetails.duration, this.hearingRequestMainModel.hearingDetails.duration);

this.hearingDateChanged = this.isHearingDateChanged();
this.hearingDateChanged = HearingsUtils.hasHearingDatesChanged(this.hearingRequestToCompareMainModel.hearingDetails.hearingWindow, this.hearingRequestMainModel.hearingDetails.hearingWindow);

this.hearingPriorityChanged = !_.isEqual(
this.hearingRequestToCompareMainModel.hearingDetails.hearingPriorityType,
this.hearingRequestMainModel.hearingDetails.hearingPriorityType
);
this.hearingPriorityChanged = HearingsUtils.hasHearingPriorityChanged(this.hearingRequestToCompareMainModel.hearingDetails.hearingPriorityType, this.hearingRequestMainModel.hearingDetails.hearingPriorityType);

this.hearingUnavailabilityDatesChanged = !_.isEqual(
HearingsUtils.getPartiesNotAvailableDates(this.serviceHearingValuesModel.parties),
HearingsUtils.getPartiesNotAvailableDates(this.hearingRequestMainModel.partyDetails),
HearingsUtils.getPartiesNotAvailableDates(this.hearingRequestToCompareMainModel.partyDetails)
);
this.showActionNeededLabelForPageTitle =
Expand All @@ -164,36 +159,4 @@ export class HearingTimingSectionComponent implements OnInit {
this.hearingUnavailabilityDatesConfirmed
);
}

private isHearingDateChanged(): boolean {
const hearingWindowToCompare = this.hearingRequestToCompareMainModel.hearingDetails.hearingWindow;
const hearingWindow = this.hearingRequestMainModel.hearingDetails.hearingWindow;

if (hearingWindow?.dateRangeStart || hearingWindow?.dateRangeEnd) {
if (hearingWindow?.dateRangeStart) {
if (!_.isEqual(
new Date(hearingWindowToCompare.dateRangeStart).setHours(0, 0, 0, 0),
new Date(hearingWindow.dateRangeStart).setHours(0, 0, 0, 0)
)) {
return true;
}
}
if (hearingWindow?.dateRangeEnd) {
if (!_.isEqual(
new Date(hearingWindowToCompare.dateRangeEnd).setHours(0, 0, 0, 0),
new Date(hearingWindow.dateRangeEnd).setHours(0, 0, 0, 0)
)) {
return true;
}
}
}

if (hearingWindow?.firstDateTimeMustBe) {
return !_.isEqual(
new Date(hearingWindowToCompare.firstDateTimeMustBe).setHours(0, 0, 0, 0),
new Date(hearingWindow.firstDateTimeMustBe).setHours(0, 0, 0, 0)
);
}
return !_.isEqual(hearingWindow, hearingWindowToCompare);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class HearingRequirementsComponent extends RequestHearingPageFlow impleme
*/
public initializeHearingRequestFromHearingValues(): void {
// Get hearing window from hearingRequestMainModel
let hearingWindow = HearingsUtils.getHearingWindow(this.hearingRequestMainModel);
let hearingWindow = HearingsUtils.getHRMHearingWindow(this.hearingRequestMainModel);
// Get hearing window from serviceHearingValuesModel if null
if (!hearingWindow && this.serviceHearingValuesModel.hearingWindow) {
hearingWindow = this.serviceHearingValuesModel.hearingWindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ <h1 class="govuk-fieldset__heading">{{ 'Length of hearing' | rpxTranslate }}</h1
name="durationmins" type="text" inputmode="numeric" value="" formControlName="minutes">
</div>
</div>
<exui-amendment-label id="length-of-hearing-label" *ngIf="!hearingWindowChangesConfirmed && hearingWindowChangesRequired && durationChanged"
[displayLabel]="amendmentLabelEnum.AMENDED">
</exui-amendment-label>
</div>
</fieldset>
</div>
Expand All @@ -53,7 +56,7 @@ <h3 class="govuk-fieldset__heading">
</exui-amendment-label>
</h3>
</legend>
<div class="govuk-hint">{{ 'Availability of all the parties will be taken into account when scheduling this hearing.' | rpxTranslate }}</div>
<div class="govuk-hint">{{ 'Availability of all the parties will be taken into account when scheduling this hearing' | rpxTranslate }}</div>
<span class="govuk-error-message" *ngIf="hearingPriorityDateError">
<span class="govuk-visually-hidden">{{ 'Error:' | rpxTranslate }}</span> {{hearingPriorityDateError | rpxTranslate }}
</span>
Expand All @@ -74,6 +77,9 @@ <h3 class="govuk-fieldset__heading">
<div class="govuk-form-group">
<div class="govuk-!-margin-right-1 first-hearing-date">
<xuilib-gov-uk-date [config]="firstHearingDate" [formGroup]="firstHearingFormGroup" [errorMessage]="firstDateOfHearingError"></xuilib-gov-uk-date>
<exui-amendment-label id="first-date-amendment-label" *ngIf="!hearingWindowChangesConfirmed && hearingWindowChangesRequired && firstDateTimeMustBeChanged"
[displayLabel]="amendmentLabelEnum.AMENDED">
</exui-amendment-label>
</div>
</div>
</div>
Expand All @@ -90,9 +96,15 @@ <h3 class="govuk-fieldset__heading">
</span>
<div class="govuk-form-group">
<xuilib-gov-uk-date [config]="earliestHearingDate" [formGroup]="earliestHearingFormGroup" [errorMessage]="earliestDateOfHearingError"></xuilib-gov-uk-date>
<exui-amendment-label id="earliest-hearing-date-amendment-label" *ngIf="!hearingWindowChangesConfirmed && hearingWindowChangesRequired && dateRangeStartChanged"
[displayLabel]="amendmentLabelEnum.AMENDED">
</exui-amendment-label>
</div>
<div class="govuk-form-group">
<xuilib-gov-uk-date [config]="latestHearingDate" [formGroup]="latestHearingFormGroup" [errorMessage]="latestDateOfHearingError"></xuilib-gov-uk-date>
<exui-amendment-label id="latest-hearing-date-amendment-label" *ngIf="!hearingWindowChangesConfirmed && hearingWindowChangesRequired && dateRangeEndChanged"
[displayLabel]="amendmentLabelEnum.AMENDED">
</exui-amendment-label>
</div>
</div>
</div>
Expand All @@ -106,7 +118,11 @@ <h3 class="govuk-fieldset__heading">
<div class="govuk-form-group govuk-!-margin-top-5" [ngClass]="{'govuk-form-group--error': hearingPriorityError}">
<fieldset class="govuk-fieldset" id="hearing-priority">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--s">
<h3 class="govuk-fieldset__heading">{{ 'What is the priority of this hearing?' | rpxTranslate }}</h3>
<h3 class="govuk-fieldset__heading">{{ 'What is the priority of this hearing?' | rpxTranslate }}
<exui-amendment-label id="hearing-priority-amendment-label" *ngIf="!hearingWindowChangesConfirmed && hearingWindowChangesRequired && priorityChanged"
[displayLabel]="amendmentLabelEnum.AMENDED">
</exui-amendment-label>
</h3>
</legend>
<span class="govuk-error-message" *ngIf="hearingPriorityError">
<span class="govuk-visually-hidden">{{ 'Error:' | rpxTranslate }}</span> {{hearingPriorityError | rpxTranslate }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,18 @@ describe('HearingTimingComponent', () => {
it('should get getFormData', () => {
component.hearingRequestMainModel.hearingDetails.hearingWindow = {};
component.hearingRequestMainModel.hearingDetails.hearingWindow.firstDateTimeMustBe = '01-01-2021';
component.getFormData();
component.getFormData(0, component.hearingRequestMainModel.hearingDetails.hearingWindow, '');
expect(component.checkedHearingAvailability).toBe(RadioOptions.YES);
component.hearingRequestMainModel.hearingDetails.duration = 70;
component.hearingRequestMainModel.hearingDetails.hearingPriorityType = 'Urgent';
component.hearingRequestMainModel.hearingDetails.hearingWindow = null;
component.getFormData();
component.getFormData(70, null, 'Urgent');
expect(component.priorityFormInfo.hours).toBe('1');
expect(component.priorityFormInfo.minutes).toBe('10');
expect(component.priorityFormInfo.priority).toBe('Urgent');
expect(component.checkedHearingAvailability).toBe(RadioOptions.NO);
component.hearingRequestMainModel.hearingDetails.hearingWindow = { dateRangeStart: '01-01-2021' };
component.getFormData();
component.getFormData(0, component.hearingRequestMainModel.hearingDetails.hearingWindow, '');
expect(component.checkedHearingAvailability).toBe(RadioOptions.CHOOSE_DATE_RANGE);
component.hearingRequestMainModel.hearingDetails.hearingWindow = { dateRangeEnd: '01-01-2021' };
component.getFormData();
component.getFormData(0, component.hearingRequestMainModel.hearingDetails.hearingWindow, '');
expect(component.checkedHearingAvailability).toBe(RadioOptions.CHOOSE_DATE_RANGE);
});

Expand Down Expand Up @@ -395,7 +392,7 @@ describe('HearingTimingComponent', () => {
component.showDateAvailability();
component.prepareHearingRequestData();
fixture.detectChanges();
expect(component.hearingRequestMainModel.hearingDetails.hearingWindow.dateRangeEnd).toBe('2021-01-01T00:00:00.000Z');
expect(component.hearingRequestMainModel.hearingDetails.hearingWindow.dateRangeEnd).toBe('2022-11-30T00:00:00.000Z');
});

it('should check date selection format for form data', () => {
Expand Down
Loading

0 comments on commit 8977f37

Please sign in to comment.