Skip to content

Commit

Permalink
Added trn verification leve to dqt record pane
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevJoy committed Oct 9, 2023
1 parent ef0c261 commit cce03eb
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@
<govuk-summary-list-row-key>TRN</govuk-summary-list-row-key>
<govuk-summary-list-row-value>@Model.Trn</govuk-summary-list-row-value>
</govuk-summary-list-row>
@{
if(Model.EffectiveVerificationLevel == TrnVerificationLevel.Low)
{
<govuk-summary-list-row>
<govuk-summary-list-row-key>TRN verification level</govuk-summary-list-row-key>
<govuk-summary-list-row-value><govuk-tag class="govuk-tag--yellow">Low</govuk-tag></govuk-summary-list-row-value>
</govuk-summary-list-row>
}
else if(Model.EffectiveVerificationLevel == TrnVerificationLevel.Medium)
{
<govuk-summary-list-row>
<govuk-summary-list-row-key>TRN verification level</govuk-summary-list-row-key>
<govuk-summary-list-row-value><govuk-tag class="govuk-tag--blue">Medium</govuk-tag></govuk-summary-list-row-value>
</govuk-summary-list-row>
}
}
</govuk-summary-list>
</div>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public UserModel(TeacherIdentityServerDbContext dbContext, IDqtApiClient dqtApiC

public IEnumerable<Guid>? MergedUserIds { get; set; }

public TrnVerificationLevel? EffectiveVerificationLevel { get; set; }

[FromRoute]
public Guid UserId { get; set; }

Expand All @@ -71,7 +73,8 @@ public async Task<IActionResult> OnGet()
u.Created,
u.UserType,
MergedUserIds = u.MergedUsers!.Select(mu => mu.UserId),
RegisteredWithClientDisplayName = u.RegisteredWithClient != null ? u.RegisteredWithClient.DisplayName : null
RegisteredWithClientDisplayName = u.RegisteredWithClient != null ? u.RegisteredWithClient.DisplayName : null,
u.EffectiveVerificationLevel
})
.SingleOrDefaultAsync();

Expand All @@ -96,6 +99,7 @@ public async Task<IActionResult> OnGet()
CanChangeDqtRecord = !HaveDqtRecord;
MergedUserIds = user.MergedUserIds;
DateOfBirth = user.DateOfBirth;
EffectiveVerificationLevel = user.EffectiveVerificationLevel;

if (user.Trn is not null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

namespace TeacherIdentity.AuthServer.Tests.EndpointTests.Admin;

public class UserTests : TestBase
Expand Down Expand Up @@ -137,4 +138,58 @@ public async Task Get_ValidRequestForUserWithMergedUsers_RendersExpectedContent(
var doc = await response.GetDocument();
Assert.Equal(mergedUser.UserId.ToString(), doc.GetSummaryListValueForKey("Merged user IDs"));
}

[Theory]
[InlineData(Models.TrnVerificationLevel.Low, "Low")]
[InlineData(Models.TrnVerificationLevel.Medium, "Medium")]
public async Task Get_ValidRequestForTrnVerificationLevel_RendersExpectedContent(Models.TrnVerificationLevel trnVerificationLevel, string verificationLevelString)
{
// Arrange
var user = await TestData.CreateUser(hasTrn: true, userType: Models.UserType.Teacher, hasPreferredName: true, trnVerificationLevel: trnVerificationLevel);
var request = new HttpRequestMessage(HttpMethod.Get, $"/admin/users/{user.UserId}");
var dqtFirstName = Faker.Name.First();
var dqtLastName = Faker.Name.Last();
var dqtDateOfBirth = DateOnly.FromDateTime(Faker.Identification.DateOfBirth());
var dqtNino = Faker.Identification.UkNationalInsuranceNumber();

HostFixture.DqtApiClient.Setup(mock => mock.GetTeacherByTrn(user.Trn!, It.IsAny<CancellationToken>()))
.ReturnsAsync(new AuthServer.Services.DqtApi.TeacherInfo()
{
DateOfBirth = dqtDateOfBirth,
FirstName = dqtFirstName,
MiddleName = "",
LastName = dqtLastName,
NationalInsuranceNumber = dqtNino,
Trn = user.Trn!,
PendingNameChange = false,
PendingDateOfBirthChange = false,
Email = null
});

// Act
var response = await HttpClient.SendAsync(request);

// Assert
Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);

var doc = await response.GetDocument();
Assert.Equal(verificationLevelString, doc.GetSummaryListValueForKey("TRN verification level"));
}

[Fact]
public async Task Get_ValidRequestForUserWithoutTRN_DoesNotRenderTrnVerificationLevelSummaryRow()
{
// Arrange
var user = await TestData.CreateUser(hasTrn: false, userType: Models.UserType.Teacher, hasPreferredName: true);
var request = new HttpRequestMessage(HttpMethod.Get, $"/admin/users/{user.UserId}");

// Act
var response = await HttpClient.SendAsync(request);

// Assert
Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode);

var doc = await response.GetDocument();
Assert.Null(doc.GetSummaryListRowForKey("TRN verification level"));
}
}

0 comments on commit cce03eb

Please sign in to comment.