Skip to content

Commit a3878d9

Browse files
committed
Block ability to merge a person record which has MQs
1 parent def6d30 commit a3878d9

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

  • TeachingRecordSystem
    • src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail
    • tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail

TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/Index.cshtml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public async Task OnGetAsync()
3333
.IgnoreQueryFilters()
3434
.Include(p => p.PreviousNames).AsSplitQuery()
3535
.Include(p => p.Alerts).AsSplitQuery()
36+
.Include(p => p.Qualifications).AsSplitQuery()
3637
.SingleAsync(p => p.PersonId == PersonId);
3738

3839
Person = BuildPersonInfo(person);
@@ -48,9 +49,13 @@ public async Task OnGetAsync()
4849
canEditPersonData &&
4950
Person.IsActive;
5051

52+
var hasMandatoryQualification = person.Qualifications!
53+
.Any(q => q.QualificationType == QualificationType.MandatoryQualification);
54+
5155
CanMerge =
5256
canEditNonPersonOrAlertData &&
5357
!HasOpenAlert &&
58+
!hasMandatoryQualification &&
5459
Person!.IsActive &&
5560
(PersonProfessionalStatus is not PersonProfessionalStatusInfo professionalStatus ||
5661
!_invalidInductionStatusesForMerge.Contains(professionalStatus.InductionStatus));

TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Persons/PersonDetail/IndexTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,23 @@ public async Task Get_PersonDoesNotHaveOpenAlert_ShowsMergeButton()
478478
Assert.NotNull(doc.GetElementByTestId("merge-button"));
479479
}
480480

481+
[Fact]
482+
public async Task Get_PersonHasMandatoryQualification_DoesNotShowMergeButton()
483+
{
484+
// Arrange
485+
var person = await TestData.CreatePersonAsync(p => p
486+
.WithMandatoryQualification());
487+
488+
var request = new HttpRequestMessage(HttpMethod.Get, $"/persons/{person.PersonId}");
489+
490+
// Act
491+
var response = await HttpClient.SendAsync(request);
492+
493+
// Assert
494+
var doc = await AssertEx.HtmlResponseAsync(response);
495+
Assert.Null(doc.GetElementByTestId("merge-button"));
496+
}
497+
481498
[Theory]
482499
[InlineData(InductionStatus.InProgress, false)]
483500
[InlineData(InductionStatus.Passed, false)]

0 commit comments

Comments
 (0)