Skip to content

Commit

Permalink
APR-2632 - Fix PRG pattern in WhosInControl (#931)
Browse files Browse the repository at this point in the history
* APR-2632-apply-WhosIncontrol-PGR-pattern

* APR-2632-PRG pattern don't require for this, comments removed

* APR-2632-added a test for redirect to ConfirmPeopleInControl

* APR-2630-SFA.DAS.Validation.Mvc to replace ModelState

* Revert "APR-2630-SFA.DAS.Validation.Mvc to replace ModelState"

This reverts commit ad1b215.
  • Loading branch information
raviudari01 authored Jan 17, 2022
1 parent b65e7d7 commit 1123abf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ public void Start_page_routes_to_confirm_directors_pscs_if_provider_verified_wit

var result = _controller.StartPage(Guid.NewGuid()).GetAwaiter().GetResult();

var viewResult = result as ViewResult;
viewResult.Should().NotBeNull();
viewResult.ViewName.Should().Contain("ConfirmDirectorsPscs");
result.Should().BeOfType<RedirectToActionResult>();
var redirectResult = result as RedirectToActionResult;
redirectResult.ActionName.Should().Be("ConfirmDirectorsPscs");
}

[Test]
Expand All @@ -183,9 +183,9 @@ public void Start_page_routes_to_confirm_directors_pscs_if_provider_verified_wit

var result = _controller.StartPage(Guid.NewGuid()).GetAwaiter().GetResult();

var viewResult = result as ViewResult;
viewResult.Should().NotBeNull();
viewResult.ViewName.Should().Contain("ConfirmDirectorsPscs");
result.Should().BeOfType<RedirectToActionResult>();
var redirectResult = result as RedirectToActionResult;
redirectResult.ActionName.Should().Be("ConfirmDirectorsPscs");
}

[Test]
Expand Down Expand Up @@ -241,9 +241,9 @@ public void Start_page_routes_to_confirm_trustees_if_provider_verified_with_char

var result = _controller.StartPage(Guid.NewGuid()).GetAwaiter().GetResult();

var viewResult = result as ViewResult;
viewResult.Should().NotBeNull();
viewResult.ViewName.Should().Contain("ConfirmTrustees");
result.Should().BeOfType<RedirectToActionResult>();
var redirectResult = result as RedirectToActionResult;
redirectResult.ActionName.Should().Be("ConfirmTrustees");
}

[Test]
Expand All @@ -263,7 +263,7 @@ public void Start_page_routes_to_confirm_trustees_if_provider_verified_with_char

var redirectResult = result as RedirectToActionResult;
redirectResult.Should().NotBeNull();
redirectResult.ActionName.Should().Be("AddPeopleInControl");
redirectResult.ActionName.Should().Be("ConfirmTrustees");
}


Expand All @@ -281,9 +281,29 @@ public void Start_page_routes_to_organisation_type_if_ukrlp_verification_source_

var result = _controller.StartPage(Guid.NewGuid()).GetAwaiter().GetResult();

var viewResult = result as ViewResult;
viewResult.Should().NotBeNull();
viewResult.ViewName.Should().Contain("SoleTraderOrPartnership");
result.Should().BeOfType<RedirectToActionResult>();
var redirectResult = result as RedirectToActionResult;
redirectResult.ActionName.Should().Be("SoleTraderOrPartnership");
}

[Test]
public void Start_page_routes_to_ConfirmPeopleInControl()
{
var _qnaApplicationData = new JObject
{
[RoatpWorkflowQuestionTags.UkrlpVerificationCompany] = "",
[RoatpWorkflowQuestionTags.UkrlpVerificationCharity] = "",
[RoatpWorkflowQuestionTags.UkrlpVerificationSoleTraderPartnership] = "FALSE",
[RoatpWorkflowQuestionTags.AddPeopleInControl] = "Test"
};

_qnaClient.Setup(x => x.GetApplicationData(It.IsAny<Guid>())).ReturnsAsync(_qnaApplicationData);

var result = _controller.StartPage(Guid.NewGuid()).GetAwaiter().GetResult();

result.Should().BeOfType<RedirectToActionResult>();
var redirectResult = result as RedirectToActionResult;
redirectResult.ActionName.Should().Be("ConfirmPeopleInControl");
}

[Test]
Expand All @@ -300,9 +320,9 @@ public void Start_page_routes_to_add_people_in_control_if_not_verified_with_comp

var result = _controller.StartPage(Guid.NewGuid()).GetAwaiter().GetResult();

var viewResult = result as ViewResult;
viewResult.Should().NotBeNull();
viewResult.ViewName.Should().Contain("AddPeopleInControl");
result.Should().BeOfType<RedirectToActionResult>();
var redirectResult = result as RedirectToActionResult;
redirectResult.ActionName.Should().Be("AddPeopleInControl");
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,30 @@ public async Task<IActionResult> StartPage(Guid applicationId)
if (verificationCompanyAnswer == "TRUE"
&& companiesHouseManualEntryAnswer != "TRUE")
{
return await ConfirmDirectorsPscs(applicationId, ukprn, companyNumber);
return RedirectToAction("ConfirmDirectorsPscs", new { applicationId, ukprn, companyNumber });
}

var verificationCharityAnswer = qnaApplicationData.GetValue(RoatpWorkflowQuestionTags.UkrlpVerificationCharity)?.Value<string>();
var charityCommissionManualEntryAnswer = qnaApplicationData.GetValue(RoatpWorkflowQuestionTags.ManualEntryRequiredCharityCommission)?.Value<string>();
if (verificationCharityAnswer == "TRUE"
&& charityCommissionManualEntryAnswer != "TRUE")
{
return await ConfirmTrustees(applicationId);
return RedirectToAction("ConfirmTrustees", new { applicationId });
}

var verificationPartnership = qnaApplicationData.GetValue(RoatpWorkflowQuestionTags.UkrlpVerificationSoleTraderPartnership)?.Value<string>();
if (verificationPartnership == "TRUE")
{
return await SoleTraderOrPartnership(applicationId);
return RedirectToAction("SoleTraderOrPartnership", new { applicationId });
}

var peopleData = qnaApplicationData.GetValue(RoatpWorkflowQuestionTags.AddPeopleInControl)?.Value<string>();
if (peopleData != null)
{
return await ConfirmPeopleInControl(applicationId);
return RedirectToAction("ConfirmPeopleInControl", new { applicationId });
}

return await AddPeopleInControl(applicationId);
return RedirectToAction("AddPeopleInControl", new { applicationId });
}

[HttpGet("refresh-directors-pscs")]
Expand Down Expand Up @@ -303,7 +303,6 @@ public async Task<IActionResult> TrusteesDobsConfirmed(ConfirmTrusteesDateOfBirt

if (model.ErrorMessages != null & model.ErrorMessages.Count > 0)
{
// TODO: Tech Debt - This should follow the PRG pattern
return View("~/Views/Roatp/WhosInControl/ConfirmTrusteesDob.cshtml", model);
}

Expand Down

0 comments on commit 1123abf

Please sign in to comment.