Skip to content

Commit

Permalink
Implemented fix for VIH-11057 - external ref id not being mapped corr…
Browse files Browse the repository at this point in the history
…ectly for endpoints models, on preexisting endpoints.
  • Loading branch information
will-craig committed Oct 21, 2024
1 parent 21cc208 commit 259892a
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 88 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 @@ -25,12 +25,12 @@ describe('ScreeningFormComponent', () => {
participant2.email = 'email2';
participant2.display_name = 'Participant2';

const endpoint1 = new EndpointModel();
const endpoint1 = new EndpointModel(null);
endpoint1.id = '3';
endpoint1.displayName = 'Endpoint 1';
endpoint1.sip = 'sip1';

const endpoint2 = new EndpointModel();
const endpoint2 = new EndpointModel(null);
endpoint2.id = '4';
endpoint2.displayName = 'Endpoint 2';
endpoint2.sip = 'sip2';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ScreeningListItemComponent } from './screening-list-item.component';
import { EndpointModel } from 'src/app/common/model/endpoint.model';
import { HearingModel } from 'src/app/common/model/hearing.model';
import { ParticipantModel } from 'src/app/common/model/participant.model';
import { SimpleChanges, SimpleChange } from '@angular/core';
import { SimpleChange, SimpleChanges } from '@angular/core';

describe('ScreeningListItemComponent', () => {
let component: ScreeningListItemComponent;
Expand All @@ -28,11 +28,11 @@ describe('ScreeningListItemComponent', () => {
};
hearing.participants = [participantWithoutScreening, participantWithScreening];

const endpointWithoutScreening = new EndpointModel();
const endpointWithoutScreening = new EndpointModel(null);
endpointWithoutScreening.id = '3';
endpointWithoutScreening.displayName = 'Endpoint No Screening';

const endpointWithScreening = new EndpointModel();
const endpointWithScreening = new EndpointModel(null);
endpointWithScreening.id = '4';
endpointWithScreening.displayName = 'Endpoint With Screening';
endpointWithScreening.screening = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentFixture, TestBed, tick } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ScreeningListComponent } from './screening-list.component';
import { HearingModel } from 'src/app/common/model/hearing.model';
Expand Down Expand Up @@ -26,11 +26,11 @@ describe('ScreeningListComponent', () => {
};
hearing.participants = [participantWithoutScreening, participantWithScreening];

const endpointWithoutScreening = new EndpointModel();
const endpointWithoutScreening = new EndpointModel(null);
endpointWithoutScreening.id = '3';
endpointWithoutScreening.displayName = 'Endpoint No Screening';

const endpointWithScreening = new EndpointModel();
const endpointWithScreening = new EndpointModel(null);
endpointWithScreening.id = '4';
endpointWithScreening.displayName = 'Endpoint With Screening';
endpointWithScreening.screening = {
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('ScreeningListComponent', () => {
describe('onEndpointScreeningDeleted', () => {
it('should emit deleteEndpointScreening event', () => {
// Arrange
const endpoint = new EndpointModel();
const endpoint = new EndpointModel(null);
spyOn(component.deleteEndpointScreening, 'emit');

// Act
Expand Down
Loading

0 comments on commit 259892a

Please sign in to comment.