diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts index 1fc5e7180..6316f110d 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts @@ -27,7 +27,7 @@ import { InterpreterFormComponent } from '../interpreter-form/interpreter-form.c import { MockComponent } from 'ng-mocks'; import { InterpreterSelectedDto } from '../interpreter-form/interpreter-selected.model'; import { FeatureFlagDirective } from 'src/app/src/app/shared/feature-flag.directive'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; let component: AddParticipantComponent; let fixture: ComponentFixture; @@ -179,7 +179,7 @@ participants.push(p3); participants.push(p4); function initHearingRequest(): VHBooking { - const newHearing = createVHBooking(); + const newHearing = new VHBooking(); newHearing.hearing_venue_id = -1; newHearing.scheduled_duration = 0; newHearing.participants = participants; @@ -189,7 +189,7 @@ function initHearingRequest(): VHBooking { } function initExistHearingRequest(): VHBooking { - const newHearing = createVHBooking(); + const newHearing = new VHBooking(); newHearing.hearing_id = '12345'; newHearing.hearing_venue_id = 1; newHearing.scheduled_duration = 20; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts index 877e92c96..7cdac63f3 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts @@ -19,6 +19,7 @@ import { LinkedParticipantModel, LinkedParticipantType } from 'src/app/common/mo import { takeUntil } from 'rxjs/operators'; import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkly.service'; import { InterpreterSelectedDto } from '../interpreter-form/interpreter-selected.model'; +import { cloneWithGetters } from 'src/app/common/helpers/clone-with-getters'; @Component({ selector: 'app-add-participant', @@ -324,7 +325,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme this.hearing.participants.push(newParticipant); this.hearing.participants = [...this.hearing.participants]; - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); this.populateInterpretedForList(); this.videoHearingService.updateHearingRequest(this.hearing); @@ -392,7 +393,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } }); this.hearing.participants = [...this.hearing.participants]; - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); this.clearForm(); this.participantDetails = null; this.form.markAsPristine(); @@ -442,7 +443,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } this.participantService.removeParticipant(this.hearing, this.selectedParticipantEmail); this.removeLinkedParticipant(this.selectedParticipantEmail); - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); this.videoHearingService.updateHearingRequest(this.hearing); this.videoHearingService.setBookingHasChanged(); } @@ -759,7 +760,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } this.participantService.removeParticipant(this.hearing, this.selectedParticipantEmail); this.removeLinkedParticipant(this.selectedParticipantEmail); - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); this.videoHearingService.updateHearingRequest(this.hearing); this.videoHearingService.setBookingHasChanged(); } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.spec.ts index 201deaf21..53004a1b6 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.spec.ts @@ -23,7 +23,7 @@ import { PageUrls } from 'src/app/shared/page-url.constants'; import { SearchEmailComponent } from '../search-email/search-email.component'; import { MockComponent } from 'ng-mocks'; import { Constants } from 'src/app/common/constants'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; function initHearingRequest(): VHBooking { const participants: ParticipantModel[] = []; @@ -52,7 +52,7 @@ function initHearingRequest(): VHBooking { participants.push(p1); participants.push(p2); - const newHearing = createVHBooking(); + const newHearing = new VHBooking(); newHearing.participants = participants; newHearing.hearing_venue_id = -1; @@ -511,7 +511,7 @@ describe('AssignJudgeComponent', () => { describe('updateJudge', () => { beforeEach(() => { - component.hearing = createVHBooking(); + component.hearing = new VHBooking(); component.canNavigate = null; component.judgeDisplayNameFld.setValue(initialJudgeDisplayNameFld); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.ts index 458712577..273749025 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.ts @@ -16,6 +16,7 @@ import { PipeStringifierService } from '../../services/pipe-stringifier.service' import { EmailValidationService } from 'src/app/booking/services/email-validation.service'; import { ConfigService } from '../../services/config.service'; import { map } from 'rxjs/operators'; +import { cloneWithGetters } from 'src/app/common/helpers/clone-with-getters'; @Component({ selector: 'app-assign-judge', templateUrl: './assign-judge.component.html', @@ -131,7 +132,7 @@ export class AssignJudgeComponent extends BookingBaseComponent implements OnInit this.removeJudge(); } - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); this.setTextFieldValues(); } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.spec.ts index 0c01225a5..04c0d42c0 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.spec.ts @@ -22,17 +22,17 @@ import { createMultiDayHearing } from 'src/app/testing/helpers/hearing.helpers'; import { VideoSupplier } from 'src/app/services/clients/api-client'; import { ServiceIds } from '../models/supplier-override'; import { ReferenceDataService } from 'src/app/services/reference-data.service'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; function initHearingRequest(): VHBooking { - const newHearing = createVHBooking(); + const newHearing = new VHBooking(); newHearing.hearing_venue_id = -1; newHearing.scheduled_duration = 0; return newHearing; } function initExistingHearingRequest(): VHBooking { - const existingRequest = createVHBooking(); + const existingRequest = new VHBooking(); existingRequest.hearing_venue_id = 1; existingRequest.case_type = 'Generic'; @@ -442,7 +442,7 @@ describe('CreateHearingComponent with existing request in session', () => { hearing.isMultiDayEdit = false; videoHearingsServiceSpy.getCurrentRequest.and.returnValue(hearing); }); - it('should disable editing of case name when multi-day hearing enhancements are enabled', fakeAsync(() => { + fit('should disable editing of case name when multi-day hearing enhancements are enabled', fakeAsync(() => { launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(true)); component.ngOnInit(); tick(); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/endpoints/endpoints.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/endpoints/endpoints.component.spec.ts index 9fadec022..c68382182 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/endpoints/endpoints.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/endpoints/endpoints.component.spec.ts @@ -12,10 +12,10 @@ import { VideoEndpointListComponent } from './video-endpoint-list/video-endpoint import { VideoEndpointItemComponent } from './video-endpoint-item/video-endpoint-item.component'; import { BreadcrumbStubComponent } from 'src/app/testing/stubs/breadcrumb-stub'; import { FeatureFlagDirective } from 'src/app/src/app/shared/feature-flag.directive'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; function initHearingRequest(): VHBooking { - const newHearing = createVHBooking(); + const newHearing = new VHBooking(); newHearing.hearing_venue_id = -1; newHearing.scheduled_duration = 0; newHearing.participants = [ @@ -185,8 +185,8 @@ describe('EndpointsComponent', () => { describe('when booking is multi day', () => { beforeEach(() => { - const booking = createVHBooking(); - booking.isMultiDay = true; + const booking = new VHBooking(); + booking.groupId = '123'; videoHearingsServiceSpy.getCurrentRequest.and.returnValue(booking); }); it('should navigate to the summary page when next clicked and multi day booking enhancements are enabled', () => { @@ -204,12 +204,12 @@ describe('EndpointsComponent', () => { }); describe('when booking is not multi day', () => { beforeEach(() => { - const booking = createVHBooking(); - booking.isMultiDay = false; + const booking = new VHBooking(); + booking.groupId = '123'; videoHearingsServiceSpy.getCurrentRequest.and.returnValue(booking); }); - it('should navigate to the other information page when next clicked and multi day booking enhancements are enabled', () => { + fit('should navigate to the other information page when next clicked and multi day booking enhancements are enabled', () => { featureServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(true)); component.ngOnInit(); component.videoEndpoints = [ diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.spec.ts index 38ce56fd7..06257b9ff 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.spec.ts @@ -21,15 +21,16 @@ import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkl import { By } from '@angular/platform-browser'; import { createMultiDayHearing } from 'src/app/testing/helpers/hearing.helpers'; import { EditHearingDatesComponent } from './edit-hearing-dates/edit-hearing-dates.component'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; +import { cloneWithGetters } from 'src/app/common/helpers/clone-with-getters'; -const newHearing = createVHBooking(); +const newHearing = new VHBooking(); function initExistingHearingRequest(): VHBooking { const today = new Date(); today.setHours(10, 30); - const existingRequest = createVHBooking(); + const existingRequest = new VHBooking(); existingRequest.hearing_venue_id = 1; existingRequest.scheduled_date_time = today; existingRequest.scheduled_duration = 80; @@ -528,7 +529,7 @@ describe('HearingScheduleComponent returning to page', () => { new HearingVenueResponse({ id: 1, name: 'aa@hmcts.net', code: '123' }), new HearingVenueResponse({ id: 2, name: 'aa@hmcts.net1', code: '456' }) ]; - component.hearing = createVHBooking(); + component.hearing = new VHBooking(); component.hearing.hearing_venue_id = 2; component.hearing.court_code = '456'; component.hearing.court_name = 'aa@hmcts.net1'; @@ -541,7 +542,7 @@ describe('HearingScheduleComponent returning to page', () => { const courts = MockValues.Courts.filter(x => x.id !== -1); const selectedCourt = courts[0]; referenceDataServiceServiceSpy.getCourts.and.returnValue(of(courts)); - const existingHearingRequest = { ...existingRequest }; + const existingHearingRequest = cloneWithGetters(existingRequest); existingHearingRequest.hearing_id = '123455555900'; existingHearingRequest.court_name = selectedCourt.name; videoHearingsServiceSpy.getCurrentRequest.and.returnValue(existingHearingRequest); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/judicial-office-holders/add-judicial-office-holders/add-judicial-office-holders.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/judicial-office-holders/add-judicial-office-holders/add-judicial-office-holders.component.spec.ts index b702b1b4e..5a5738927 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/judicial-office-holders/add-judicial-office-holders/add-judicial-office-holders.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/judicial-office-holders/add-judicial-office-holders/add-judicial-office-holders.component.spec.ts @@ -5,7 +5,7 @@ import { BookingService } from 'src/app/services/booking.service'; import { Logger } from 'src/app/services/logger'; import { AddJudicialOfficeHoldersComponent } from './add-judicial-office-holders.component'; import { Router } from '@angular/router'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; import { ParticipantListComponent } from '../../participant'; import { ParticipantsListStubComponent } from 'src/app/testing/stubs/participant-list-stub'; import { BreadcrumbComponent } from '../../breadcrumb/breadcrumb.component'; @@ -34,7 +34,7 @@ describe('AddJudicialOfficeHoldersComponent', () => { beforeEach(async () => { launchDarklyServiceSpy = jasmine.createSpyObj('LaunchDarklyService', ['getFlag']); launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.interpreterEnhancements).and.returnValue(of(false)); - hearing = createVHBooking(); + hearing = new VHBooking(); hearing.judiciaryParticipants = []; videoHearingsServiceSpy = jasmine.createSpyObj('VideoHearingsService', [ 'getCurrentRequest', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/judicial-office-holders/models/add-judicial-member.model.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/judicial-office-holders/models/add-judicial-member.model.ts index 7bb86995d..d2e56e040 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/judicial-office-holders/models/add-judicial-member.model.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/judicial-office-holders/models/add-judicial-member.model.ts @@ -37,4 +37,12 @@ export class JudicialMemberDto { return dto; } + + static judgeWithDisplayName(displayName: string): JudicialMemberDto { + const dto = new JudicialMemberDto(null, null, null, null, null, null, false); + dto.displayName = displayName; + dto.roleCode = 'Judge'; + + return dto + } } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/other-information/other-information.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/other-information/other-information.component.spec.ts index 6aca1258f..6b5e5ba46 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/other-information/other-information.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/other-information/other-information.component.spec.ts @@ -12,7 +12,7 @@ import { BreadcrumbComponent } from '../breadcrumb/breadcrumb.component'; import { OtherInformationComponent } from './other-information.component'; import { ParticipantModel } from '../../common/model/participant.model'; import { CaseModel } from 'src/app/common/model/case.model'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; import { LaunchDarklyService } from 'src/app/services/launch-darkly.service'; import { BreadcrumbStubComponent } from 'src/app/testing/stubs/breadcrumb-stub'; @@ -21,7 +21,7 @@ function initHearingRequest(): VHBooking { const cases: CaseModel[] = []; - const newHearing = createVHBooking(); + const newHearing = new VHBooking(); newHearing.case = cases[0]; newHearing.participants = participants; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.spec.ts index c3532de09..9056cd851 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.spec.ts @@ -10,6 +10,7 @@ import { Constants } from 'src/app/common/constants'; import { ParticipantModel } from 'src/app/common/model/participant.model'; import { PageUrls } from 'src/app/shared/page-url.constants'; import { VideoSupplier } from 'src/app/services/clients/api-client'; +import { VHBooking } from 'src/app/common/model/vh-booking'; const router = { navigate: jasmine.createSpy('navigate'), @@ -51,11 +52,11 @@ describe('ParticipantItemComponent', () => { fixture = TestBed.createComponent(ParticipantItemComponent); debugElement = fixture.debugElement; component = debugElement.componentInstance; - component.hearing = { - updated_date: new Date(), - other_information: '|JudgeEmail|James.Doe@hmcts.net|JudgePhone|123456789', - supplier: VideoSupplier.Kinly - }; + const hearing = new VHBooking(); + hearing.updated_date = new Date(), + hearing.other_information = '|JudgeEmail|James.Doe@hmcts.net|JudgePhone|123456789', + hearing.supplier = VideoSupplier.Kinly; + component.hearing = hearing; fixture.detectChanges(); }); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.spec.ts index 001340667..6ef01c126 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.spec.ts @@ -15,6 +15,7 @@ import { FeatureFlags, LaunchDarklyService } from '../../../services/launch-dark import { of } from 'rxjs'; import { InterpreterSelectedDto } from '../../interpreter-form/interpreter-selected.model'; import { VideoSupplier } from 'src/app/services/clients/api-client'; +import { VHBooking } from 'src/app/common/model/vh-booking'; const loggerSpy = jasmine.createSpyObj('Logger', ['error', 'debug', 'warn']); const router = { @@ -63,7 +64,10 @@ describe('ParticipantListComponent', () => { fixture = TestBed.createComponent(ParticipantListComponent); debugElement = fixture.debugElement; component = debugElement.componentInstance; - component.hearing = { updated_date: new Date(), supplier: VideoSupplier.Kinly }; + const hearing = new VHBooking(); + hearing.updated_date = new Date(); + hearing.supplier = VideoSupplier.Kinly; + component.hearing = hearing; fixture.detectChanges(); }); @@ -335,7 +339,10 @@ describe('ParticipantListComponent-SortParticipants', () => { fixture = TestBed.createComponent(ParticipantListComponent); debugElement = fixture.debugElement; component = debugElement.componentInstance; - component.hearing = { updated_date: new Date(), supplier: VideoSupplier.Kinly }; + const hearing = new VHBooking(); + hearing.updated_date = new Date(); + hearing.supplier = VideoSupplier.Kinly; + component.hearing = hearing; fixture.detectChanges(); }); it('should produce a sorted list with no duplicates', () => { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-form.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-form.component.spec.ts index 300366b9f..f68825ffc 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-form.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-form.component.spec.ts @@ -4,7 +4,7 @@ import { ScreeningFormComponent as ScreeningFormComponent } from './screening-fo import { Logger } from 'src/app/services/logger'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; import { EndpointModel } from 'src/app/common/model/endpoint.model'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; import { ParticipantModel } from 'src/app/common/model/participant.model'; describe('ScreeningFormComponent', () => { @@ -14,7 +14,7 @@ describe('ScreeningFormComponent', () => { let hearing: VHBooking; beforeEach(async () => { - hearing = createVHBooking(); + hearing = new VHBooking(); const participant1 = new ParticipantModel(); participant1.id = '1'; participant1.email = 'email1'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-list-item.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-list-item.component.spec.ts index a7cc553b1..d749ab971 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-list-item.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-list-item.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ScreeningListItemComponent } from './screening-list-item.component'; import { EndpointModel } from 'src/app/common/model/endpoint.model'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; import { ParticipantModel } from 'src/app/common/model/participant.model'; import { SimpleChange, SimpleChanges } from '@angular/core'; @@ -12,7 +12,7 @@ describe('ScreeningListItemComponent', () => { let hearing: VHBooking; beforeEach(async () => { - hearing = createVHBooking(); + hearing = new VHBooking(); const participantWithoutScreening = new ParticipantModel(); participantWithoutScreening.id = '1'; participantWithoutScreening.display_name = 'Participant No Screening'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-list.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-list.component.spec.ts index 295a88790..beadf0fdc 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-list.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening-list.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ScreeningListComponent } from './screening-list.component'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; import { ParticipantModel } from 'src/app/common/model/participant.model'; import { EndpointModel } from 'src/app/common/model/endpoint.model'; import { SimpleChange, SimpleChanges } from '@angular/core'; @@ -12,7 +12,7 @@ describe('ScreeningListComponent', () => { let hearing: VHBooking; beforeEach(async () => { - hearing = createVHBooking(); + hearing = new VHBooking(); const participantWithoutScreening = new ParticipantModel(); participantWithoutScreening.id = '1'; participantWithoutScreening.display_name = 'Participant No Screening'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening.component.spec.ts index 8b6f3c5f4..d465d5025 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening.component.spec.ts @@ -5,7 +5,7 @@ import { Router } from '@angular/router'; import { BookingService } from 'src/app/services/booking.service'; import { Logger } from 'src/app/services/logger'; import { VideoHearingsService } from 'src/app/services/video-hearings.service'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; import { EndpointModel } from 'src/app/common/model/endpoint.model'; import { ParticipantModel } from 'src/app/common/model/participant.model'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; @@ -15,7 +15,7 @@ import { BreadcrumbComponent } from '../breadcrumb/breadcrumb.component'; import { ScreeningListComponent } from './screening-list.component'; function initHearingRequest(): VHBooking { - const hearing = createVHBooking(); + const hearing = new VHBooking(); hearing.hearing_id = ''; hearing.participants = [ { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening.component.ts index f50df4f00..4c7f8c0a5 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/screening/screening.component.ts @@ -9,6 +9,7 @@ import { ParticipantModel } from '../../common/model/participant.model'; import { BookingService } from 'src/app/services/booking.service'; import { PageUrls } from 'src/app/shared/page-url.constants'; import { Router } from '@angular/router'; +import { cloneWithGetters } from 'src/app/common/helpers/clone-with-getters'; @Component({ selector: 'app-screening', @@ -55,7 +56,7 @@ export class ScreeningComponent implements OnInit, OnDestroy { }; } this.hearingService.updateHearingRequest(this.hearing); - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); } onDeleteEndpointScreening(endpoint: EndpointModel) { @@ -64,7 +65,7 @@ export class ScreeningComponent implements OnInit, OnDestroy { e.screening = null; } }); - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); } onDeleteParticipantScreening(participant: ParticipantModel) { @@ -73,7 +74,7 @@ export class ScreeningComponent implements OnInit, OnDestroy { p.screening = null; } }); - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); } onContinue() { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.spec.ts index e1e24e4ce..0c81ea2d3 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.spec.ts @@ -5,7 +5,7 @@ import { HearingRoleResponse } from '../../services/clients/api-client'; import { ParticipantModel } from '../../common/model/participant.model'; import { Logger } from '../../services/logger'; import { HearingRoleModel } from 'src/app/common/model/hearing-role.model'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; describe('ParticipantService', () => { const loggerSpy = jasmine.createSpyObj('Logger', ['error', 'info']); @@ -68,7 +68,7 @@ describe('ParticipantService', () => { expect(result).toBeTruthy(); })); it('should remove participant', inject([ParticipantService], (service: ParticipantService) => { - const hearing: VHBooking = createVHBooking(); + const hearing: VHBooking = new VHBooking(); const part1 = new ParticipantModel(); part1.email = 'aa@hmcts.net'; const participants: ParticipantModel[] = []; @@ -78,7 +78,7 @@ describe('ParticipantService', () => { expect(hearing.participants.length).toBe(0); })); it('should not remove participant, if email is not in the list', inject([ParticipantService], (service: ParticipantService) => { - const hearing: VHBooking = createVHBooking(); + const hearing: VHBooking = new VHBooking(); const part1 = new ParticipantModel(); part1.email = 'aa@hmcts.net'; const participants: ParticipantModel[] = []; @@ -88,7 +88,7 @@ describe('ParticipantService', () => { expect(hearing.participants.length).toBe(1); })); it('should remove participant and log a message', inject([ParticipantService], (service: ParticipantService) => { - const hearing: VHBooking = createVHBooking(); + const hearing: VHBooking = new VHBooking(); hearing.hearing_id = '12345'; const part1 = new ParticipantModel(); part1.email = 'aa@hmcts.net'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.spec.ts index 9f116db3a..eecfcbb6a 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.spec.ts @@ -38,7 +38,7 @@ import { BookingStatusService } from 'src/app/services/booking-status-service'; import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkly.service'; import { TruncatableTextComponent } from 'src/app/shared/truncatable-text/truncatable-text.component'; import { ReferenceDataService } from 'src/app/services/reference-data.service'; -import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; function initExistingHearingRequest(): VHBooking { const pat1 = new ParticipantModel(); @@ -54,7 +54,7 @@ function initExistingHearingRequest(): VHBooking { newCaseRequest.name = 'Mr. Test User vs HMRC'; newCaseRequest.number = 'TX/12345/2018'; - const existingRequest = createVHBooking(); + const existingRequest = new VHBooking(); existingRequest.case = newCaseRequest; existingRequest.hearing_venue_id = 2; existingRequest.scheduled_date_time = today; @@ -86,7 +86,7 @@ function initBadHearingRequest(): VHBooking { newCaseRequest.name = 'Mr. Test User vs HMRC'; newCaseRequest.number = 'TX/12345/2018'; - const existingRequest = createVHBooking(); + const existingRequest = new VHBooking(); existingRequest.case = newCaseRequest; existingRequest.hearing_venue_id = 2; existingRequest.scheduled_date_time = today; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.ts index b1352c4b5..54f80a1af 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.ts @@ -27,6 +27,7 @@ import { OtherInformationModel } from '../../common/model/other-information.mode import { finalize, takeUntil } from 'rxjs/operators'; import { BookingStatusService } from 'src/app/services/booking-status-service'; import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkly.service'; +import { cloneWithGetters } from 'src/app/common/helpers/clone-with-getters'; @Component({ selector: 'app-summary', @@ -204,13 +205,13 @@ export class SummaryComponent implements OnInit, OnDestroy { } this.hearing.participants.splice(indexOfParticipant, 1); this.removeLinkedParticipant(this.selectedParticipantEmail); - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); } const judicalParticipant = this.hearing.judiciaryParticipants?.findIndex(x => x.email === this.selectedParticipantEmail); if (judicalParticipant > -1) { this.hearing.judiciaryParticipants.splice(judicalParticipant, 1); - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); } this.hearingService.updateHearingRequest(this.hearing); @@ -535,7 +536,7 @@ export class SummaryComponent implements OnInit, OnDestroy { } this.participantService.removeParticipant(this.hearing, this.selectedParticipantEmail); this.removeLinkedParticipant(this.selectedParticipantEmail); - this.hearing = { ...this.hearing }; + this.hearing = cloneWithGetters(this.hearing); this.hearingService.updateHearingRequest(this.hearing); this.hearingService.setBookingHasChanged(); this.bookingService.removeParticipantEmail(); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-details/booking-details.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-details/booking-details.component.spec.ts index 3fb2db6a7..d5bc1eb47 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-details/booking-details.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-details/booking-details.component.spec.ts @@ -23,7 +23,7 @@ import { BookingDetailsComponent } from './booking-details.component'; import { BookingStatusService } from 'src/app/services/booking-status-service'; import { HearingRoleCodes } from '../../common/model/hearing-roles.model'; import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkly.service'; -import { createVHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; let component: BookingDetailsComponent; let videoHearingServiceSpy: jasmine.SpyObj; @@ -146,7 +146,7 @@ const hearingResponse = new HearingDetailsResponse(); const caseModel = new CaseModel(); caseModel.name = 'X vs Y'; caseModel.number = 'XX3456234565'; -const hearingModel = createVHBooking(); +const hearingModel = new VHBooking(); hearingModel.hearing_id = '44'; hearingModel.case = caseModel; hearingModel.scheduled_duration = 120; @@ -287,13 +287,13 @@ describe('BookingDetailsComponent', () => { })); describe('edit buttons pressed', () => { it('should set edit mode if the single day edit button pressed', fakeAsync(() => { - component.booking = createVHBooking(); + component.booking = new VHBooking(); component.editHearing(); expect(component.booking.isMultiDayEdit).toBeFalsy(); assertUpdatesAfterEditButtonsPressed(); })); it('should set edit mode if the multi day edit button pressed', fakeAsync(() => { - component.booking = createVHBooking(); + component.booking = new VHBooking(); component.editMultiDaysOfHearing(); expect(component.booking.isMultiDayEdit).toBeTruthy(); assertUpdatesAfterEditButtonsPressed(); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-status/booking-status.component.html b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-status/booking-status.component.html index 71e63b37f..17d9f1555 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-status/booking-status.component.html +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-status/booking-status.component.html @@ -1,15 +1,15 @@ NO JUDGE ASSIGNED
{{ bookingDetails.scheduled_date_time | amLocal | amDateFormat : 'h:mm a' }}
-
listed for {{ duration }}
+
listed for {{ bookingDetails.durationInHoursAndMinutes }}
{{ this.statusMessage }} diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-status/booking-status.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-status/booking-status.component.ts index 3298fa734..cbe69cb7e 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-status/booking-status.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-status/booking-status.component.ts @@ -1,10 +1,5 @@ import { Component, Input } from '@angular/core'; import { - durationInHoursAndMinutes, - hasBookingConfirmationFailed, - hasConfirmationWithNoJudge, - isCancelled, - isCreated, VHBooking } from 'src/app/common/model/vh-booking'; @Component({ @@ -33,24 +28,4 @@ export class BookingStatusComponent { public get hasNoJudge(): boolean { return this.bookingDetails.status === 'BookedWithoutJudge' || this.bookingDetails.status === 'ConfirmedWithoutJudge'; } - - public get duration(): string { - return durationInHoursAndMinutes(this.bookingDetails); - } - - public get isCancelled(): boolean { - return isCancelled(this.bookingDetails); - } - - public get isCreated(): boolean { - return isCreated(this.bookingDetails); - } - - public get hasBookingConfirmationFailed(): boolean { - return hasBookingConfirmationFailed(this.bookingDetails); - } - - public get hasConfirmationWithNoJudge(): boolean { - return hasConfirmationWithNoJudge(this.bookingDetails); - } } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.html b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.html index f5984cb36..9782113c7 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.html +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.html @@ -135,7 +135,7 @@

{{ title }}

diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.spec.ts index 4278d3d74..e8cff7f0f 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.spec.ts @@ -38,8 +38,8 @@ import { VenuesMenuComponent } from '../../shared/menus/venues-menu/venues-menu. import { JusticeUsersService } from 'src/app/services/justice-users.service'; import { JusticeUserMenuStubComponent } from 'src/app/testing/stubs/dropdown-menu/justice-user-menu-stub.component'; import { BookingStatusComponent } from '../booking-status/booking-status.component'; -import { createVHBookingFromDetails } from 'src/app/common/model/vh-booking'; import { BookingsListItemModel } from 'src/app/common/model/booking-list-item.model'; +import { VHBooking } from 'src/app/common/model/vh-booking'; let component: BookingsListComponent; let bookingPersistService: BookingPersistService; @@ -129,7 +129,7 @@ export class BookingslistTestData { const model = new BookingsListModel(dateNoTime); const lists: Array = []; const b1 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -155,7 +155,7 @@ export class BookingslistTestData { b1.Booking.allocatedTo = 'allocated-to'; const b2 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '2', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -181,7 +181,7 @@ export class BookingslistTestData { b2.Booking.allocatedTo = 'allocated-to'; const b3 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '3', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -220,7 +220,7 @@ export class BookingslistTestData { const model = new BookingsListModel(dateNoTime); const lists: Array = []; const b1 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -247,7 +247,7 @@ export class BookingslistTestData { b1.Booking.allocatedTo = 'allocated-to'; const b2 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '2', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -274,7 +274,7 @@ export class BookingslistTestData { b2.Booking.allocatedTo = 'allocated-to'; const b3 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '6', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -316,7 +316,7 @@ export class ArrayBookingslistModelTestData { const model = new BookingsListModel(dateNoTime); const lists: Array = []; const b1 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '11', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -343,7 +343,7 @@ export class ArrayBookingslistModelTestData { b1.Booking.allocatedTo = 'allocated-to'; const b2 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '12', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -370,7 +370,7 @@ export class ArrayBookingslistModelTestData { b2.Booking.allocatedTo = 'allocated-to'; const b3 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '33', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -405,7 +405,7 @@ export class ArrayBookingslistModelTestData { const dateNoTime1 = new Date(date1.setHours(0, 0, 0, 0)); const model1 = new BookingsListModel(dateNoTime1); const b11 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '44', new Date('2019-11-22 13:58:40.3730067'), 120, @@ -432,7 +432,7 @@ export class ArrayBookingslistModelTestData { b11.Booking.allocatedTo = 'allocated-to'; const b21 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '45', new Date('2019-11-22 13:58:40.3730067'), 120, @@ -459,7 +459,7 @@ export class ArrayBookingslistModelTestData { b21.Booking.allocatedTo = 'allocated-to'; const b31 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '46', new Date('2019-11-22 13:58:40.3730067'), 120, @@ -580,7 +580,7 @@ export class BookingPersistServiceSpy { updateBooking() { const booking = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -1117,7 +1117,7 @@ describe('BookingsListComponent', () => { it('should find the record position in the bookings list', () => { component.bookings = new ArrayBookingslistModelTestData().getTestData(); const booking = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '33', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -1149,7 +1149,7 @@ describe('BookingsListComponent', () => { it('should set the selected group index and item index to -1 for record is not found in the list', () => { component.bookings = new ArrayBookingslistModelTestData().getTestData(); const booking = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '3', new Date('2019-12-22 13:58:40.3730067'), 120, diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.ts index 21a306a5a..03a42a264 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.ts @@ -17,7 +17,6 @@ import { JusticeUsersMenuComponent } from '../../shared/menus/justice-users-menu import { CaseTypesMenuComponent } from '../../shared/menus/case-types-menu/case-types-menu.component'; import { VenuesMenuComponent } from '../../shared/menus/venues-menu/venues-menu.component'; import { BookingsListItemModel } from 'src/app/common/model/booking-list-item.model'; -import { isCancelled, isCreated } from 'src/app/common/model/vh-booking'; @Component({ selector: 'app-bookings-list', @@ -474,12 +473,4 @@ export class BookingsListComponent implements OnInit, OnDestroy { selectedVenueEmitter($event: number[]) { this.bookingPersistService.selectedVenueIds = $event; } - - isCancelled(booking: BookingsListItemModel) { - return isCancelled(booking.Booking); - } - - isCreated(booking: BookingsListItemModel) { - return isCreated(booking.Booking); - } } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/helpers/clone-with-getters.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/helpers/clone-with-getters.ts new file mode 100644 index 000000000..f68a7748b --- /dev/null +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/helpers/clone-with-getters.ts @@ -0,0 +1,3 @@ +export function cloneWithGetters(obj: T): T { + return Object.defineProperties({}, Object.getOwnPropertyDescriptors(obj)) as T; +} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/api-contract-to-client-model-mappers.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/api-contract-to-client-model-mappers.spec.ts index e38988c58..e5e38c92e 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/api-contract-to-client-model-mappers.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/api-contract-to-client-model-mappers.spec.ts @@ -68,7 +68,7 @@ describe('mapHearingToVHBooking', () => { expect(result.groupId).toBe(hearing.group_id); }); - it('should map hearing without judge', () => { + fit('should map hearing without judge', () => { // Arrange const hearing = createSingleDayHearing(); hearing.judiciary_participants = hearing.judiciary_participants.filter(participant => participant.role_code !== 'Judge'); @@ -82,7 +82,7 @@ describe('mapHearingToVHBooking', () => { }); describe('mapBookingsHearingResponseToVHBooking', () => { - it('should map BookingsHearingResponse to VHBooking', () => { + fit('should map BookingsHearingResponse to VHBooking', () => { // Arrange const response = new BookingsHearingResponse(); response.hearing_id = 'hearing-id'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/api-contract-to-client-model-mappers.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/api-contract-to-client-model-mappers.ts index 14f0df5b3..2c964061c 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/api-contract-to-client-model-mappers.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/api-contract-to-client-model-mappers.ts @@ -17,61 +17,66 @@ import { JudicialMemberDto } from 'src/app/booking/judicial-office-holders/model import { EndpointModel } from './endpoint.model'; export function mapHearingToVHBooking(hearing: HearingDetailsResponse): VHBooking { - return { - hearing_id: hearing.id, - scheduled_date_time: new Date(hearing.scheduled_date_time), - scheduled_duration: hearing.scheduled_duration, - case: mapCaseResponseToCaseModel(hearing.cases)[0], - participants: mapParticipantResponseToParticipantModel(hearing.participants), - judiciaryParticipants: hearing.judiciary_participants?.map(judiciaryParticipant => - JudicialMemberDto.fromJudiciaryParticipantResponse(judiciaryParticipant) - ), - created_by: hearing.created_by, - case_type: hearing.case_type_name, - case_type_service_id: hearing.service_id, - other_information: hearing.other_information, - court_room: hearing.hearing_room_name, - court_name: hearing.hearing_venue_name, - court_code: hearing.hearing_venue_code, - created_date: new Date(hearing.created_date), - updated_by: hearing.updated_by, - updated_date: new Date(hearing.updated_date), - status: hearing.status, - audio_recording_required: hearing.audio_recording_required, - endpoints: mapEndpointResponseToEndpointModel(hearing.endpoints, hearing.participants), - isMultiDay: hearing.group_id !== null && hearing.group_id !== undefined, - multiDayHearingLastDayScheduledDateTime: hearing.multi_day_hearing_last_day_scheduled_date_time, - hearingsInGroup: hearing.hearings_in_group?.map(hearingInGroup => mapHearingToVHBooking(hearingInGroup)), - originalScheduledDateTime: hearing.scheduled_date_time, - supplier: hearing.conference_supplier, - judge: getJudge(hearing), - isLastDayOfMultiDayHearing: - hearing.scheduled_date_time.getTime() === hearing.multi_day_hearing_last_day_scheduled_date_time?.getTime(), - groupId: hearing.group_id - }; + const booking = new VHBooking(); + booking.hearing_id = hearing.id, + booking.scheduled_date_time = new Date(hearing.scheduled_date_time), + booking.scheduled_duration = hearing.scheduled_duration, + booking.case = mapCaseResponseToCaseModel(hearing.cases)[0], + booking.participants = mapParticipantResponseToParticipantModel(hearing.participants), + booking.judiciaryParticipants = hearing.judiciary_participants?.map(judiciaryParticipant => + JudicialMemberDto.fromJudiciaryParticipantResponse(judiciaryParticipant) + ), + booking.created_by = hearing.created_by, + booking.case_type = hearing.case_type_name, + booking.case_type_service_id = hearing.service_id, + booking.other_information = hearing.other_information, + booking.court_room = hearing.hearing_room_name, + booking.court_name = hearing.hearing_venue_name, + booking.court_code = hearing.hearing_venue_code, + booking.created_date = new Date(hearing.created_date), + booking.updated_by = hearing.updated_by, + booking.updated_date = new Date(hearing.updated_date), + booking.status = hearing.status, + booking.audio_recording_required = hearing.audio_recording_required, + booking.endpoints = mapEndpointResponseToEndpointModel(hearing.endpoints, hearing.participants), + booking.multiDayHearingLastDayScheduledDateTime = hearing.multi_day_hearing_last_day_scheduled_date_time, + booking.hearingsInGroup = hearing.hearings_in_group?.map(hearingInGroup => mapHearingToVHBooking(hearingInGroup)), + booking.originalScheduledDateTime = hearing.scheduled_date_time, + booking.supplier = hearing.conference_supplier, + booking.groupId = hearing.group_id; + return booking; } export function mapBookingsHearingResponseToVHBooking(response: BookingsHearingResponse): VHBooking { - return { - hearing_id: response.hearing_id, - scheduled_date_time: response.scheduled_date_time, - scheduled_duration: response.scheduled_duration, - case: mapCaseNameAndNumberToCaseModel(response.hearing_name, response.hearing_number), - created_by: response.created_by, - case_type: response.case_type_name, - court_room: response.court_room, - court_name: response.court_address, - created_date: response.created_date, - updated_by: response.last_edit_by, - updated_date: response.last_edit_date, - status: response.status, - audio_recording_required: response.audio_recording_required, - supplier: response.conference_supplier, - judge: mapJudgeNameToJudge(response.judge_name), - groupId: response.group_id, - courtRoomAccount: response.court_room_account, - allocatedTo: response.allocated_to - }; + const booking = new VHBooking(); + booking.hearing_id = response.hearing_id; + booking.scheduled_date_time = response.scheduled_date_time; + booking.scheduled_duration = response.scheduled_duration; + + const caseModel = new CaseModel(); + caseModel.name = response.hearing_name; + caseModel.number = response.hearing_number; + booking.case = caseModel; + + booking.created_by = response.created_by; + booking.case_type = response.case_type_name; + booking.court_room = response.court_room; + booking.court_name = response.court_address; + booking.created_date = response.created_date; + booking.updated_by = response.last_edit_by; + booking.updated_date = response.last_edit_date; + booking.status = response.status; + booking.audio_recording_required = response.audio_recording_required; + booking.supplier = response.conference_supplier; + + if (response.judge_name) { + booking.assignJudge(response.judge_name); + } + + booking.groupId = response.group_id; + booking.courtRoomAccount = response.court_room_account; + booking.allocatedTo = response.allocated_to; + return booking; } export function mapCaseResponseToCaseModel(casesResponse: CaseResponse[]): CaseModel[] { @@ -163,18 +168,4 @@ export function mapEndpointResponseToEndpointModel(response: EndpointResponse[], }); } return endpoints; -} - -export function mapJudgeNameToJudge(judgeName: string): JudicialMemberDto { - const judge = new JudicialMemberDto(null, null, null, null, null, null, false); - judge.displayName = judgeName; - return judge; -} - -function getJudge(hearing: HearingDetailsResponse): JudicialMemberDto { - const judge = hearing.judiciary_participants?.find(x => x.role_code === Constants.Judge); - if (judge) { - return JudicialMemberDto.fromJudiciaryParticipantResponse(judge); - } - return null; -} +} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/case.model.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/case.model.ts index 4686f6f68..87335fa0b 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/case.model.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/case.model.ts @@ -1,4 +1,9 @@ export class CaseModel { + constructor(name?: string, number?: string) { + this.name = name; + this.number = number; + } + number?: string; name?: string; isLeadCase?: boolean; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/vh-booking.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/vh-booking.ts index 9e339b9eb..128d8226c 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/vh-booking.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/vh-booking.ts @@ -4,10 +4,65 @@ import { ParticipantModel } from './participant.model'; import { JudicialMemberDto } from 'src/app/booking/judicial-office-holders/models/add-judicial-member.model'; import { EndpointModel } from './endpoint.model'; import { LinkedParticipantModel } from './linked-participant.model'; -import { mapCaseNameAndNumberToCaseModel, mapJudgeNameToJudge } from './api-contract-to-client-model-mappers'; import { FormatShortDuration } from '../formatters/format-short-duration'; +import { Constants } from '../constants'; + +export class VHBooking { + constructor( + hearingId?: string, + startTime?: Date, + duration?: number, + hearingCaseNumber?: string, + hearingCaseName?: string, + judgeName?: string, + courtRoom?: string, + courtAddress?: string, + createdBy?: string, + createdDate?: Date, + lastEditBy?: string, + lastEditDate?: Date, + confirmedBy?: string, + confirmedDate?: Date, + status?: string, + audioRecordingRequired?: boolean, + cancelReason?: string, + caseType?: string, + courtRoomAccount?: string, + telephoneConferenceId?: string + ) { + this.hearing_id = hearingId || ''; + this.scheduled_date_time = startTime; + this.scheduled_duration = duration || 0; + this.case = new CaseModel(hearingCaseName, hearingCaseNumber); + this.court_room = courtRoom; + this.court_name = courtAddress; + this.created_by = createdBy; + this.created_date = createdDate; + this.updated_by = lastEditBy; + this.updated_date = lastEditDate; + this.confirmedBy = confirmedBy; + this.confirmedDate = confirmedDate; + this.status = status; + this.audio_recording_required = audioRecordingRequired; + this.cancelReason = cancelReason; + this.case_type = caseType; + this.courtRoomAccount = courtRoomAccount; + this.telephone_conference_id = telephoneConferenceId; + this.participants = []; + this.judiciaryParticipants = []; + + if (judgeName) { + this.assignJudge(judgeName); + } + + this.endpoints = [], + this.linked_participants = [], + this.hearing_dates = [], + this.updated_date = new Date(), + this.supplier = VideoSupplier.Vodafone + this.groupId = null; + } -export interface VHBooking { hearing_id?: string; scheduled_date_time?: Date; scheduled_duration?: number; @@ -35,99 +90,52 @@ export interface VHBooking { linked_participants?: LinkedParticipantModel[]; hearing_dates?: Date[]; isConfirmed?: boolean; - isMultiDay?: boolean; multiDayHearingLastDayScheduledDateTime?: Date; hearingsInGroup?: VHBooking[]; originalScheduledDateTime?: Date; supplier: VideoSupplier; - judge?: JudicialMemberDto; - isLastDayOfMultiDayHearing?: boolean; groupId?: string; confirmedBy?: string; confirmedDate?: Date; cancelReason?: string; courtRoomAccount?: string; allocatedTo?: string; -} -export function createVHBooking(): VHBooking { - return { - hearing_id: '', - scheduled_duration: 0, - participants: [], - judiciaryParticipants: [], - endpoints: [], - linked_participants: [], - hearing_dates: [], - updated_date: new Date(), - supplier: VideoSupplier.Vodafone - }; -} + get durationInHoursAndMinutes(): string { + return FormatShortDuration(this.scheduled_duration); + } + + get isCancelled(): boolean { + return this.status === 'Cancelled'; + } + + get isCreated(): boolean { + return this.status === 'Created'; + } -// TODO this is primarily used to enforce required properties -// Should we consolidate this with createVHBooking -// Or make them non-optional properties in VHBooking -export function createVHBookingFromDetails( - hearingId: string, - startTime: Date, - duration: number, - hearingCaseNumber: string, - hearingCaseName: string, - judgeName: string, - courtRoom: string, - courtAddress: string, - createdBy: string, - createdDate: Date, - lastEditBy: string, - lastEditDate: Date, - confirmedBy: string, - confirmedDate: Date, - status: string, - audioRecordingRequired: boolean, - cancelReason: string, - caseType: string, - courtRoomAccount: string, - telephoneConferenceId: string -): VHBooking { - const booking = createVHBooking(); - booking.hearing_id = hearingId; - booking.scheduled_date_time = startTime; - booking.scheduled_duration = duration; - booking.case = mapCaseNameAndNumberToCaseModel(hearingCaseName, hearingCaseNumber); - booking.judge = mapJudgeNameToJudge(judgeName); - booking.court_room = courtRoom; - booking.court_name = courtAddress; - booking.created_by = createdBy; - booking.created_date = createdDate; - booking.updated_by = lastEditBy; - booking.updated_date = lastEditDate; - booking.confirmedBy = confirmedBy; - booking.confirmedDate = confirmedDate; - booking.status = status; - booking.audio_recording_required = audioRecordingRequired; - booking.cancelReason = cancelReason; - booking.case_type = caseType; - booking.courtRoomAccount = courtRoomAccount; - booking.telephone_conference_id = telephoneConferenceId; - return booking; -} + get hasBookingConfirmationFailed(): boolean { + return this.status === 'Failed'; + } -export function durationInHoursAndMinutes(booking: VHBooking) { - return FormatShortDuration(booking.scheduled_duration); -} + get hasConfirmationWithNoJudge(): boolean { + return this.status === 'ConfirmedWithoutJudge'; + } -export function isCancelled(booking: VHBooking): boolean { - return booking.status === 'Cancelled'; -} + get isMultiDay(): boolean { + return this.groupId !== null; + } -export function isCreated(booking: VHBooking): boolean { - return booking.status === 'Created'; -} + get isLastDayOfMultiDayHearing(): boolean { + return this.scheduled_date_time.getTime() === this.multiDayHearingLastDayScheduledDateTime?.getTime(); + } -export function hasBookingConfirmationFailed(booking: VHBooking): boolean { - return booking.status === 'Failed'; -} + get judge(): JudicialMemberDto { + return this.judiciaryParticipants?.find(x => x.roleCode === Constants.Judge) || null; + } -export function hasConfirmationWithNoJudge(booking: VHBooking): boolean { - return booking.status === 'ConfirmedWithoutJudge'; -} + assignJudge(displayName: string) { + const judge = JudicialMemberDto.judgeWithDisplayName(displayName); + this.judiciaryParticipants = this.judiciaryParticipants.filter(x => x.roleCode !== Constants.Judge); + this.judiciaryParticipants.push(judge); + } +} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.spec.ts index a4fd9f556..54a8d4ac3 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.spec.ts @@ -6,7 +6,7 @@ import { Observable, of } from 'rxjs'; import { BookingsListModel } from '../common/model/bookings-list.model'; import { BookingsModel } from '../common/model/bookings.model'; import { BookingsListItemModel } from '../common/model/booking-list-item.model'; -import { createVHBookingFromDetails } from '../common/model/vh-booking'; +import { VHBooking } from '../common/model/vh-booking'; export class ResponseTestData { static getEditingBookings(): Array { @@ -14,7 +14,7 @@ export class ResponseTestData { const model = new BookingsListModel(new Date('2019-12-22 00:00:00.0000000')); const lists: Array = []; const b1 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-12-22 13:58:40.3730067'), 120, @@ -39,7 +39,7 @@ export class ResponseTestData { ) ); const b2 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '12', new Date('2019-12-22 13:58:40.3730067'), 120, @@ -64,7 +64,7 @@ export class ResponseTestData { ) ); const b3 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '33', new Date('2019-12-22 13:58:40.3730067'), 120, @@ -103,7 +103,7 @@ export class ResponseTestData { const model = new BookingsListModel(new Date('2019-10-22 00:00:00.0000000')); const lists: Array = []; const b1 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -128,7 +128,7 @@ export class ResponseTestData { ) ); const b2 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '12', new Date('2019-10-22 14:58:40.3730067'), 120, @@ -153,7 +153,7 @@ export class ResponseTestData { ) ); const b3 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '33', new Date('2019-10-22 14:58:40.3730067'), 120, @@ -186,7 +186,7 @@ export class ResponseTestData { const lists1: Array = []; const model1 = new BookingsListModel(new Date('2019-11-22 00:00:00.0000000')); const b11 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '44', new Date('2019-11-22 13:58:40.3730067'), 120, @@ -211,7 +211,7 @@ export class ResponseTestData { ) ); const b21 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '45', new Date('2019-11-22 14:58:40.3730067'), 120, @@ -236,7 +236,7 @@ export class ResponseTestData { ) ); const b31 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '46', new Date('2019-11-22 15:58:40.3730067'), 120, @@ -414,7 +414,7 @@ describe('Booking list service functionality', () => { it('should replace the edited record to the existing correct date group', () => { const bookingsList = ResponseTestData.getBookingsTestData(); const bookingEdited = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-11-22 13:58:40.3730067'), 120, @@ -453,7 +453,7 @@ describe('Booking list service functionality', () => { it('should remove from date group record and add a new date group for the edited record', () => { const bookingsList = ResponseTestData.getBookingsTestData(); const bookingEdited = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-12-22 13:58:40.3730067'), 120, diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-persist.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-persist.service.spec.ts index 2ca4a92c8..fc9cf8b02 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-persist.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-persist.service.spec.ts @@ -3,9 +3,10 @@ import { BookingPersistService } from './bookings-persist.service'; import { v4 as uuid } from 'uuid'; import { CaseModel } from '../common/model/case.model'; import { BookingStatus, CaseResponse, HearingDetailsResponse, JudiciaryParticipantResponse, VideoSupplier } from './clients/api-client'; -import { createVHBooking, VHBooking } from '../common/model/vh-booking'; +import { VHBooking } from '../common/model/vh-booking'; import { BookingsListItemModel } from '../common/model/booking-list-item.model'; import { mapHearingToVHBooking } from '../common/model/api-contract-to-client-model-mappers'; +import { cloneWithGetters } from '../common/helpers/clone-with-getters'; function MockGroupedBookings(hearings: BookingsListItemModel[]): BookingsListModel { const model = new BookingsListModel(new Date()); @@ -83,11 +84,10 @@ describe('BookingsPersistService', () => { describe('#updateBooking', () => { it('should not update if there are no loaded hearings', () => { - const model: VHBooking = { - updated_date: new Date(), - audio_recording_required: true, - supplier: VideoSupplier.Kinly - }; + const model = new VHBooking(); + model.updated_date = new Date(); + model.audio_recording_required = true; + model.supplier = VideoSupplier.Kinly; service.updateBooking(model); expect(service.bookingList.length).toBe(0); }); @@ -95,7 +95,7 @@ describe('BookingsPersistService', () => { it('should not update hearing if it is not selected', () => { service.bookingList = [MockGroupedBookings([MockBookedHearing(), MockBookedHearing()])]; - const hearing = createVHBooking(); + const hearing = new VHBooking(); const updatedCase = new CaseModel(); updatedCase.name = 'updated case'; hearing.case = updatedCase; @@ -111,7 +111,7 @@ describe('BookingsPersistService', () => { service.selectedGroupIndex = 0; service.selectedItemIndex = 0; - const hearing = createVHBooking(); + const hearing = new VHBooking(); hearing.court_room = 'court room'; hearing.court_name = 'court'; @@ -153,13 +153,13 @@ describe('BookingsPersistService', () => { }); }); - it('should update judge name for selected hearing with judiciary participant judge', () => { + fit('should update judge name for selected hearing with judiciary participant judge', () => { service.bookingList = [MockGroupedBookings([MockBookedHearing(), MockBookedHearing()])]; service.selectedGroupIndex = 0; service.selectedItemIndex = 0; - const hearing = { ...service.bookingList[0].BookingsDetails[0] }; + const hearing = cloneWithGetters(service.bookingList[0].BookingsDetails[0]); const judge = hearing.Booking.judge; judge.displayName = 'Judge Test'; @@ -173,13 +173,13 @@ describe('BookingsPersistService', () => { expect(updatedHearing.Booking.judge.displayName).toBe(judge.displayName); }); - it('should update judge name for selected hearing with judiciary participants but no judge', () => { + fit('should update judge name for selected hearing with judiciary participants but no judge', () => { service.bookingList = [MockGroupedBookings([MockBookedHearingWithoutJudge(), MockBookedHearingWithoutJudge()])]; service.selectedGroupIndex = 0; service.selectedItemIndex = 0; - const hearing = { ...service.bookingList[0].BookingsDetails[0] }; + const hearing = cloneWithGetters(service.bookingList[0].BookingsDetails[0]); const panelMember = hearing.Booking.judiciaryParticipants[0]; panelMember.displayName = 'Panel Member'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.spec.ts index 7994be732..2e14aec1d 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.spec.ts @@ -23,7 +23,7 @@ import { InterpreterSelectedDto } from '../booking/interpreter-form/interpreter- import { ScreeningDto } from '../booking/screening/screening.model'; import { ReferenceDataService } from './reference-data.service'; import { MockValues } from '../testing/data/test-objects'; -import { createVHBooking, VHBooking } from '../common/model/vh-booking'; +import { VHBooking } from '../common/model/vh-booking'; describe('Video hearing service', () => { let service: VideoHearingsService; @@ -83,7 +83,7 @@ describe('Video hearing service', () => { }); it('should have changes when updating hearing request', () => { - const model = createVHBooking(); + const model = new VHBooking(); service.updateHearingRequest(model); expect(service.hasUnsavedChanges()).toBe(true); @@ -102,14 +102,14 @@ describe('Video hearing service', () => { }); it('should cache current hearing request', () => { - const model = createVHBooking(); + const model = new VHBooking(); model.hearing_id = 'hearingId'; service.updateHearingRequest(model); expect(service.getCurrentRequest().hearing_id).toBe('hearingId'); }); it('should remove currently cached hearing when cancelling', () => { - const model = createVHBooking(); + const model = new VHBooking(); model.hearing_id = 'hearingId'; service.updateHearingRequest(model); service.cancelRequest(); @@ -121,7 +121,7 @@ describe('Video hearing service', () => { const caseModel = new CaseModel(); caseModel.name = 'case1'; caseModel.number = 'Number 1'; - const model = createVHBooking(); + const model = new VHBooking(); model.case_type = 'Tax'; model.scheduled_date_time = new Date(date); model.scheduled_duration = 30; @@ -143,7 +143,7 @@ describe('Video hearing service', () => { const caseModel = new CaseModel(); caseModel.name = 'case1'; caseModel.number = 'Number 1'; - const model = createVHBooking(); + const model = new VHBooking(); model.case_type = 'Tax'; model.scheduled_date_time = new Date(date); model.scheduled_duration = 30; @@ -297,7 +297,7 @@ describe('Video hearing service', () => { const caseModel = new CaseModel(); caseModel.name = 'case1'; caseModel.number = 'Number 1'; - const hearingModel = createVHBooking(); + const hearingModel = new VHBooking(); hearingModel.court_room = 'Court Room1'; hearingModel.court_name = 'Test Court'; hearingModel.other_information = 'Other Information'; @@ -365,7 +365,7 @@ describe('Video hearing service', () => { const caseModel = new CaseModel(); caseModel.name = 'case1'; caseModel.number = 'Number 1'; - const hearingModel = createVHBooking(); + const hearingModel = new VHBooking(); hearingModel.court_room = 'Court Room1'; hearingModel.court_name = 'Test Court'; hearingModel.other_information = 'Other Information'; @@ -496,28 +496,28 @@ describe('Video hearing service', () => { describe('isConferenceClosed', () => { it('should return false if booking status booked and telephone conference Id is empty', () => { - const model = createVHBooking(); + const model = new VHBooking(); model.status = BookingStatus.Booked; model.telephone_conference_id = ''; service.updateHearingRequest(model); expect(service.isConferenceClosed()).toBe(false); }); it('should return false if booking status created and telephone conference Id is not empty', () => { - const model = createVHBooking(); + const model = new VHBooking(); model.status = BookingStatus.Created; model.telephone_conference_id = '1111'; service.updateHearingRequest(model); expect(service.isConferenceClosed()).toBe(false); }); it('should return false if booking status booked and telephone conference Id is not empty', () => { - const model = createVHBooking(); + const model = new VHBooking(); model.status = BookingStatus.Booked; model.telephone_conference_id = '1111'; service.updateHearingRequest(model); expect(service.isConferenceClosed()).toBe(false); }); it('should return true if booking status created and telephone conference Id is empty', () => { - const model = createVHBooking(); + const model = new VHBooking(); model.status = BookingStatus.Created; model.telephone_conference_id = ''; service.updateHearingRequest(model); @@ -529,7 +529,7 @@ describe('Video hearing service', () => { const aboutToStartMinutesThreshold = 30; let model: VHBooking; beforeEach(() => { - model = createVHBooking(); + model = new VHBooking(); model.scheduled_date_time = new Date(); model.status = BookingStatus.Created; }); @@ -727,7 +727,7 @@ describe('Video hearing service', () => { }); describe('updateMultiDayHearing', () => { - const hearing = createVHBooking(); + const hearing = new VHBooking(); const date = Date.now(); const caseModel = new CaseModel(); caseModel.name = 'case1'; @@ -848,12 +848,12 @@ describe('Video hearing service', () => { describe('isTotalHearingMoreThanThreshold', () => { it('should return false if booking is multiday and the total days are less than 40', () => { - const hearing = createVHBooking(); + const hearing = new VHBooking(); hearing.hearing_id = 'SomeGuid'; hearing.hearingsInGroup = []; for (let i = 0; i < 39; i++) { - const model = createVHBooking(); + const model = new VHBooking(); model.status = BookingStatus.Booked; model.hearing_id = 'guid' + i; hearing.hearingsInGroup.push(model); @@ -865,12 +865,12 @@ describe('Video hearing service', () => { expect(service.isTotalHearingMoreThanThreshold()).toBe(false); }); it('should return true if booking is multiday and the total days are more than 40', () => { - const hearing = createVHBooking(); + const hearing = new VHBooking(); hearing.hearing_id = 'SomeGuid'; hearing.hearingsInGroup = []; for (let i = 0; i < 50; i++) { - const model = createVHBooking(); + const model = new VHBooking(); model.status = BookingStatus.Booked; model.hearing_id = 'guid' + i; hearing.hearingsInGroup.push(model); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.ts index b452f52bf..56527d316 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.ts @@ -37,7 +37,7 @@ import { map, shareReplay } from 'rxjs/operators'; import { InterpreterSelectedDto } from '../booking/interpreter-form/interpreter-selected.model'; import { ScreeningDto } from '../booking/screening/screening.model'; import { ReferenceDataService } from './reference-data.service'; -import { createVHBooking, VHBooking } from '../common/model/vh-booking'; +import { VHBooking } from '../common/model/vh-booking'; import { mapHearingToVHBooking } from '../common/model/api-contract-to-client-model-mappers'; @Injectable({ @@ -72,7 +72,7 @@ export class VideoHearingsService { private checkForExistingHearing() { const localRequest = sessionStorage.getItem(this.newRequestKey); if (localRequest === null) { - this.modelHearing = createVHBooking(); + this.modelHearing = new VHBooking(); } else { this.modelHearing = JSON.parse(localRequest); } @@ -144,7 +144,7 @@ export class VideoHearingsService { } cancelRequest() { - this.modelHearing = createVHBooking(); + this.modelHearing = new VHBooking(); sessionStorage.removeItem(this.newRequestKey); sessionStorage.removeItem(this.bookingHasChangesKey); } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/booking-edit/booking-edit.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/booking-edit/booking-edit.component.spec.ts index 93c18ff55..0300b8a2d 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/booking-edit/booking-edit.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/booking-edit/booking-edit.component.spec.ts @@ -6,7 +6,7 @@ import { BookingService } from '../../services/booking.service'; import { BookingEditComponent } from './booking-edit.component'; import { of } from 'rxjs'; import { LaunchDarklyService, FeatureFlags } from 'src/app/services/launch-darkly.service'; -import { createVHBooking } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; describe('BookingEditComponent', () => { let component: BookingEditComponent; @@ -18,7 +18,7 @@ describe('BookingEditComponent', () => { 'isHearingAboutToStart', 'getCurrentRequest' ]); - videoHearingServiceSpy.getCurrentRequest.and.returnValue(createVHBooking()); + videoHearingServiceSpy.getCurrentRequest.and.returnValue(new VHBooking()); const bookingServiceSpy = jasmine.createSpyObj('BookingService', ['setEditMode']); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/data/response-test-data.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/data/response-test-data.ts index 4a518f0ee..e4d900da5 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/data/response-test-data.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/data/response-test-data.ts @@ -11,7 +11,7 @@ import { } from '../../services/clients/api-client'; import { v4 as uuid } from 'uuid'; import { BookingsListItemModel } from 'src/app/common/model/booking-list-item.model'; -import { createVHBookingFromDetails } from 'src/app/common/model/vh-booking'; +import { VHBooking } from 'src/app/common/model/vh-booking'; export class ResponseTestData { static getHearingResponseTestData(): HearingDetailsResponse { @@ -118,7 +118,7 @@ export class ResponseTestData { const model = new BookingsListModel(new Date('2019-12-22 00:00:00.0000000')); const lists: Array = []; const b1 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-12-22 13:58:40.3730067'), 120, @@ -142,7 +142,7 @@ export class ResponseTestData { ) ); const b2 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '12', new Date('2019-12-22 13:58:40.3730067'), 120, @@ -166,7 +166,7 @@ export class ResponseTestData { ) ); const b3 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '33', new Date('2019-12-22 13:58:40.3730067'), 120, @@ -204,7 +204,7 @@ export class ResponseTestData { const model = new BookingsListModel(new Date('2019-10-22 00:00:00.0000000')); const lists: Array = []; const b1 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '1', new Date('2019-10-22 13:58:40.3730067'), 120, @@ -228,7 +228,7 @@ export class ResponseTestData { ) ); const b2 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '12', new Date('2019-10-22 14:58:40.3730067'), 120, @@ -252,7 +252,7 @@ export class ResponseTestData { ) ); const b3 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '33', new Date('2019-10-22 14:58:40.3730067'), 120, @@ -284,7 +284,7 @@ export class ResponseTestData { const lists1: Array = []; const model1 = new BookingsListModel(new Date('2019-11-22 00:00:00.0000000')); const b11 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '44', new Date('2019-11-22 13:58:40.3730067'), 120, @@ -308,7 +308,7 @@ export class ResponseTestData { ) ); const b21 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '45', new Date('2019-11-22 14:58:40.3730067'), 120, @@ -332,7 +332,7 @@ export class ResponseTestData { ) ); const b31 = new BookingsListItemModel( - createVHBookingFromDetails( + new VHBooking( '46', new Date('2019-11-22 15:58:40.3730067'), 120, diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/helpers/hearing.helpers.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/helpers/hearing.helpers.ts index e2b6813c4..da5e420d5 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/helpers/hearing.helpers.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/helpers/hearing.helpers.ts @@ -3,7 +3,7 @@ import { VHBooking } from 'src/app/common/model/vh-booking'; // Creates a multi day hearing from an existing hearing model export function createMultiDayHearing(currentHearing: VHBooking) { const multiDayHearing: VHBooking = Object.assign({}, currentHearing); - multiDayHearing.isMultiDay = true; + multiDayHearing.groupId = '123'; const scheduledDateTime = new Date(); scheduledDateTime.setSeconds(0); multiDayHearing.scheduled_date_time = scheduledDateTime;