Skip to content

Commit

Permalink
Merge pull request #349 from DFE-Digital/fix-idam-main-sonar-cloud-issue
Browse files Browse the repository at this point in the history
Fix failing IDAM maintenance tests
  • Loading branch information
stevesatdfe authored Jan 8, 2025
2 parents 6e483ac + c24e8a4 commit 6dae1e0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FamilyHubs.Idams.Maintenanc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FamilyHubs.Idams.Maintenance.Data", "src\FamilyHubs.Idams.Maintenance.Data\FamilyHubs.Idams.Maintenance.Data.csproj", "{F2B53CDD-7D07-4266-80B4-EF762C77B376}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FamilyHubs.Idams.Maintenance.UnitTests", "tests\FamilyHubs.Idams.Maintenance.UnitTests\FamilyHubs.Idams.Maintenance.UnitTests.csproj", "{12079D2F-F42D-4B86-A50F-E4D0118B1138}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -31,6 +33,10 @@ Global
{F2B53CDD-7D07-4266-80B4-EF762C77B376}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2B53CDD-7D07-4266-80B4-EF762C77B376}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2B53CDD-7D07-4266-80B4-EF762C77B376}.Release|Any CPU.Build.0 = Release|Any CPU
{12079D2F-F42D-4B86-A50F-E4D0118B1138}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12079D2F-F42D-4B86-A50F-E4D0118B1138}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12079D2F-F42D-4B86-A50F-E4D0118B1138}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12079D2F-F42D-4B86-A50F-E4D0118B1138}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -39,6 +45,7 @@ Global
{CB6D66EE-E5A0-4E6C-895A-97B1D6692E88} = {4988CDF2-ECFB-47DA-B9F6-A4DF3138E8CA}
{47D73AD1-2441-42C7-A6CF-C4EA143ABF5C} = {4988CDF2-ECFB-47DA-B9F6-A4DF3138E8CA}
{F2B53CDD-7D07-4266-80B4-EF762C77B376} = {4988CDF2-ECFB-47DA-B9F6-A4DF3138E8CA}
{12079D2F-F42D-4B86-A50F-E4D0118B1138} = {9C7D8127-6A9A-4AD7-ADCC-0C6DBD186166}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A3C58AC5-822F-4BAD-961F-0382482F2F22}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
<div class="govuk-form-group">
<div class="govuk-radios" data-module="govuk-radios">
<div class="govuk-radios__item">
<input class="govuk-radios__input" id="remove-user" type="radio" asp-for="DeleteUser" value=true>
<input class="govuk-radios__input" id="remove-user" type="radio" asp-for="DeleteUser" value="true">
<label class="govuk-label govuk-radios__label" for="remove-user">
Yes, delete this user
</label>
</div>
<div class="govuk-radios__item">
<input class="govuk-radios__input" id="remove-user-2" type="radio" asp-for="DeleteUser" value=false>
<input class="govuk-radios__input" id="remove-user-2" type="radio" asp-for="DeleteUser" value="false">
<label class="govuk-label govuk-radios__label" for="remove-user-2">
No, keep this user
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ public class DeleteUserModel : PageModel

[BindProperty]
[Required]
public bool? DeleteUser { get; set; } = null;
public bool? DeleteUser { get; set; }

public string Error { get; set; } = string.Empty;

public DeleteUserModel(IIdamService idamService)
{
_idamService = idamService;
}

public async Task OnGet(long accountId)
{
AccountId = accountId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
using FamilyHubs.Idams.Maintenance.Core.Services;
using FamilyHubs.Idams.Maintenance.UnitTests.Support;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Xunit;

namespace FamilyHubs.Idams.Maintenance.UnitTests.UI;

[Collection("WebTests")]
public class DeleteUserWebTests : BaseWebTest
{
private readonly IIdamService _idamService = Substitute.For<IIdamService>();

protected override void Configure(IServiceCollection services)
{
services.AddSingleton(_idamService);
}

[Fact]
public async Task NavigateToRoot_Index_HasRemoveUserRadioButton()
{
var account1 = TestAccounts.GetAccount1();
_idamService.GetAccountById(account1.Id).Returns(account1);
var page = await Navigate($"/DeleteUser?accountId={account1.Id}");

var removeUserButton = page.QuerySelector("[id=\"remove-user\"]");
Expand All @@ -21,6 +32,7 @@ public async Task NavigateToRoot_Index_HasRemoveUserRadioButton()
public async Task NavigateToRoot_Index_HasDotNotRemoveUserRadioButton()
{
var account1 = TestAccounts.GetAccount1();
_idamService.GetAccountById(account1.Id).Returns(account1);
var page = await Navigate($"/DeleteUser?accountId={account1.Id}");

var dotNotRemoveUserButton = page.QuerySelector("[id=\"remove-user-2\"]");
Expand All @@ -31,9 +43,10 @@ public async Task NavigateToRoot_Index_HasDotNotRemoveUserRadioButton()
public async Task NavigateToRoot_Index_HasContinueRadioButton()
{
var account1 = TestAccounts.GetAccount1();
_idamService.GetAccountById(account1.Id).Returns(account1);
var page = await Navigate($"/DeleteUser?accountId={account1.Id}");

var dotNotRemoveUserButton = page.QuerySelector("[data-testid=\"continue-button\"]");
dotNotRemoveUserButton.Should().NotBeNull();
var continueButton = page.QuerySelector("[data-testid=\"continue-button\"]");
continueButton.Should().NotBeNull();
}
}

0 comments on commit 6dae1e0

Please sign in to comment.