Skip to content

Commit

Permalink
VIH-11046 Added restrictions to screening participants and endpoints (#…
Browse files Browse the repository at this point in the history
…1433)

* Added restriction to screening participants and endpoints recently added, within an edit-hearing. Provided text to advise user to save booking first

* edit hearing - logic flip

* fixed assertion

* Fixed broken test. Used wrong assertion, changed from toBe to toEqual

* changed from sip to id

* Implemented fix for VIH-11057 - external ref id not being mapped correctly for endpoints models, on preexisting endpoints.

(cherry picked from commit f7489b8)
  • Loading branch information
will-craig authored and Shaed Parkar committed Oct 24, 2024
1 parent 63bf1bd commit c23f317
Show file tree
Hide file tree
Showing 20 changed files with 228 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function initHearingRequest(): HearingModel {
pin: 'pin',
username: '[email protected]',
contactEmail: '[email protected]',
interpretationLanguage: undefined
interpretationLanguage: undefined,
externalReferenceId: 'ex1'
}
];
return newHearing;
Expand Down Expand Up @@ -212,7 +213,14 @@ describe('EndpointsComponent', () => {
featureServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(true));
component.ngOnInit();
component.videoEndpoints = [
{ id: '1', displayName: 'Test', defenceAdvocate: null, interpretationLanguage: undefined, screening: undefined }
{
id: '1',
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined,
externalReferenceId: '1'
}
];
component.saveEndpoints();
expect(routerSpy.navigate).toHaveBeenCalledWith(['/other-information']);
Expand All @@ -232,7 +240,8 @@ describe('EndpointsComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
component.onEndpointAdded(endpoint);
expect(component.videoEndpoints).toContain(endpoint);
Expand All @@ -244,7 +253,8 @@ describe('EndpointsComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
component.videoEndpoints = [endpoint];
component.onEndpointAdded(endpoint);
Expand All @@ -255,8 +265,22 @@ describe('EndpointsComponent', () => {
describe('onEndpointUpdated', () => {
beforeEach(() => {
component.videoEndpoints = [
{ id: '1', displayName: 'Test', defenceAdvocate: null, interpretationLanguage: undefined, screening: undefined },
{ id: '2', displayName: 'Test2', defenceAdvocate: null, interpretationLanguage: undefined, screening: undefined }
{
id: '1',
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined,
externalReferenceId: '1'
},
{
id: '2',
displayName: 'Test2',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined,
externalReferenceId: '1'
}
];
});

Expand All @@ -266,15 +290,17 @@ describe('EndpointsComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
component.videoEndpoints = [endpoint];
const updatedEndpoint = {
id: '1',
displayName: 'Updated',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
component.onEndpointUpdated({ original: endpoint, updated: updatedEndpoint });
expect(component.videoEndpoints).toContain(updatedEndpoint);
Expand All @@ -286,14 +312,16 @@ describe('EndpointsComponent', () => {
displayName: 'DoesNotExist',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
const updatedEndpoint = {
id: '1',
displayName: 'Updated',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
component.onEndpointUpdated({ original: endpoint, updated: updatedEndpoint });
expect(component.videoEndpoints).not.toContain(endpoint);
Expand All @@ -303,8 +331,22 @@ describe('EndpointsComponent', () => {
describe('onEndpointSelectedForDeletion', () => {
beforeEach(() => {
component.videoEndpoints = [
{ id: '1', displayName: 'Test', defenceAdvocate: null, interpretationLanguage: undefined, screening: undefined },
{ id: '2', displayName: 'Test2', defenceAdvocate: null, interpretationLanguage: undefined, screening: undefined }
{
id: '1',
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined,
externalReferenceId: '1'
},
{
id: '2',
displayName: 'Test2',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined,
externalReferenceId: '1'
}
];
});

Expand All @@ -314,7 +356,8 @@ describe('EndpointsComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
component.onEndpointSelectedForDeletion(endpoint);
expect(component.videoEndpoints).not.toContain(endpoint);
Expand All @@ -326,7 +369,8 @@ describe('EndpointsComponent', () => {
displayName: 'Test3',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
component.onEndpointSelectedForDeletion(endpoint);
expect(component.videoEndpoints.length).toBe(2);
Expand All @@ -340,7 +384,8 @@ describe('EndpointsComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: '1'
};
component.onEndpointSelectedForEdit(endpoint);
expect(component.videoEndpointToEdit).toBe(endpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class EndpointsComponent extends BookingBaseComponent implements OnInit,

const newEndpointsArray: EndpointModel[] = [];
for (const vapDto of this.videoEndpoints) {
const endpointModel = new EndpointModel();
const endpointModel = new EndpointModel(vapDto.externalReferenceId);
endpointModel.id = vapDto.id;
endpointModel.displayName = vapDto.displayName;
endpointModel.defenceAdvocate = vapDto.defenceAdvocate?.email;
Expand Down Expand Up @@ -197,7 +197,8 @@ export class EndpointsComponent extends BookingBaseComponent implements OnInit,
}
: null,
interpretationLanguage: e.interpretationLanguage,
screening: e.screening
screening: e.screening,
externalReferenceId: e.externalReferenceId
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface VideoAccessPointDto {
defenceAdvocate?: EndpointLink;
interpretationLanguage: InterpreterSelectedDto; // This should not be optional once the backend is implemented
screening: ScreeningDto;
externalReferenceId: string;
}

export interface EndpointLink {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentFixture, TestBed, fakeAsync, flush } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { VideoEndpointFormComponent } from './video-endpoint-form.component';
import { VideoAccessPointDto } from '../models/video-access-point.model';
Expand Down Expand Up @@ -83,7 +83,8 @@ describe('VideoEndpointFormComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
};
component.form.setValue({
displayName: dto.displayName,
Expand All @@ -110,14 +111,16 @@ describe('VideoEndpointFormComponent', () => {
displayName: 'Original',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
};
const updatedDto: VideoAccessPointDto = {
id: '1',
displayName: 'Updated',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
};
component.existingVideoEndpoint = originalDto;
component.form.setValue({
Expand All @@ -134,11 +137,11 @@ describe('VideoEndpointFormComponent', () => {

const rep = component.availableRepresentatives[0];
// update the input field with the email of the first participant via the debug fixture element
const displayNameInput = fixture.nativeElement.querySelector('[id="displayName"') as HTMLInputElement;
const displayNameInput = fixture.nativeElement.querySelector('[id="displayName"]') as HTMLInputElement;
displayNameInput.value = 'Test Endpoint';
displayNameInput.dispatchEvent(new Event('input'));

const linkedRepresentativeInput = fixture.nativeElement.querySelector('[id="representative"') as HTMLSelectElement;
const linkedRepresentativeInput = fixture.nativeElement.querySelector('[id="representative"]') as HTMLSelectElement;
linkedRepresentativeInput.value = rep.email;
linkedRepresentativeInput.dispatchEvent(new Event('change'));

Expand All @@ -150,7 +153,8 @@ describe('VideoEndpointFormComponent', () => {
displayName: rep.display_name
},
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
});
});

Expand All @@ -171,15 +175,17 @@ describe('VideoEndpointFormComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
}
];
component.videoEndpoint = {
id: '2',
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
};
component.form.setValue({
displayName: 'Test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export class VideoEndpointFormComponent {
displayName: this.form.value.displayName,
defenceAdvocate,
interpretationLanguage: this.interpreterSelection,
screening: this.videoEndpoint?.screening
screening: this.videoEndpoint?.screening,
externalReferenceId: this.videoEndpoint?.externalReferenceId
};
if (this.editMode) {
this.endpointUpdated.emit({ original: this.videoEndpoint, updated: dto });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('VideoEndpointItemComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
};
component.videoEndpoint = dto;
component.edit();
Expand All @@ -39,7 +40,8 @@ describe('VideoEndpointItemComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
};
component.videoEndpoint = dto;
component.delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('VideoEndpointListComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
};
component.editEndpoint.emit(dto);
expect(component.editEndpoint.emit).toHaveBeenCalledWith(dto);
Expand All @@ -38,7 +39,8 @@ describe('VideoEndpointListComponent', () => {
displayName: 'Test',
defenceAdvocate: null,
interpretationLanguage: undefined,
screening: undefined
screening: undefined,
externalReferenceId: undefined
};
component.deleteEndpoint.emit(dto);
expect(component.deleteEndpoint.emit).toHaveBeenCalledWith(dto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@
</div>
</div>
</ng-container>

<div *ngIf="newParticipantRemovedFromOptions">
<div class="govuk-warning-text">
<span aria-hidden="true" class="govuk-warning-text__icon">!</span>
<strong class="govuk-warning-text__text">
<span class="govuk-warning-text__assistive">Warning</span>
New participants and endpoints cannot be included in screening options, without being saved first.
</strong>
</div>
</div>
<button
*ngIf="form.value.displayName"
type="submit"
Expand Down
Loading

0 comments on commit c23f317

Please sign in to comment.