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

EXUI 1851 #3790

Merged
merged 12 commits into from
Jul 29, 2024
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 Expand Up @@ -1193,6 +1194,49 @@ describe('HearingEditSummaryComponent', () => {
});

it('should return false as no difference in reasonable adjustment', () => {
setAfterPageVisitValues();
const partiesSHV = createSHVEntry();
const partiesHMC = createHMCEntry();

component.serviceHearingValuesModel = {
...initialState.hearings.hearingValues.serviceHearingValuesModel,
parties: partiesSHV
};
component.hearingRequestMainModel = {
...initialState.hearings.hearingRequest.hearingRequestMainModel,
partyDetails: partiesHMC
};

const isDifference = component.pageVisitReasonableAdjustmentChangeExists();

expect(isDifference).toEqual(false);
});

it('should return true as reasonable adjustment required but not confirmed.', () => {
setAfterPageVisitValues();
hearingsService.propertiesUpdatedOnPageVisit.afterPageVisit.reasonableAdjustmentChangesRequired = true;

const partiesSHV = createSHVEntry();
const partiesHMC = createHMCEntry();

component.serviceHearingValuesModel = {
...initialState.hearings.hearingValues.serviceHearingValuesModel,
parties: partiesSHV
};
component.hearingRequestMainModel = {
...initialState.hearings.hearingRequest.hearingRequestMainModel,
partyDetails: partiesHMC
};

const isDifference = component.pageVisitReasonableAdjustmentChangeExists();

expect(isDifference).toEqual(true);
});

it('should return false as reasonable adjustment required and confirmed.', () => {
setAfterPageVisitValues();
hearingsService.propertiesUpdatedOnPageVisit.afterPageVisit.reasonableAdjustmentChangesRequired = true;
hearingsService.propertiesUpdatedOnPageVisit.afterPageVisit.reasonableAdjustmentChangesConfirmed = true;
const partiesSHV = createSHVEntry();
const partiesHMC = createHMCEntry();

Expand All @@ -1211,6 +1255,8 @@ describe('HearingEditSummaryComponent', () => {
});

it('should return true as there is a difference in reasonable adjustment', () => {
setAfterPageVisitValues();
hearingsService.propertiesUpdatedOnPageVisit.afterPageVisit.reasonableAdjustmentChangesRequired = true;
const partiesSHV = createSHVEntry();
const partiesHMC = createHMCEntry();
partiesHMC[1].individualDetails.reasonableAdjustments = ['RA0041', 'RA0044', 'RA0042'];
Expand All @@ -1230,6 +1276,7 @@ describe('HearingEditSummaryComponent', () => {
});

it('should return false as removed party had no reasonable adjustments', () => {
setAfterPageVisitValues();
const partiesSHV: PartyDetailsModel[] = createSHVEntry();

const partiesHMC: PartyDetailsModel[] = createHMCEntry();
Expand Down Expand Up @@ -1262,6 +1309,7 @@ describe('HearingEditSummaryComponent', () => {
});

it('should return false as removed party had no reasonable adjustments test 2', () => {
setAfterPageVisitValues();
const partiesSHV: PartyDetailsModel[] = createSHVEntry();

const partiesHMC: PartyDetailsModel[] = createHMCEntry();
Expand Down Expand Up @@ -1295,6 +1343,7 @@ describe('HearingEditSummaryComponent', () => {
});

it('should return false as added party had no reasonable adjustments', () => {
setAfterPageVisitValues();
const partiesSHV: PartyDetailsModel[] = createSHVEntry();

const partiesHMC: PartyDetailsModel[] = createHMCEntry();
Expand Down Expand Up @@ -1327,6 +1376,8 @@ describe('HearingEditSummaryComponent', () => {
});

it('should return true as party removed from original hmc with reasonable adjustment', () => {
setAfterPageVisitValues();
hearingsService.propertiesUpdatedOnPageVisit.afterPageVisit.reasonableAdjustmentChangesRequired = true;
const partiesSHV = createSHVEntry();
const partiesHMC = createHMCEntry();

Expand Down Expand Up @@ -1363,6 +1414,8 @@ describe('HearingEditSummaryComponent', () => {
});

it('should return true as party to original shv with reasonable adjustment', () => {
setAfterPageVisitValues();
hearingsService.propertiesUpdatedOnPageVisit.afterPageVisit.reasonableAdjustmentChangesRequired = true;
const partiesSHV = createSHVEntry();
const partiesHMC = createHMCEntry();

Expand Down Expand Up @@ -1479,4 +1532,25 @@ describe('HearingEditSummaryComponent', () => {
];
return partiesHMC;
}
function setAfterPageVisitValues() {
hearingsService.propertiesUpdatedOnPageVisit = {
hearingId: 'h000001',
caseFlags: null,
parties: null,
hearingWindow: null,
afterPageVisit: {
reasonableAdjustmentChangesConfirmed: false,
reasonableAdjustmentChangesRequired: false,
nonReasonableAdjustmentChangesRequired: false,
nonReasonableAdjustmentChangesConfirmed: false,
partyDetailsChangesRequired: false,
partyDetailsChangesConfirmed: true,
hearingWindowChangesRequired: false,
hearingFacilitiesChangesRequired: false,
partyDetailsAnyChangesRequired: false,
hearingUnavailabilityDatesChanged: false,
hearingWindowChangesConfirmed: false
}
};
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,14 @@ export class HearingEditSummaryComponent extends RequestHearingPageFlow implemen
const interpreterLanguagesSHV = this.extractInterpreterLanguages(SHVIndividualParties);
const interpreterLanguagesHMC = this.extractInterpreterLanguages(HRMIndividualParties);

return !_.isEqual(interpreterLanguagesSHV, interpreterLanguagesHMC);
if (!_.isEqual(interpreterLanguagesSHV, interpreterLanguagesHMC)){
return true;
}
if (this.hearingsService.propertiesUpdatedOnPageVisit?.afterPageVisit?.reasonableAdjustmentChangesRequired) {
return !this.hearingsService.propertiesUpdatedOnPageVisit?.afterPageVisit?.reasonableAdjustmentChangesConfirmed;
}
// There are no changes for reasonable adjustments and language interpreter flags when SHV compared with HMC
return false;
}

private extractReasonableAdjustments(partyDetails: PartyDetailsModel[]) {
Expand Down Expand Up @@ -580,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.hasHearingDurationChagned(this.hearingRequestMainModel.hearingDetails.duration, this.serviceHearingValuesModel.duration)){
StoneBenHMCTS marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -143,8 +142,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 @@ -170,8 +172,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 @@ -294,18 +299,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 @@ -345,20 +353,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 @@ -135,20 +136,15 @@ export class HearingTimingSectionComponent implements OnInit {
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same spelling mistake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved, thank you


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),

StoneBenHMCTS marked this conversation as resolved.
Show resolved Hide resolved
HearingsUtils.getPartiesNotAvailableDates(this.hearingRequestMainModel.partyDetails),
HearingsUtils.getPartiesNotAvailableDates(this.hearingRequestToCompareMainModel.partyDetails)
);
this.showActionNeededLabelForPageTitle =
Expand All @@ -165,36 +161,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);
}
}
Loading