Skip to content

Commit

Permalink
Merge branch 'master' into VIH-10306-review-gds-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
will-craig authored Mar 19, 2024
2 parents 278376b + ad29f5e commit f9a43fd
Show file tree
Hide file tree
Showing 30 changed files with 955 additions and 232 deletions.
6 changes: 3 additions & 3 deletions AdminWebsite/AdminWebsite.IntegrationTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@
},
"BookingsApi.Client": {
"type": "Transitive",
"resolved": "1.51.14",
"contentHash": "LSDN8PFQSBdJIm8ZK6d8LITIRuxwgDzd+7vDCHlT5Ry8Lu6qp4QZOxUgpqkath1IKtAXCpDtN0AQ4v4wLo3ibQ==",
"resolved": "1.52.2",
"contentHash": "TUHNSqHwu8nxw6rWN1LNCrpi8IZtGVUuRhrFtDEeF7ePjtrEMgNSxRaqw/+CXaAhRI5yTLmL60fGoYJGaclEeg==",
"dependencies": {
"Microsoft.AspNetCore.Mvc.Core": "2.2.5"
}
Expand Down Expand Up @@ -2101,7 +2101,7 @@
"type": "Project",
"dependencies": {
"AspNetCore.HealthChecks.Uris": "[6.0.3, )",
"BookingsApi.Client": "[1.51.14, )",
"BookingsApi.Client": "[1.52.2, )",
"FluentValidation.AspNetCore": "[10.4.0, )",
"LaunchDarkly.ServerSdk": "[7.0.3, )",
"MicroElements.Swashbuckle.FluentValidation": "[5.7.0, )",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,31 @@ public async Task Should_update_multi_day_hearing_for_v1(bool updateFutureDays)
// Arrange
var hearingId = Guid.NewGuid();
var groupId = Guid.NewGuid();
var existingHearingsInMultiDayGroup = CreateListOfV1HearingsInMultiDayGroup(groupId, hearingId);
var hearingDates = new List<DateTime>
{
DateTime.Today.AddDays(1).AddHours(10),
DateTime.UtcNow.AddDays(2).AddHours(10),
DateTime.UtcNow.AddDays(3).AddHours(10),
DateTime.UtcNow.AddDays(4).AddHours(10),
DateTime.UtcNow.AddDays(5).AddHours(10),
};
var existingHearingsInMultiDayGroup = CreateListOfV1HearingsInMultiDayGroup(groupId, hearingId, scheduledDates: hearingDates);
existingHearingsInMultiDayGroup[3].Status = BookingStatus.Cancelled;
existingHearingsInMultiDayGroup[4].Status = BookingStatus.Failed;
BookingsApiClient.Setup(x => x.GetHearingsByGroupIdAsync(groupId)).ReturnsAsync(existingHearingsInMultiDayGroup);
var hearing = existingHearingsInMultiDayGroup.First(x => x.Id == hearingId);

var request = CreateV1EditMultiDayHearingRequest(hearing);
request.UpdateFutureDays = updateFutureDays;
request.HearingsInGroup = new List<UpdateHearingInGroupRequest>();
foreach (var hearingInGroup in existingHearingsInMultiDayGroup)
{
request.HearingsInGroup.Add(new UpdateHearingInGroupRequest
{
HearingId = hearingInGroup.Id,
ScheduledDateTime = hearingInGroup.ScheduledDateTime.AddDays(1)
});
}
FeatureToggle.Setup(e => e.UseV2Api()).Returns(false);

// Change the judge
Expand Down Expand Up @@ -89,6 +108,12 @@ public async Task Should_update_multi_day_hearing_for_v1(bool updateFutureDays)
{
expectedUpdatedHearings.Add(hearing);
}

expectedUpdatedHearings = expectedUpdatedHearings
.Where(h =>
h.Status != BookingStatus.Cancelled &&
h.Status != BookingStatus.Failed)
.ToList();

var oldJudges = expectedUpdatedHearings
.Where(h => h.Participants.Exists(p => p.HearingRoleName == "Judge"))
Expand All @@ -101,10 +126,17 @@ public async Task Should_update_multi_day_hearing_for_v1(bool updateFutureDays)
.Where(e => e.DisplayName == endpointToRemove.DisplayName)
.ToList();

// Hearing details common to all hearings in the group
BookingsApiClient.Verify(x => x.UpdateHearingsInGroupAsync(
groupId,
It.Is<UpdateHearingsInGroupRequest>(r =>
r.Hearings.TrueForAll(h =>
h.ScheduledDuration == request.ScheduledDuration &&
h.HearingVenueName == request.HearingVenueName &&
h.HearingRoomName == request.HearingRoomName &&
h.OtherInformation == request.OtherInformation &&
h.CaseNumber == request.CaseNumber &&
h.AudioRecordingRequired == request.AudioRecordingRequired &&
h.Participants.ExistingParticipants.Count == 1 &&
h.Participants.NewParticipants.Count == 2 &&
h.Participants.NewParticipants.Exists(p => p.ContactEmail == newParticipant.ContactEmail) &&
Expand All @@ -115,6 +147,22 @@ public async Task Should_update_multi_day_hearing_for_v1(bool updateFutureDays)
h.Endpoints.RemovedEndpointIds.Any(id => removedEndpoints.Any(e => e.Id == id)
)))));

// Hearing details specific to each hearing in the group
foreach (var hearingInGroup in request.HearingsInGroup)
{
if (!expectedUpdatedHearings.Exists(h => h.Id == hearingInGroup.HearingId))
{
continue;
}

BookingsApiClient.Verify(x => x.UpdateHearingsInGroupAsync(
groupId,
It.Is<UpdateHearingsInGroupRequest>(r =>
r.Hearings.Exists(h =>
h.HearingId == hearingInGroup.HearingId &&
h.ScheduledDateTime == hearingInGroup.ScheduledDateTime))));
}

BookingsApiClient.Verify(x => x.UpdateHearingsInGroupAsync(
groupId,
It.Is<UpdateHearingsInGroupRequest>(r =>
Expand All @@ -129,12 +177,31 @@ public async Task Should_update_multi_day_hearing_for_v2(bool updateFutureDays)
// Arrange
var hearingId = Guid.NewGuid();
var groupId = Guid.NewGuid();
var existingHearingsInMultiDayGroup = CreateListOfV2HearingsInMultiDayGroup(groupId, hearingId);
var hearingDates = new List<DateTime>
{
DateTime.Today.AddDays(1).AddHours(10),
DateTime.UtcNow.AddDays(2).AddHours(10),
DateTime.UtcNow.AddDays(3).AddHours(10),
DateTime.UtcNow.AddDays(4).AddHours(10),
DateTime.UtcNow.AddDays(5).AddHours(10),
};
var existingHearingsInMultiDayGroup = CreateListOfV2HearingsInMultiDayGroup(groupId, hearingId, scheduledDates: hearingDates);
existingHearingsInMultiDayGroup[3].Status = BookingStatus.Cancelled;
existingHearingsInMultiDayGroup[4].Status = BookingStatus.Failed;
BookingsApiClient.Setup(x => x.GetHearingsByGroupIdAsync(groupId)).ReturnsAsync(existingHearingsInMultiDayGroup);
var hearing = existingHearingsInMultiDayGroup.First(x => x.Id == hearingId);

var request = CreateV2EditMultiDayHearingRequest(hearing);
request.UpdateFutureDays = updateFutureDays;
request.HearingsInGroup = new List<UpdateHearingInGroupRequest>();
foreach (var hearingInGroup in existingHearingsInMultiDayGroup)
{
request.HearingsInGroup.Add(new UpdateHearingInGroupRequest
{
HearingId = hearingInGroup.Id,
ScheduledDateTime = hearingInGroup.ScheduledDateTime.AddDays(1)
});
}
FeatureToggle.Setup(e => e.UseV2Api()).Returns(true);

// Change the judge
Expand Down Expand Up @@ -183,15 +250,28 @@ public async Task Should_update_multi_day_hearing_for_v2(bool updateFutureDays)
expectedUpdatedHearings.Add(hearing);
}

expectedUpdatedHearings = expectedUpdatedHearings
.Where(h =>
h.Status != BookingStatus.Cancelled &&
h.Status != BookingStatus.Failed)
.ToList();

var removedEndpoints = expectedUpdatedHearings
.SelectMany(h => h.Endpoints)
.Where(e => e.DisplayName == endpointToRemove.DisplayName)
.ToList();

// Hearing details common to all hearings in the group
BookingsApiClient.Verify(x => x.UpdateHearingsInGroupV2Async(
groupId,
It.Is<UpdateHearingsInGroupRequestV2>(r =>
r.Hearings.TrueForAll(h =>
h.ScheduledDuration == request.ScheduledDuration &&
h.HearingVenueCode == request.HearingVenueCode &&
h.HearingRoomName == request.HearingRoomName &&
h.OtherInformation == request.OtherInformation &&
h.CaseNumber == request.CaseNumber &&
h.AudioRecordingRequired == request.AudioRecordingRequired &&
h.Participants.ExistingParticipants.Count == 1 &&
h.Participants.NewParticipants.Count == 1 &&
h.Participants.NewParticipants.Exists(p => p.ContactEmail == newParticipant.ContactEmail) &&
Expand All @@ -203,6 +283,22 @@ public async Task Should_update_multi_day_hearing_for_v2(bool updateFutureDays)
h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Exists(p => p == oldJudgePersonalCode)
)))));

// Hearing details specific to each hearing in the group
foreach (var hearingInGroup in request.HearingsInGroup)
{
if (!expectedUpdatedHearings.Exists(h => h.Id == hearingInGroup.HearingId))
{
continue;
}

BookingsApiClient.Verify(x => x.UpdateHearingsInGroupV2Async(
groupId,
It.Is<UpdateHearingsInGroupRequestV2>(r =>
r.Hearings.Exists(h =>
h.HearingId == hearingInGroup.HearingId &&
h.ScheduledDateTime == hearingInGroup.ScheduledDateTime))));
}

BookingsApiClient.Verify(x => x.UpdateHearingsInGroupV2Async(
groupId,
It.Is<UpdateHearingsInGroupRequestV2>(r =>
Expand All @@ -221,6 +317,15 @@ public async Task should_update_multi_day_hearing_for_v2_when_judiciary_particip
var hearing = existingHearingsInMultiDayGroup.First(x => x.Id == hearingId);

var request = CreateV2EditMultiDayHearingRequest(hearing);
request.HearingsInGroup = new List<UpdateHearingInGroupRequest>();
foreach (var hearingInGroup in existingHearingsInMultiDayGroup)
{
request.HearingsInGroup.Add(new UpdateHearingInGroupRequest
{
HearingId = hearingInGroup.Id,
ScheduledDateTime = hearingInGroup.ScheduledDateTime
});
}
FeatureToggle.Setup(e => e.UseV2Api()).Returns(true);

var updatedHearing = MapUpdatedHearingV2(hearing, request);
Expand Down Expand Up @@ -484,6 +589,12 @@ private static EditMultiDayHearingRequest CreateV1EditMultiDayHearingRequest(Hea
private static EditMultiDayHearingRequest CreateV2EditMultiDayHearingRequest(HearingDetailsResponse hearing) =>
new()
{
ScheduledDuration = 90,
HearingVenueCode = "701411",
HearingRoomName = "HearingRoomName",
OtherInformation = "OtherInformation",
CaseNumber = "CaseNumber",
AudioRecordingRequired = true,
Participants = hearing.Participants.Select(x => new EditParticipantRequest
{
Id = x.Id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ public async Task Should_return_ok_status_for_multi_day_hearing_V1()
var dates = new List<DateTime>
{
_vhExistingHearingV1.ScheduledDateTime.AddDays(1),
_vhExistingHearingV1.ScheduledDateTime.AddDays(2)
_vhExistingHearingV1.ScheduledDateTime.AddDays(2),
_vhExistingHearingV1.ScheduledDateTime.AddDays(3),
_vhExistingHearingV1.ScheduledDateTime.AddDays(4)
};
var multiDayHearings = new List<BookingsApi.Contract.V1.Responses.HearingDetailsResponse>
{
Expand All @@ -219,8 +221,12 @@ public async Task Should_return_ok_status_for_multi_day_hearing_V1()
Id = Guid.NewGuid(),
ScheduledDateTime = date,
ScheduledDuration = _vhExistingHearingV1.ScheduledDuration,
GroupId = groupId
GroupId = groupId,
Status = BookingStatus.Created
}));
// Set some to cancelled and failed so we can test they are filtered out
multiDayHearings[2].Status = BookingStatus.Cancelled;
multiDayHearings[3].Status = BookingStatus.Failed;
_mocker.Mock<IBookingsApiClient>().Setup(x => x.GetHearingsByGroupIdAsync(groupId))
.ReturnsAsync(multiDayHearings);

Expand All @@ -232,7 +238,12 @@ public async Task Should_return_ok_status_for_multi_day_hearing_V1()
okRequestResult.StatusCode.Should().Be(200);

var response = (HearingDetailsResponse) ((OkObjectResult) result).Value;
var expectedHearingLastDay = multiDayHearings[^1];
var expectedActiveHearingsInGroup = multiDayHearings
.Where(h =>
h.Status != BookingStatus.Cancelled &&
h.Status != BookingStatus.Failed)
.ToList();
var expectedHearingLastDay = expectedActiveHearingsInGroup[^1];
response.MultiDayHearingLastDayScheduledDateTime.Should().Be(expectedHearingLastDay.ScheduledDateTime);
response.HearingsInGroup.Should().BeEquivalentTo(multiDayHearings.Select(x => x.Map()));
}
Expand All @@ -251,7 +262,9 @@ public async Task Should_return_ok_status_for_multi_day_hearing_V2()
var dates = new List<DateTime>
{
_vhExistingHearingV2.ScheduledDateTime.AddDays(1),
_vhExistingHearingV2.ScheduledDateTime.AddDays(2)
_vhExistingHearingV2.ScheduledDateTime.AddDays(2),
_vhExistingHearingV2.ScheduledDateTime.AddDays(3),
_vhExistingHearingV2.ScheduledDateTime.AddDays(4),
};
var multiDayHearings = new List<HearingDetailsResponseV2>
{
Expand All @@ -262,8 +275,12 @@ public async Task Should_return_ok_status_for_multi_day_hearing_V2()
Id = Guid.NewGuid(),
ScheduledDateTime = date,
ScheduledDuration = _vhExistingHearingV2.ScheduledDuration,
GroupId = groupId
GroupId = groupId,
Status = BookingStatusV2.Created
}));
// Set some to cancelled and failed so we can test they are filtered out
multiDayHearings[2].Status = BookingStatusV2.Cancelled;
multiDayHearings[3].Status = BookingStatusV2.Failed;
_mocker.Mock<IBookingsApiClient>().Setup(x => x.GetHearingsByGroupIdV2Async(groupId))
.ReturnsAsync(multiDayHearings);

Expand All @@ -275,7 +292,12 @@ public async Task Should_return_ok_status_for_multi_day_hearing_V2()
okRequestResult.StatusCode.Should().Be(200);

var response = (HearingDetailsResponse) ((OkObjectResult) result).Value;
var expectedHearingLastDay = multiDayHearings[^1];
var expectedActiveHearingsInGroup = multiDayHearings
.Where(h =>
h.Status != BookingStatusV2.Cancelled &&
h.Status != BookingStatusV2.Failed)
.ToList();
var expectedHearingLastDay = expectedActiveHearingsInGroup[^1];
response.MultiDayHearingLastDayScheduledDateTime.Should().Be(expectedHearingLastDay.ScheduledDateTime);
response.HearingsInGroup.Should().BeEquivalentTo(multiDayHearings.Select(x => x.Map()));
}
Expand Down
6 changes: 3 additions & 3 deletions AdminWebsite/AdminWebsite.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
},
"BookingsApi.Client": {
"type": "Transitive",
"resolved": "1.51.14",
"contentHash": "LSDN8PFQSBdJIm8ZK6d8LITIRuxwgDzd+7vDCHlT5Ry8Lu6qp4QZOxUgpqkath1IKtAXCpDtN0AQ4v4wLo3ibQ==",
"resolved": "1.52.2",
"contentHash": "TUHNSqHwu8nxw6rWN1LNCrpi8IZtGVUuRhrFtDEeF7ePjtrEMgNSxRaqw/+CXaAhRI5yTLmL60fGoYJGaclEeg==",
"dependencies": {
"Microsoft.AspNetCore.Mvc.Core": "2.2.5"
}
Expand Down Expand Up @@ -1979,7 +1979,7 @@
"type": "Project",
"dependencies": {
"AspNetCore.HealthChecks.Uris": "[6.0.3, )",
"BookingsApi.Client": "[1.51.14, )",
"BookingsApi.Client": "[1.52.2, )",
"FluentValidation.AspNetCore": "[10.4.0, )",
"LaunchDarkly.ServerSdk": "[7.0.3, )",
"MicroElements.Swashbuckle.FluentValidation": "[5.7.0, )",
Expand Down
2 changes: 1 addition & 1 deletion AdminWebsite/AdminWebsite/AdminWebsite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="6.0.3" />
<PackageReference Include="BookingsApi.Client" Version="1.51.14" />
<PackageReference Include="BookingsApi.Client" Version="1.52.2" />
<PackageReference Include="LaunchDarkly.ServerSdk" Version="7.0.3" />
<PackageReference Include="MicroElements.Swashbuckle.FluentValidation" Version="5.7.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.51.0" />
Expand Down
4 changes: 1 addition & 3 deletions AdminWebsite/AdminWebsite/ClientApp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { AuthGuard } from './security/guards/auth.guard';
import { ReformLoginComponent } from './security/reform-login.component';
import { AudioSearchGuard } from './security/audio-search.guard';
import { ManageTeamFeatureGuard } from './security/guards/manage-team-feature.guard';
import { EditMultiDayBookingGuard } from './security/guards/edit-multi-day-booking.guard';

export function loadConfig(configService: ConfigService) {
return () => configService.loadConfig();
Expand Down Expand Up @@ -104,8 +103,7 @@ export function loadConfig(configService: ConfigService) {
WindowRef,
WorkAllocationFeatureGuard,
ManageTeamFeatureGuard,
AudioSearchGuard,
EditMultiDayBookingGuard
AudioSearchGuard
],
exports: [UnallocatedHearingsComponent],
bootstrap: [AppComponent]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ import { AddJudicialOfficeHoldersComponent } from './judicial-office-holders/add
import { LastMinuteAmendmentsGuard } from '../security/guards/last-minute-amendments.guard';
import { AdminGuard } from '../security/guards/admin.guard';
import { AuthGuard } from '../security/guards/auth.guard';
import { EditMultiDayBookingGuard } from '../security/guards/edit-multi-day-booking.guard';

export const routes: Routes = [
{
path: 'book-hearing',
component: CreateHearingComponent,
canActivate: [AuthGuard, AdminGuard, LastMinuteAmendmentsGuard, EditMultiDayBookingGuard]
canActivate: [AuthGuard, AdminGuard, LastMinuteAmendmentsGuard]
},
{
path: 'hearing-schedule',
component: HearingScheduleComponent,
canActivate: [AuthGuard, AdminGuard, LastMinuteAmendmentsGuard, EditMultiDayBookingGuard]
canActivate: [AuthGuard, AdminGuard, LastMinuteAmendmentsGuard]
},
{
path: 'assign-judge',
Expand All @@ -43,7 +42,7 @@ export const routes: Routes = [
{
path: 'other-information',
component: OtherInformationComponent,
canActivate: [AuthGuard, AdminGuard, LastMinuteAmendmentsGuard, EditMultiDayBookingGuard]
canActivate: [AuthGuard, AdminGuard, LastMinuteAmendmentsGuard]
},
{ path: 'summary', component: SummaryComponent, canActivate: [AuthGuard, AdminGuard] },
{ path: 'booking-confirmation', component: BookingConfirmationComponent, canActivate: [AuthGuard, AdminGuard] }
Expand Down
Loading

0 comments on commit f9a43fd

Please sign in to comment.