Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/VIH-10367--Presiding-judge-holder-d…
Browse files Browse the repository at this point in the history
…isplay-valiation
  • Loading branch information
will-craig authored Dec 14, 2023
2 parents 8a445f2 + ed89c32 commit 1aa55f7
Show file tree
Hide file tree
Showing 23 changed files with 372 additions and 76 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.49.13",
"contentHash": "3+T2Q9IbsFFTVFRY7vTpNbfChHjilgQQIrAm4ptwPoH6HP9UWtrrM/JOj8/esfOMlajZvBziSXd7qfQPPnepuA==",
"resolved": "1.49.15",
"contentHash": "ye+s7y4jeNSgVd7sgbRee0dnx4HZIegmBxYlWHENPNv5u8zSH15dENPmLX8BODkUKOLpwHiIxQyRMh8KKzlcFQ==",
"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.49.13, )",
"BookingsApi.Client": "[1.49.15, )",
"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 @@ -327,6 +327,7 @@ public async Task Should_catch_BookingsApiException_by_updating_booking_status_a
public async Task Should_clone_hearing()
{
var request = GetMultiHearingRequest();
request.ScheduledDuration = 120;
var groupedHearings = new List<V1.Responses.HearingDetailsResponse>
{
new()
Expand All @@ -350,7 +351,8 @@ public async Task Should_clone_hearing()
response.Should().BeOfType<NoContentResult>();

_mocker.Mock<IBookingsApiClient>().Verify(
x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequest>()),
x => x.CloneHearingAsync(It.IsAny<Guid>(), It.Is<CloneHearingRequest>(
y => y.ScheduledDuration == request.ScheduledDuration)),
Times.Exactly(1));
}

Expand Down Expand Up @@ -395,8 +397,8 @@ public async Task Should_clone_and_confirm_hearing_for_large_booking()
[Test]
public async Task Should_return_bad_request_status_if_no_items_in_the_date_list()
{
var startDate = new DateTime(2020, 10, 1);
var endDate = new DateTime(2020, 10, 1);
var startDate = new DateTime(2020, 10, 1, 0, 0, 0, DateTimeKind.Utc);
var endDate = new DateTime(2020, 10, 1, 0, 0, 0, DateTimeKind.Utc);
var request = new MultiHearingRequest { StartDate = startDate, EndDate = endDate};


Expand Down Expand Up @@ -458,8 +460,8 @@ public async Task Should_clone_hearings_on_weekends_when_start_or_end_date_are_o
[Test]
public async Task Should_not_clone_hearings_on_weekends_when_start_or_end_date_are_on_weekdays()
{
var startDate = new DateTime(2022, 12, 15);
var endDate = new DateTime(2022, 12, 20);
var startDate = new DateTime(2022, 12, 15, 0, 0, 0, DateTimeKind.Utc);
var endDate = new DateTime(2022, 12, 20, 0, 0, 0, DateTimeKind.Utc);
var request = new MultiHearingRequest { StartDate = startDate, EndDate = endDate};
var groupedHearings = new List<V1.Responses.HearingDetailsResponse>
{
Expand All @@ -477,11 +479,11 @@ public async Task Should_not_clone_hearings_on_weekends_when_start_or_end_date_a

var expectedDates = new List<DateTime>
{
new(2022, 12, 16),
new(2022, 12, 17),
new(2022, 12, 18),
new(2022, 12, 19),
new(2022, 12, 20)
new(2022, 12, 16, 0, 0, 0, DateTimeKind.Utc),
new(2022, 12, 17, 0, 0, 0, DateTimeKind.Utc),
new(2022, 12, 18, 0, 0, 0, DateTimeKind.Utc),
new(2022, 12, 19, 0, 0, 0, DateTimeKind.Utc),
new(2022, 12, 20, 0, 0, 0, DateTimeKind.Utc)
};

var response = await _controller.CloneHearing(Guid.NewGuid(), request);
Expand All @@ -499,9 +501,9 @@ public async Task Should_clone_hearings_using_hearing_dates()
{
var hearingDates = new List<DateTime>
{
new (2023, 1, 6),
new (2023, 1, 7),
new (2023, 1, 8)
new (2023, 1, 6, 0, 0, 0, DateTimeKind.Utc),
new (2023, 1, 7, 0, 0, 0, DateTimeKind.Utc),
new (2023, 1, 8, 0, 0, 0, DateTimeKind.Utc)
};
var request = new MultiHearingRequest { HearingDates = hearingDates };
var groupedHearings = new List<V1.Responses.HearingDetailsResponse>
Expand All @@ -520,9 +522,9 @@ public async Task Should_clone_hearings_using_hearing_dates()

var expectedDates = new List<DateTime>
{
new (2023, 1, 6),
new (2023, 1, 7),
new (2023, 1, 8)
new (2023, 1, 6, 0, 0, 0, DateTimeKind.Utc),
new (2023, 1, 7, 0, 0, 0, DateTimeKind.Utc),
new (2023, 1, 8, 0, 0, 0, DateTimeKind.Utc)
};

var response = await _controller.CloneHearing(Guid.NewGuid(), request);
Expand All @@ -537,8 +539,8 @@ public async Task Should_clone_hearings_using_hearing_dates()

private static MultiHearingRequest GetMultiHearingRequest()
{
var startDate = new DateTime(2020, 10, 1);
var endDate = new DateTime(2020, 10, 6);
var startDate = new DateTime(2020, 10, 1, 0, 0, 0, DateTimeKind.Utc);
var endDate = new DateTime(2020, 10, 6, 0, 0, 0, DateTimeKind.Utc);
return new MultiHearingRequest { StartDate = startDate, EndDate = endDate };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Net;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using AdminWebsite.Mappers;
using BookingsApi.Client;
using BookingsApi.Contract.V1.Requests;
using BookingsApi.Contract.V1.Responses;
Expand Down Expand Up @@ -385,8 +386,24 @@ public async Task PostJudgesBySearchTerm_should_return_judiciary_and_courtroom_a
okRequestResult.StatusCode.Should().NotBeNull();
var personRespList = (List<JudgeResponse>)okRequestResult.Value;

var expectedJudiciaryCount = withJudiciary ? _judiciaryResponse.Count : 0;
var expectedCourtRoomCount = withCourtroom ? _courtRoomResponse.Count : 0;
var expectedResponse = new List<JudgeResponse>();
var expectedJudiciaryResponses = new List<JudgeResponse>();
var expectedCourtRoomResponses = new List<JudgeResponse>();

if (withJudiciary)
{
expectedJudiciaryResponses = _judiciaryResponse.Select(JudgeResponseMapper.MapTo).ToList();
expectedResponse.AddRange(expectedJudiciaryResponses);
}

if (withCourtroom)
{
expectedCourtRoomResponses = _courtRoomResponse.ToList();
expectedResponse.AddRange(_courtRoomResponse);
}

var expectedJudiciaryCount = withJudiciary ? expectedJudiciaryResponses.Count : 0;
var expectedCourtRoomCount = withCourtroom ? expectedCourtRoomResponses.Count : 0;

var expectedTotal = expectedJudiciaryCount + expectedCourtRoomCount;

Expand All @@ -397,6 +414,8 @@ public async Task PostJudgesBySearchTerm_should_return_judiciary_and_courtroom_a
Assert.That(personRespList, Is.Not.EqualTo(_courtRoomResponse));
Assert.That(personRespList, Is.EqualTo(_courtRoomResponse.OrderBy(x => x.Email)));
}

personRespList.Should().BeEquivalentTo(expectedResponse);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AdminWebsite.Contracts.Responses;
using AdminWebsite.Contracts.Enums;
using AdminWebsite.Contracts.Responses;
using AdminWebsite.Mappers;
using BookingsApi.Contract.V1.Responses;
using FluentAssertions;
Expand Down Expand Up @@ -26,5 +27,29 @@ public void Should_map_person_response_to_judge_response()
judgeResponse.Email.Should().Be(personResponse.Email);
judgeResponse.ContactEmail.Should().Be(personResponse.ContactEmail);
}

[Test]
public void Should_map_judiciary_person_response_to_judge_response()
{
var judiciaryPersonResponse = new JudiciaryPersonResponse
{
Title = "Mr",
FirstName = "FirstName",
LastName = "LastName",
FullName = "FirstName LastName",
Email = "[email protected]",
WorkPhone = "123",
PersonalCode = "PersonalCode"
};

var judgeResponse = JudgeResponseMapper.MapTo(judiciaryPersonResponse);

judgeResponse.FirstName.Should().Be(judiciaryPersonResponse.FirstName);
judgeResponse.LastName.Should().Be(judiciaryPersonResponse.LastName);
judgeResponse.DisplayName.Should().Be(judiciaryPersonResponse.FullName);
judgeResponse.Email.Should().Be(judiciaryPersonResponse.Email);
judgeResponse.ContactEmail.Should().Be(judiciaryPersonResponse.Email);
judgeResponse.AccountType.Should().Be(JudgeAccountType.Judiciary);
}
}
}
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.49.13",
"contentHash": "3+T2Q9IbsFFTVFRY7vTpNbfChHjilgQQIrAm4ptwPoH6HP9UWtrrM/JOj8/esfOMlajZvBziSXd7qfQPPnepuA==",
"resolved": "1.49.15",
"contentHash": "ye+s7y4jeNSgVd7sgbRee0dnx4HZIegmBxYlWHENPNv5u8zSH15dENPmLX8BODkUKOLpwHiIxQyRMh8KKzlcFQ==",
"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.49.13, )",
"BookingsApi.Client": "[1.49.15, )",
"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.49.13" />
<PackageReference Include="BookingsApi.Client" Version="1.49.15" />
<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
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ <h2 class="govuk-heading-m">Time and location</h2>
</div>
</div>

<div *ngIf="!multiDaysHearing" class="vh-bottom-m">
<div *ngIf="showDurationControls" class="vh-bottom-m">
<div
[ngClass]="
hearingDurationHourInvalid || hearingDurationMinuteInvalid || durationInvalid ? 'govuk-form-group--error' : 'govuk-form-group'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('HearingScheduleComponent first visit', () => {

launchDarklyServiceSpy = jasmine.createSpyObj<LaunchDarklyService>('LaunchDarklyService', ['getFlag']);
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.useV2Api).and.returnValue(of(false));
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(false));

TestBed.configureTestingModule({
imports: [SharedModule, RouterTestingModule],
Expand Down Expand Up @@ -244,6 +245,7 @@ describe('HearingScheduleComponent first visit', () => {

it('should update hearing request when form is valid', () => {
expect(component.form.valid).toBeFalsy();
component.multiDaysHearing = true;
multiDaysControl.setValue(false);
dateControl.setValue('9999-12-30');
endDateControl.setValue('0001-01-01');
Expand Down Expand Up @@ -273,6 +275,7 @@ describe('HearingScheduleComponent first visit', () => {
component.isStartHoursInPast = true;
component.isStartMinutesInPast = true;
component.hasSaved = false;
component.multiDaysHearing = true;
multiDaysControl.setValue(false);

expect(component.form.valid).toBeTruthy();
Expand Down Expand Up @@ -416,6 +419,7 @@ describe('HearingScheduleComponent returning to page', () => {

launchDarklyServiceSpy = jasmine.createSpyObj<LaunchDarklyService>('LaunchDarklyService', ['getFlag']);
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.useV2Api).and.returnValue(of(false));
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(false));

TestBed.configureTestingModule({
imports: [HttpClientModule, ReactiveFormsModule, RouterTestingModule],
Expand Down Expand Up @@ -574,6 +578,7 @@ describe('HearingScheduleComponent multi days hearing', () => {

launchDarklyServiceSpy = jasmine.createSpyObj<LaunchDarklyService>('LaunchDarklyService', ['getFlag']);
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.useV2Api).and.returnValue(of(false));
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(false));

TestBed.configureTestingModule({
imports: [HttpClientModule, ReactiveFormsModule, RouterTestingModule],
Expand Down Expand Up @@ -684,4 +689,33 @@ describe('HearingScheduleComponent multi days hearing', () => {
component.ngOnInit();
expect(component.isBookedHearing).toBe(false);
});

describe('multi day booking enhancements enabled', () => {
beforeEach(() => {
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(true));
component.ngOnInit();
fixture.detectChanges();
});

it('should retain duration values after ticking multi-days', () => {
const durationHours = 2;
const durationMinutes = 45;
component.durationHourControl.setValue(durationHours);
component.durationMinuteControl.setValue(durationMinutes);
component.multiDaysControl.setValue(true);
expect(component.durationHourControl.value).toBe(durationHours);
expect(component.durationMinuteControl.value).toBe(durationMinutes);
});

it('should retain duration values after unticking multi-days', () => {
const durationHours = 1;
const durationMinutes = 30;
component.durationHourControl.setValue(durationHours);
component.durationMinuteControl.setValue(durationMinutes);
component.multiDaysHearing = true;
component.multiDaysControl.setValue(false);
expect(component.durationHourControl.value).toBe(durationHours);
expect(component.durationMinuteControl.value).toBe(durationMinutes);
});
});
});
Loading

0 comments on commit 1aa55f7

Please sign in to comment.