From 0d20d96c611a4ec04bf7eba00cfaaead94948eaf Mon Sep 17 00:00:00 2001 From: Andrew Horth Date: Wed, 3 Jan 2024 08:02:12 +0000 Subject: [PATCH] Aligned change request UI with updated Figma designs (#1039) --- .../Security/AuthorizationPolicies.cs | 2 +- .../Pages/Cases/EditCase/Accept.cshtml | 29 ---- .../Pages/Cases/EditCase/Accept.cshtml.cs | 83 ---------- .../Pages/Cases/EditCase/Index.cshtml | 153 ------------------ .../EditChangeRequest/Accept.cshtml | 69 ++++++++ .../EditChangeRequest/Accept.cshtml.cs | 105 ++++++++++++ .../DateOfBirthChangeRequestInfo.cs | 7 + .../EditChangeRequest/Index.cshtml | 133 +++++++++++++++ .../EditChangeRequest}/Index.cshtml.cs | 43 +---- .../NameChangeRequestInfo.cs | 11 ++ .../EditChangeRequest}/Reject.cshtml | 20 +-- .../EditChangeRequest}/Reject.cshtml.cs | 57 ++++--- .../{Cases => ChangeRequests}/Index.cshtml | 28 ++-- .../{Cases => ChangeRequests}/Index.cshtml.cs | 24 +-- .../Mqs/EditMq/Status/EditMqResultState.cs | 2 +- .../PersonDetail/EditName/Confirm.cshtml | 2 +- .../PersonDetail/EditName/Index.cshtml | 2 +- .../Pages/Shared/_Layout.cshtml | 6 +- .../TeachingRecordSystem.SupportUi/Program.cs | 2 +- .../TrsLinkGenerator.cs | 10 +- .../{CaseTests.cs => ChangeRequestTests.cs} | 50 +++--- .../PageExtensions.cs | 25 +-- .../EditChangeRequest}/AcceptTests.cs | 14 +- .../EditChangeRequest}/IndexTests.cs | 91 +++++++---- .../EditChangeRequest}/RejectTests.cs | 18 +-- .../{Cases => ChangeRequests}/IndexTests.cs | 24 +-- .../TestData.CreateNameChangeIncident.cs | 42 ++++- 27 files changed, 579 insertions(+), 473 deletions(-) delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Accept.cshtml delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Accept.cshtml.cs delete mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Index.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Accept.cshtml create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Accept.cshtml.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/DateOfBirthChangeRequestInfo.cs create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Index.cshtml rename TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/{Cases/EditCase => ChangeRequests/EditChangeRequest}/Index.cshtml.cs (72%) create mode 100644 TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/NameChangeRequestInfo.cs rename TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/{Cases/EditCase => ChangeRequests/EditChangeRequest}/Reject.cshtml (65%) rename TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/{Cases/EditCase => ChangeRequests/EditChangeRequest}/Reject.cshtml.cs (66%) rename TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/{Cases => ChangeRequests}/Index.cshtml (62%) rename TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/{Cases => ChangeRequests}/Index.cshtml.cs (81%) rename TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/{CaseTests.cs => ChangeRequestTests.cs} (67%) rename TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/{Cases/EditCase => ChangeRequests/EditChangeRequest}/AcceptTests.cs (89%) rename TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/{Cases/EditCase => ChangeRequests/EditChangeRequest}/IndexTests.cs (59%) rename TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/{Cases/EditCase => ChangeRequests/EditChangeRequest}/RejectTests.cs (91%) rename TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/{Cases => ChangeRequests}/IndexTests.cs (76%) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Infrastructure/Security/AuthorizationPolicies.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Infrastructure/Security/AuthorizationPolicies.cs index a5dafa539..fec540847 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Infrastructure/Security/AuthorizationPolicies.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Infrastructure/Security/AuthorizationPolicies.cs @@ -2,6 +2,6 @@ namespace TeachingRecordSystem.SupportUi.Infrastructure.Security; public static class AuthorizationPolicies { - public const string CaseManagement = "CaseManagement"; + public const string ChangeRequestManagement = "ChangeRequestManagement"; public const string Hangfire = "Hangfire"; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Accept.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Accept.cshtml deleted file mode 100644 index f2daeff5e..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Accept.cshtml +++ /dev/null @@ -1,29 +0,0 @@ -@page "/cases/{ticketNumber}/accept" -@model TeachingRecordSystem.SupportUi.Pages.Cases.EditCase.AcceptModel -@{ - ViewBag.Title = "Are you sure you want to accept this change?"; -} - -@section BeforeContent { - -} - -
-
-

@ViewBag.Title

-
- - - Current - @Model.CurrentValue - - - Change to - @Model.NewValue - - - - Confirm -
-
-
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Accept.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Accept.cshtml.cs deleted file mode 100644 index e605ef46a..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Accept.cshtml.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using TeachingRecordSystem.Core.Dqt.Models; -using TeachingRecordSystem.Core.Dqt.Queries; -using TeachingRecordSystem.SupportUi.Infrastructure.Security; - -namespace TeachingRecordSystem.SupportUi.Pages.Cases.EditCase; - -[Authorize(Policy = AuthorizationPolicies.CaseManagement)] -public class AcceptModel : PageModel -{ - private readonly TrsLinkGenerator _linkGenerator; - private readonly ICrmQueryDispatcher _crmQueryDispatcher; - - public AcceptModel( - TrsLinkGenerator linkGenerator, - ICrmQueryDispatcher crmQueryDispatcher) - { - _linkGenerator = linkGenerator; - _crmQueryDispatcher = crmQueryDispatcher; - } - - [FromRoute] - public string TicketNumber { get; set; } = null!; - - public string? CurrentValue { get; set; } - - public string? NewValue { get; set; } - - public async Task OnGet() - { - var incidentDetail = await GetIncidentDetail(); - if (incidentDetail is null) - { - return NotFound(); - } - - if (incidentDetail.Incident.StateCode != IncidentState.Active) - { - return BadRequest(); - } - - SetModelFromIncidentDetail(incidentDetail); - - return Page(); - } - - public async Task OnPost() - { - var incidentDetail = await GetIncidentDetail(); - - _ = await _crmQueryDispatcher.ExecuteQuery(new ApproveIncidentQuery(incidentDetail!.Incident.Id)); - - TempData.SetFlashSuccess( - $"The request has been accepted", - "The user’s record has been changed and they have been notified."); - - return Redirect(_linkGenerator.Cases()); - } - - private void SetModelFromIncidentDetail(IncidentDetail incidentDetail) - { - var incident = incidentDetail.Incident; - var customer = incidentDetail.Contact; - var subject = incidentDetail.Subject; - - if (subject.Title == DqtConstants.NameChangeSubjectTitle) - { - CurrentValue = string.IsNullOrEmpty(customer.MiddleName) ? $"{customer.FirstName} {customer.LastName}" : $"{customer.FirstName} {customer.MiddleName} {customer.LastName}"; - NewValue = string.IsNullOrEmpty(incident.dfeta_NewMiddleName) ? $"{incident.dfeta_NewFirstName} {incident.dfeta_NewLastName}" : $"{incident.dfeta_NewFirstName} {incident.dfeta_NewMiddleName} {incident.dfeta_NewLastName}"; - } - - if (subject.Title == DqtConstants.DateOfBirthChangeSubjectTitle) - { - CurrentValue = customer.BirthDate.ToDateOnlyWithDqtBstFix(isLocalTime: false)!.Value.ToString("dd/MM/yyyy"); - NewValue = incident.dfeta_NewDateofBirth.ToDateOnlyWithDqtBstFix(isLocalTime: true)!.Value.ToString("dd/MM/yyyy"); - } - } - - private Task GetIncidentDetail() => - _crmQueryDispatcher.ExecuteQuery(new GetIncidentByTicketNumberQuery(TicketNumber)); -} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Index.cshtml deleted file mode 100644 index 2e0081d81..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Index.cshtml +++ /dev/null @@ -1,153 +0,0 @@ -@page "/cases/{ticketNumber}/{handler?}/{id?}" -@model TeachingRecordSystem.SupportUi.Pages.Cases.EditCase.IndexModel -@{ - ViewBag.Title = Model.CaseHeader!.CaseType; -} - -@section BeforeContent { - -} - -
-
- - - - - - - - - - - - - - - - -
@ViewBag.Title
Case referenceNameCreated on
@Model.CaseHeader.CaseReference@Model.CaseHeader.Customer@Model.CaseHeader.CreatedOn.ToString("dd/MM/yyyy")
-
-
- -
- -
-
- - - @if (Model.CaseHeader.CaseType == DqtConstants.NameChangeSubjectTitle) - { - - - - - - - - - - - - - - - - - - - - - - - - - } - @if (Model.CaseHeader.CaseType == DqtConstants.DateOfBirthChangeSubjectTitle) - { - - - - - - - - - - - - - } -
Request
NameCurrentRequest
First@Model.NameChangeRequest!.CurrentFirstName@Model.NameChangeRequest!.NewFirstName
Middle@Model.NameChangeRequest!.CurrentMiddleName@Model.NameChangeRequest!.NewMiddleName
Last@Model.NameChangeRequest!.CurrentLastName@Model.NameChangeRequest!.NewLastName
CurrentRequest
@Model.DateOfBirthChangeRequest!.CurrentDateOfBirth.ToString("dd/MM/yyyy")@Model.DateOfBirthChangeRequest!.NewDateOfBirth.ToString("dd/MM/yyyy")
-
-
- -
-
-

Proof

-
-
- @foreach (var evidence in Model.Evidence!) - { -
-
- @if (evidence.MimeType == "application/pdf") - { - - - } - else - { - evidence.FileName - } - View larger (opens in new tab) -
-
- } -
-
-

Documents we accept

-
    - @if (Model.CaseHeader.CaseType == DqtConstants.NameChangeSubjectTitle) - { -
  • -

    Marriage

    - Marriage certificate -
  • -
  • -

    Civil Partnership

    - Civil agreement certificate -
  • -
  • -

    Divorce

    - Decree absolute and birth certificate -
  • -
  • -

    Statutory declaration

    - Statutory declaration -
  • -
  • -

    Deed poll

    - Deed poll -
  • -
  • -

    Fix a typo

    - Passport -
  • - } - @if (Model.CaseHeader.CaseType == DqtConstants.DateOfBirthChangeSubjectTitle) - { -
  • Birth certificate
  • -
  • Passport
  • -
  • Driving license
  • - } -
-
-
-
-
- -
- Accept change - Reject change -
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Accept.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Accept.cshtml new file mode 100644 index 000000000..d17ba27c4 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Accept.cshtml @@ -0,0 +1,69 @@ +@page "/change-requests/{ticketNumber}/accept" +@model TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest.AcceptModel +@{ + ViewBag.Title = "Confirm the change"; +} + +@section BeforeContent { + +} + +@Model.CaseType - @Model.PersonName +

@ViewBag.Title

+ +
+
+
+ + + + + + + + + @if (Model.CaseType == DqtConstants.NameChangeSubjectTitle) + { + + @if (Model.NameChangeRequest!.CurrentFirstName != Model.NameChangeRequest!.NewFirstName) + { + + + + + + } + @if (Model.NameChangeRequest!.CurrentMiddleName != Model.NameChangeRequest!.NewMiddleName) + { + + + + + + } + @if (Model.NameChangeRequest!.CurrentLastName != Model.NameChangeRequest!.NewLastName) + { + + + + + + } + + } + @if (Model.CaseType == DqtConstants.DateOfBirthChangeSubjectTitle) + { + + + + + + + + } +
CurrentNew
First name@Model.NameChangeRequest!.CurrentFirstName@Model.NameChangeRequest!.NewFirstName
Middle name@Model.NameChangeRequest!.CurrentMiddleName@Model.NameChangeRequest!.NewMiddleName
Last name@Model.NameChangeRequest!.CurrentLastName@Model.NameChangeRequest!.NewLastName
Date of birth@Model.DateOfBirthChangeRequest!.CurrentDateOfBirth.ToString("d MMMM yyyy")@Model.DateOfBirthChangeRequest!.NewDateOfBirth.ToString("d MMMM yyyy")
+ + Confirm +
+
+
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Accept.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Accept.cshtml.cs new file mode 100644 index 000000000..ef1589055 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Accept.cshtml.cs @@ -0,0 +1,105 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.RazorPages; +using TeachingRecordSystem.Core.Dqt.Models; +using TeachingRecordSystem.Core.Dqt.Queries; +using TeachingRecordSystem.SupportUi.Infrastructure.Security; + +namespace TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest; + +[Authorize(Policy = AuthorizationPolicies.ChangeRequestManagement)] +public class AcceptModel : PageModel +{ + private readonly TrsLinkGenerator _linkGenerator; + private readonly ICrmQueryDispatcher _crmQueryDispatcher; + + public AcceptModel( + TrsLinkGenerator linkGenerator, + ICrmQueryDispatcher crmQueryDispatcher) + { + _linkGenerator = linkGenerator; + _crmQueryDispatcher = crmQueryDispatcher; + } + + [FromRoute] + public string TicketNumber { get; set; } = null!; + + public string? CaseType { get; set; } + + public string? PersonName { get; set; } + + IncidentDetail? IncidentDetail { get; set; } + + public NameChangeRequestInfo? NameChangeRequest { get; set; } + + public DateOfBirthChangeRequestInfo? DateOfBirthChangeRequest { get; set; } + + public IActionResult OnGet() + { + SetModelFromIncidentDetail(); + + return Page(); + } + + public async Task OnPost() + { + _ = await _crmQueryDispatcher.ExecuteQuery(new ApproveIncidentQuery(IncidentDetail!.Incident.Id)); + + TempData.SetFlashSuccess( + $"The request has been accepted", + "The user’s record has been changed and they have been notified."); + + return Redirect(_linkGenerator.ChangeRequests()); + } + + public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) + { + IncidentDetail = await _crmQueryDispatcher.ExecuteQuery(new GetIncidentByTicketNumberQuery(TicketNumber)); + if (IncidentDetail is null) + { + context.Result = NotFound(); + return; + } + + if (IncidentDetail.Incident.StateCode != IncidentState.Active) + { + context.Result = BadRequest(); + return; + } + + await next(); + } + + private void SetModelFromIncidentDetail() + { + var incident = IncidentDetail!.Incident; + var customer = IncidentDetail.Contact; + var subject = IncidentDetail.Subject; + + CaseType = subject.Title; + PersonName = customer.ResolveFullName(includeMiddleName: false); + + if (subject.Title == DqtConstants.NameChangeSubjectTitle) + { + NameChangeRequest = new NameChangeRequestInfo() + { + CurrentFirstName = customer.FirstName, + CurrentMiddleName = customer.MiddleName, + CurrentLastName = customer.LastName, + NewFirstName = incident.dfeta_NewFirstName, + NewMiddleName = incident.dfeta_NewMiddleName, + NewLastName = incident.dfeta_NewLastName + }; + } + + if (subject.Title == DqtConstants.DateOfBirthChangeSubjectTitle) + { + DateOfBirthChangeRequest = new DateOfBirthChangeRequestInfo() + { + CurrentDateOfBirth = customer.BirthDate.ToDateOnlyWithDqtBstFix(isLocalTime: false)!.Value, + NewDateOfBirth = incident.dfeta_NewDateofBirth.ToDateOnlyWithDqtBstFix(isLocalTime: true)!.Value + }; + } + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/DateOfBirthChangeRequestInfo.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/DateOfBirthChangeRequestInfo.cs new file mode 100644 index 000000000..681bc79e1 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/DateOfBirthChangeRequestInfo.cs @@ -0,0 +1,7 @@ +namespace TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest; + +public record DateOfBirthChangeRequestInfo +{ + public required DateOnly CurrentDateOfBirth { get; init; } + public required DateOnly NewDateOfBirth { get; init; } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Index.cshtml new file mode 100644 index 000000000..000acd3f5 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Index.cshtml @@ -0,0 +1,133 @@ +@page "/change-requests/{ticketNumber}/{handler?}/{id?}" +@model TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest.IndexModel +@{ + ViewBag.Title = "Request"; +} + +@section BeforeContent { + +} + +@Model.ChangeType - @Model.PersonName +

@ViewBag.Title

+ +
+
+ + + + + + + + + @if (Model.ChangeType == DqtConstants.NameChangeSubjectTitle) + { + + @if (Model.NameChangeRequest!.CurrentFirstName != Model.NameChangeRequest!.NewFirstName) + { + + + + + + } + @if (Model.NameChangeRequest!.CurrentMiddleName != Model.NameChangeRequest!.NewMiddleName) + { + + + + + + } + @if (Model.NameChangeRequest!.CurrentLastName != Model.NameChangeRequest!.NewLastName) + { + + + + + + } + + } + @if (Model.ChangeType == DqtConstants.DateOfBirthChangeSubjectTitle) + { + + + + + + + + } +
CurrentNew
First name@Model.NameChangeRequest!.CurrentFirstName@Model.NameChangeRequest!.NewFirstName
Middle name@Model.NameChangeRequest!.CurrentMiddleName@Model.NameChangeRequest!.NewMiddleName
Last name@Model.NameChangeRequest!.CurrentLastName@Model.NameChangeRequest!.NewLastName
Date of birth@Model.DateOfBirthChangeRequest!.CurrentDateOfBirth.ToString("d MMMM yyyy")@Model.DateOfBirthChangeRequest!.NewDateOfBirth.ToString("d MMMM yyyy")
+
+
+ +
+
+

Proof

+ + Documents we accept + +
    + @if (Model.ChangeType == DqtConstants.NameChangeSubjectTitle) + { +
  • +

    Marriage

    + Marriage certificate +
  • +
  • +

    Civil Partnership

    + Civil agreement certificate +
  • +
  • +

    Divorce

    + Decree absolute and birth certificate +
  • +
  • +

    Statutory declaration

    + Statutory declaration +
  • +
  • +

    Deed poll

    + Deed poll +
  • +
  • +

    Fix a typo

    + Passport +
  • + } + @if (Model.ChangeType == DqtConstants.DateOfBirthChangeSubjectTitle) + { +
  • Birth certificate
  • +
  • Passport
  • +
  • Driving license
  • + } +
+
+
+ @foreach (var evidence in Model.Evidence!) + { +
+
+ @if (evidence.MimeType == "application/pdf") + { + + + } + else + { + evidence.FileName + } + View larger (opens in new tab) +
+
+ } +
+
+ +
+ Accept change + Reject change +
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Index.cshtml.cs similarity index 72% rename from TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Index.cshtml.cs rename to TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Index.cshtml.cs index 175700619..06604d5ee 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Index.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Index.cshtml.cs @@ -5,10 +5,10 @@ using TeachingRecordSystem.Core.Dqt.Queries; using TeachingRecordSystem.SupportUi.Infrastructure.Security; -namespace TeachingRecordSystem.SupportUi.Pages.Cases.EditCase; +namespace TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest; -[Authorize(Policy = AuthorizationPolicies.CaseManagement)] -public class IndexModel : PageModel +[Authorize(Policy = AuthorizationPolicies.ChangeRequestManagement)] +public partial class IndexModel : PageModel { private readonly ICrmQueryDispatcher _crmQueryDispatcher; @@ -17,7 +17,9 @@ public IndexModel(ICrmQueryDispatcher crmQueryDispatcher) _crmQueryDispatcher = crmQueryDispatcher; } - public CaseInfo? CaseHeader { get; set; } + public string? ChangeType { get; set; } + + public string? PersonName { get; set; } public NameChangeRequestInfo? NameChangeRequest { get; set; } @@ -71,13 +73,8 @@ private void SetModelFromIncidentDetail(IncidentDetail incidentDetail) var subject = incidentDetail.Subject; var incidentDocuments = incidentDetail.IncidentDocuments; - CaseHeader = new CaseInfo() - { - CaseReference = incidentDetail.Incident.TicketNumber, - Customer = customer.dfeta_StatedFirstName is not null ? $"{customer.dfeta_StatedFirstName} {customer.dfeta_StatedLastName}" : $"{customer.FirstName} {customer.LastName}", - CaseType = subject.Title, - CreatedOn = incident.CreatedOn!.Value - }; + ChangeType = subject.Title; + PersonName = customer.ResolveFullName(includeMiddleName: false); if (subject.Title == DqtConstants.NameChangeSubjectTitle) { @@ -118,30 +115,6 @@ private void SetModelFromIncidentDetail(IncidentDetail incidentDetail) } } - public record CaseInfo - { - public required string CaseReference { get; init; } - public required string Customer { get; init; } - public required string CaseType { get; init; } - public required DateTime CreatedOn { get; init; } - } - - public record NameChangeRequestInfo - { - public required string CurrentFirstName { get; init; } - public required string? CurrentMiddleName { get; init; } - public required string CurrentLastName { get; init; } - public required string NewFirstName { get; init; } - public required string? NewMiddleName { get; init; } - public required string NewLastName { get; init; } - } - - public record DateOfBirthChangeRequestInfo - { - public required DateOnly CurrentDateOfBirth { get; init; } - public required DateOnly NewDateOfBirth { get; init; } - } - public record EvidenceInfo { public required Guid DocumentId { get; init; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/NameChangeRequestInfo.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/NameChangeRequestInfo.cs new file mode 100644 index 000000000..bb2e86613 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/NameChangeRequestInfo.cs @@ -0,0 +1,11 @@ +namespace TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest; + +public record NameChangeRequestInfo +{ + public required string CurrentFirstName { get; init; } + public required string? CurrentMiddleName { get; init; } + public required string CurrentLastName { get; init; } + public required string NewFirstName { get; init; } + public required string? NewMiddleName { get; init; } + public required string NewLastName { get; init; } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Reject.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Reject.cshtml similarity index 65% rename from TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Reject.cshtml rename to TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Reject.cshtml index ef3f086d0..63aa6ac22 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Reject.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Reject.cshtml @@ -1,18 +1,20 @@ -@page "/cases/{ticketNumber}/reject" -@using static TeachingRecordSystem.SupportUi.Pages.Cases.EditCase.RejectModel; -@model TeachingRecordSystem.SupportUi.Pages.Cases.EditCase.RejectModel +@page "/change-requests/{ticketNumber}/reject" +@using static TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest.RejectModel; +@model TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest.RejectModel @{ - ViewBag.Title = "Are you sure you want to reject this change?"; + ViewBag.Title = "Reject the change"; } @section BeforeContent { - + } +@Model.ChangeType - @Model.PersonName +

@ViewBag.Title

+
-
-

@ViewBag.Title

-
+
+ @@ -33,7 +35,7 @@ - Confirm + Reject
diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Reject.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Reject.cshtml.cs similarity index 66% rename from TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Reject.cshtml.cs rename to TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Reject.cshtml.cs index 6f1bc66ed..fef6becb7 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/EditCase/Reject.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/EditChangeRequest/Reject.cshtml.cs @@ -1,14 +1,15 @@ using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.RazorPages; using TeachingRecordSystem.Core.Dqt.Models; using TeachingRecordSystem.Core.Dqt.Queries; using TeachingRecordSystem.SupportUi.Infrastructure.Security; -namespace TeachingRecordSystem.SupportUi.Pages.Cases.EditCase; +namespace TeachingRecordSystem.SupportUi.Pages.ChangeRequests.EditChangeRequest; -[Authorize(Policy = AuthorizationPolicies.CaseManagement)] +[Authorize(Policy = AuthorizationPolicies.ChangeRequestManagement)] public class RejectModel : PageModel { private readonly TrsLinkGenerator _linkGenerator; @@ -25,27 +26,17 @@ public RejectModel( [FromRoute] public string TicketNumber { get; set; } = null!; + public string? ChangeType { get; set; } + + public string? PersonName { get; set; } + + IncidentDetail? IncidentDetail { get; set; } + [BindProperty] [Display(Name = " ")] [Required(ErrorMessage = "Select the reason for rejecting this change")] public CaseRejectionReasonOption? RejectionReasonChoice { get; set; } - public async Task OnGet() - { - var incidentDetail = await GetIncidentDetail(); - if (incidentDetail is null) - { - return NotFound(); - } - - if (incidentDetail.Incident.StateCode != IncidentState.Active) - { - return BadRequest(); - } - - return Page(); - } - public async Task OnPost() { if (!ModelState.IsValid) @@ -53,8 +44,6 @@ public async Task OnPost() return this.PageWithErrors(); } - var incidentDetail = await GetIncidentDetail(); - var requestStatus = "rejected"; var flashMessage = "The user’s record has not been changed and they have been notified."; if (RejectionReasonChoice!.Value == CaseRejectionReasonOption.ChangeNoLongerRequired) @@ -62,22 +51,40 @@ public async Task OnPost() requestStatus = "cancelled"; flashMessage = "The user’s record has not been changed and they have not been notified."; - _ = await _crmQueryDispatcher.ExecuteQuery(new CancelIncidentQuery(incidentDetail!.Incident.Id)); + _ = await _crmQueryDispatcher.ExecuteQuery(new CancelIncidentQuery(IncidentDetail!.Incident.Id)); } else { - _ = await _crmQueryDispatcher.ExecuteQuery(new RejectIncidentQuery(incidentDetail!.Incident.Id, RejectionReasonChoice.Value.GetDisplayName()!)); + _ = await _crmQueryDispatcher.ExecuteQuery(new RejectIncidentQuery(IncidentDetail!.Incident.Id, RejectionReasonChoice.Value.GetDisplayName()!)); } TempData.SetFlashSuccess( $"The request has been {requestStatus}", flashMessage); - return Redirect(_linkGenerator.Cases()); + return Redirect(_linkGenerator.ChangeRequests()); } - private Task GetIncidentDetail() => - _crmQueryDispatcher.ExecuteQuery(new GetIncidentByTicketNumberQuery(TicketNumber)); + public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next) + { + IncidentDetail = await _crmQueryDispatcher.ExecuteQuery(new GetIncidentByTicketNumberQuery(TicketNumber)); + if (IncidentDetail is null) + { + context.Result = NotFound(); + return; + } + + if (IncidentDetail.Incident.StateCode != IncidentState.Active) + { + context.Result = BadRequest(); + return; + } + + ChangeType = IncidentDetail.Subject.Title; + PersonName = IncidentDetail.Contact.ResolveFullName(includeMiddleName: false); + + await next(); + } public enum CaseRejectionReasonOption { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/Index.cshtml similarity index 62% rename from TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/Index.cshtml rename to TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/Index.cshtml index 59b8c8aa7..027c6469f 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/Index.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/Index.cshtml @@ -1,35 +1,35 @@ -@page "/cases" -@model TeachingRecordSystem.SupportUi.Pages.Cases.IndexModel +@page "/change-requests" +@model TeachingRecordSystem.SupportUi.Pages.ChangeRequests.IndexModel @{ - ViewBag.Title = "Open Cases"; + ViewBag.Title = "Change requests"; } - + - + - @if (Model.Cases!.Length == 0) + @if (Model.ChangeRequests!.Length == 0) { - - + + } else { - @foreach (var caseInfo in Model.Cases!) + @foreach (var changeRequestInfo in Model.ChangeRequests!) { - - - - - + + + + + } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/Index.cshtml.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/Index.cshtml.cs similarity index 81% rename from TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/Index.cshtml.cs rename to TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/Index.cshtml.cs index c89214cfb..da4be6624 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Cases/Index.cshtml.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/ChangeRequests/Index.cshtml.cs @@ -5,9 +5,9 @@ using TeachingRecordSystem.Core.Dqt.Queries; using TeachingRecordSystem.SupportUi.Infrastructure.Security; -namespace TeachingRecordSystem.SupportUi.Pages.Cases; +namespace TeachingRecordSystem.SupportUi.Pages.ChangeRequests; -[Authorize(Policy = AuthorizationPolicies.CaseManagement)] +[Authorize(Policy = AuthorizationPolicies.ChangeRequestManagement)] public class IndexModel : PageModel { private const int PageSize = 15; @@ -23,7 +23,7 @@ public IndexModel( _crmQueryDispatcher = crmQueryDispatcher; } - public CaseInfo[]? Cases { get; set; } + public ChangeRequestInfo[]? ChangeRequests { get; set; } [BindProperty(SupportsGet = true)] public int? PageNumber { get; set; } @@ -53,7 +53,7 @@ public async Task OnGet() if (PageNumber > TotalKnownPages) { // Redirect to first page - return Redirect(_linkGenerator.Cases()); + return Redirect(_linkGenerator.ChangeRequests()); } if (incidentsResult.TotalRecordCount < MaxCrmResultCount) @@ -72,7 +72,7 @@ public async Task OnGet() PreviousPage = PageNumber > 1 ? PageNumber - 1 : null; NextPage = PageNumber < TotalKnownPages ? PageNumber + 1 : null; - Cases = incidentsResult.Incidents + ChangeRequests = incidentsResult.Incidents .Select(MapIncident) .OrderBy(c => c.CreatedOn) .ToArray(); @@ -80,25 +80,25 @@ public async Task OnGet() return Page(); } - private CaseInfo MapIncident(Incident incident) + private ChangeRequestInfo MapIncident(Incident incident) { var customer = incident.Extract("contact", Contact.PrimaryIdAttribute); var subject = incident.Extract("subject", Subject.PrimaryIdAttribute); - return new CaseInfo() + return new ChangeRequestInfo() { - CaseReference = incident.TicketNumber, + RequestReference = incident.TicketNumber, Customer = customer.dfeta_StatedFirstName is not null ? $"{customer.dfeta_StatedFirstName} {customer.dfeta_StatedLastName}" : $"{customer.FirstName} {customer.LastName}", - CaseType = subject.Title, + ChangeType = subject.Title, CreatedOn = incident.CreatedOn!.Value }; } - public record CaseInfo + public record ChangeRequestInfo { - public required string CaseReference { get; init; } + public required string RequestReference { get; init; } public required string Customer { get; init; } - public required string CaseType { get; init; } + public required string ChangeType { get; init; } public required DateTime CreatedOn { get; init; } } } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Mqs/EditMq/Status/EditMqResultState.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Mqs/EditMq/Status/EditMqResultState.cs index 543fed42c..cbbd4a131 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Mqs/EditMq/Status/EditMqResultState.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Mqs/EditMq/Status/EditMqResultState.cs @@ -22,7 +22,7 @@ public class EditMqResultState [JsonIgnore] public bool IsComplete => Status.HasValue && - (Status != MandatoryQualificationStatus.Passed || (Status == MandatoryQualificationStatus.Passed && EndDate.HasValue)); + (Status != MandatoryQualificationStatus.Passed || Status == MandatoryQualificationStatus.Passed && EndDate.HasValue); public async Task EnsureInitialized( ICrmQueryDispatcher crmQueryDispatcher, diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditName/Confirm.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditName/Confirm.cshtml index 73e169cc2..1f02d221f 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditName/Confirm.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditName/Confirm.cshtml @@ -1,7 +1,7 @@ @page "/persons/{personId}/edit-name/confirm" @model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditName.ConfirmModel @{ - ViewBag.Title = "Confirm name changes"; + ViewBag.Title = "Confirm name change"; } @section BeforeContent { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditName/Index.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditName/Index.cshtml index 04f3645e1..4f3132c60 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditName/Index.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Persons/PersonDetail/EditName/Index.cshtml @@ -1,7 +1,7 @@ @page "/persons/{personId}/edit-name" @model TeachingRecordSystem.SupportUi.Pages.Persons.PersonDetail.EditName.IndexModel @{ - ViewBag.Title = "Edit name"; + ViewBag.Title = "Change name"; } @section BeforeContent { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Shared/_Layout.cshtml b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Shared/_Layout.cshtml index 0162c2928..0ef8ff6e9 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Shared/_Layout.cshtml +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/Shared/_Layout.cshtml @@ -43,10 +43,10 @@ { if (User.IsActiveTrsUser()) { - if ((await AuthorizationService.AuthorizeAsync(User, AuthorizationPolicies.CaseManagement)).Succeeded) + if ((await AuthorizationService.AuthorizeAsync(User, AuthorizationPolicies.ChangeRequestManagement)).Succeeded) { -
  • - Open cases +
  • + Change requests
  • } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Program.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Program.cs index e7bdc411b..45bfa4e5e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Program.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Program.cs @@ -70,7 +70,7 @@ builder.Services.AddAuthorizationBuilder() .AddPolicy( - AuthorizationPolicies.CaseManagement, + AuthorizationPolicies.ChangeRequestManagement, policy => policy .RequireAuthenticatedUser() .RequireRole(UserRoles.Helpdesk, UserRoles.Administrator)) diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs index 30376e1a0..e4c8e7e2f 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TrsLinkGenerator.cs @@ -28,15 +28,15 @@ public string AlertClose(Guid alertId, JourneyInstanceId? journeyInstanceId) => public string AlertCloseConfirm(Guid alertId, JourneyInstanceId journeyInstanceId) => GetRequiredPathByPage("/Alerts/CloseAlert/Confirm", routeValues: new { alertId }, journeyInstanceId: journeyInstanceId); - public string Cases() => GetRequiredPathByPage("/Cases/Index"); + public string ChangeRequests() => GetRequiredPathByPage("/ChangeRequests/Index"); - public string EditCase(string ticketNumber) => GetRequiredPathByPage("/Cases/EditCase/Index", routeValues: new { ticketNumber }); + public string EditChangeRequest(string ticketNumber) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Index", routeValues: new { ticketNumber }); - public string CaseDocument(string ticketNumber, Guid documentId) => GetRequiredPathByPage("/Cases/EditCase/Index", "documents", routeValues: new { ticketNumber, id = documentId }); + public string ChangeRequestDocument(string ticketNumber, Guid documentId) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Index", "documents", routeValues: new { ticketNumber, id = documentId }); - public string AcceptCase(string ticketNumber) => GetRequiredPathByPage("/Cases/EditCase/Accept", routeValues: new { ticketNumber }); + public string AcceptChangeRequest(string ticketNumber) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Accept", routeValues: new { ticketNumber }); - public string RejectCase(string ticketNumber) => GetRequiredPathByPage("/Cases/EditCase/Reject", routeValues: new { ticketNumber }); + public string RejectChangeRequest(string ticketNumber) => GetRequiredPathByPage("/ChangeRequests/EditChangeRequest/Reject", routeValues: new { ticketNumber }); public string MqAdd(Guid personId) => GetRequiredPathByPage("/Mqs/AddMq/Index", routeValues: new { personId }); diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/CaseTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/ChangeRequestTests.cs similarity index 67% rename from TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/CaseTests.cs rename to TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/ChangeRequestTests.cs index f4221baaf..5ddbb11c8 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/CaseTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/ChangeRequestTests.cs @@ -2,9 +2,9 @@ namespace TeachingRecordSystem.SupportUi.EndToEndTests; -public class CaseTests : TestBase +public class ChangeRequestTests : TestBase { - public CaseTests(HostFixture hostFixture) + public ChangeRequestTests(HostFixture hostFixture) : base(hostFixture) { } @@ -12,7 +12,7 @@ public CaseTests(HostFixture hostFixture) [Theory] [InlineData(true)] [InlineData(false)] - public async Task SelectCaseAndApprove(bool isNameChange) + public async Task SelectChangeRequestAndApprove(bool isNameChange) { var createPersonResult = await TestData.CreatePerson(); string caseReference; @@ -32,21 +32,21 @@ public async Task SelectCaseAndApprove(bool isNameChange) await page.GoToHomePage(); - await page.ClickOpenCasesLinkInNavigationBar(); + await page.ClickChangeRequestsLinkInNavigationBar(); - await page.AssertOnOpenCasesPage(); + await page.AssertOnChangeRequestsPage(); - await page.ClickCaseReferenceLinkOpenCasesPage(caseReference); + await page.ClickCaseReferenceLinkChangeRequestsPage(caseReference); - await page.AssertOnCaseDetailPage(caseReference); + await page.AssertOnChangeRequestDetailPage(caseReference); await page.ClickAcceptChangeButton(); - await page.AssertOnAcceptCasePage(caseReference); + await page.AssertOnAcceptChangeRequestPage(caseReference); await page.ClickConfirmButton(); - await page.AssertOnOpenCasesPage(); + await page.AssertOnChangeRequestsPage(); await page.AssertFlashMessage("The request has been accepted"); } @@ -54,7 +54,7 @@ public async Task SelectCaseAndApprove(bool isNameChange) [Theory] [InlineData(true)] [InlineData(false)] - public async Task SelectCaseAndReject(bool isNameChange) + public async Task SelectChangeRequestAndReject(bool isNameChange) { var createPersonResult = await TestData.CreatePerson(); string caseReference; @@ -74,23 +74,23 @@ public async Task SelectCaseAndReject(bool isNameChange) await page.GoToHomePage(); - await page.ClickOpenCasesLinkInNavigationBar(); + await page.ClickChangeRequestsLinkInNavigationBar(); - await page.AssertOnOpenCasesPage(); + await page.AssertOnChangeRequestsPage(); - await page.ClickCaseReferenceLinkOpenCasesPage(caseReference); + await page.ClickCaseReferenceLinkChangeRequestsPage(caseReference); - await page.AssertOnCaseDetailPage(caseReference); + await page.AssertOnChangeRequestDetailPage(caseReference); await page.ClickRejectChangeButton(); - await page.AssertOnRejectCasePage(caseReference); + await page.AssertOnRejectChangeRequestPage(caseReference); await page.CheckAsync("label:text-is('Request and proof don’t match')"); - await page.ClickConfirmButton(); + await page.ClickRejectButton(); - await page.AssertOnOpenCasesPage(); + await page.AssertOnChangeRequestsPage(); await page.AssertFlashMessage("The request has been rejected"); } @@ -98,7 +98,7 @@ public async Task SelectCaseAndReject(bool isNameChange) [Theory] [InlineData(true)] [InlineData(false)] - public async Task SelectCaseAndCancel(bool isNameChange) + public async Task SelectChangeRequestAndCancel(bool isNameChange) { var createPersonResult = await TestData.CreatePerson(); string caseReference; @@ -118,23 +118,23 @@ public async Task SelectCaseAndCancel(bool isNameChange) await page.GoToHomePage(); - await page.ClickOpenCasesLinkInNavigationBar(); + await page.ClickChangeRequestsLinkInNavigationBar(); - await page.AssertOnOpenCasesPage(); + await page.AssertOnChangeRequestsPage(); - await page.ClickCaseReferenceLinkOpenCasesPage(caseReference); + await page.ClickCaseReferenceLinkChangeRequestsPage(caseReference); - await page.AssertOnCaseDetailPage(caseReference); + await page.AssertOnChangeRequestDetailPage(caseReference); await page.ClickRejectChangeButton(); - await page.AssertOnRejectCasePage(caseReference); + await page.AssertOnRejectChangeRequestPage(caseReference); await page.CheckAsync("label:text-is('Change no longer required')"); - await page.ClickConfirmButton(); + await page.ClickRejectButton(); - await page.AssertOnOpenCasesPage(); + await page.AssertOnChangeRequestsPage(); await page.AssertFlashMessage("The request has been cancelled"); } diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/PageExtensions.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/PageExtensions.cs index 5e8d5187c..2813afc92 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/PageExtensions.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/PageExtensions.cs @@ -54,34 +54,34 @@ public static async Task ClickViewAlertPersonAlertsPage(this IPage page, Guid al await page.GetByTestId($"view-alert-link-{alertId}").ClickAsync(); } - public static async Task ClickOpenCasesLinkInNavigationBar(this IPage page) + public static async Task ClickChangeRequestsLinkInNavigationBar(this IPage page) { - await page.ClickAsync("a:text-is('Open cases')"); + await page.ClickAsync("a:text-is('Change requests')"); } - public static async Task AssertOnOpenCasesPage(this IPage page) + public static async Task AssertOnChangeRequestsPage(this IPage page) { - await page.WaitForUrlPathAsync("/cases"); + await page.WaitForUrlPathAsync("/change-requests"); } - public static async Task ClickCaseReferenceLinkOpenCasesPage(this IPage page, string caseReference) + public static async Task ClickCaseReferenceLinkChangeRequestsPage(this IPage page, string caseReference) { await page.ClickAsync($"a:text-is('{caseReference}')"); } - public static async Task AssertOnCaseDetailPage(this IPage page, string caseReference) + public static async Task AssertOnChangeRequestDetailPage(this IPage page, string caseReference) { - await page.WaitForUrlPathAsync($"/cases/{caseReference}"); + await page.WaitForUrlPathAsync($"/change-requests/{caseReference}"); } - public static async Task AssertOnAcceptCasePage(this IPage page, string caseReference) + public static async Task AssertOnAcceptChangeRequestPage(this IPage page, string caseReference) { - await page.WaitForUrlPathAsync($"/cases/{caseReference}/accept"); + await page.WaitForUrlPathAsync($"/change-requests/{caseReference}/accept"); } - public static async Task AssertOnRejectCasePage(this IPage page, string caseReference) + public static async Task AssertOnRejectChangeRequestPage(this IPage page, string caseReference) { - await page.WaitForUrlPathAsync($"/cases/{caseReference}/reject"); + await page.WaitForUrlPathAsync($"/change-requests/{caseReference}/reject"); } public static async Task AssertOnPersonDetailPage(this IPage page, Guid personId) @@ -264,6 +264,9 @@ public static Task ClickConfirmChangeButton(this IPage page) public static Task ClickConfirmButton(this IPage page) => ClickButton(page, "Confirm"); + public static Task ClickRejectButton(this IPage page) + => ClickButton(page, "Reject"); + public static Task ClickContinueButton(this IPage page) => ClickButton(page, "Continue"); diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/AcceptTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/AcceptTests.cs similarity index 89% rename from TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/AcceptTests.cs rename to TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/AcceptTests.cs index 3aae9a423..d49539695 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/AcceptTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/AcceptTests.cs @@ -1,4 +1,4 @@ -namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Cases.EditCase; +namespace TeachingRecordSystem.SupportUi.Tests.PageTests.ChangeRequests.EditChangeRequest; public class AcceptTests : TestBase { @@ -15,7 +15,7 @@ public async Task Get_WhenUserHasNoRoles_ReturnsForbidden() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}/accept"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}/accept"); // Act var response = await HttpClient.SendAsync(request); @@ -32,7 +32,7 @@ public async Task Get_WhenUserDoesNotHaveHelpdeskOrAdministratorRole_ReturnsForb var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}/accept"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}/accept"); // Act var response = await HttpClient.SendAsync(request); @@ -48,7 +48,7 @@ public async Task Get_WithTicketNumberForNonExistentIncident_ReturnsNotFound() SetCurrentUser(TestUsers.Helpdesk); var nonExistentTicketNumber = Guid.NewGuid().ToString(); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{nonExistentTicketNumber}/accept"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{nonExistentTicketNumber}/accept"); // Act var response = await HttpClient.SendAsync(request); @@ -65,7 +65,7 @@ public async Task Get_WithTicketNumberForInactiveIncident_ReturnsBadRequest() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId).WithCanceledStatus()); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}/accept"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}/accept"); // Act var response = await HttpClient.SendAsync(request); @@ -82,7 +82,7 @@ public async Task Post_WhenUserDoesNotHaveHelpdeskOrAdministratorRole_ReturnsFor var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Post, $"/cases/{createIncidentResult.TicketNumber}/accept") + var request = new HttpRequestMessage(HttpMethod.Post, $"/change-requests/{createIncidentResult.TicketNumber}/accept") { Content = new FormUrlEncodedContentBuilder() }; @@ -102,7 +102,7 @@ public async Task Post_ValidRequest_RedirectsWithFlashMessage() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Post, $"/cases/{createIncidentResult.TicketNumber}/accept") + var request = new HttpRequestMessage(HttpMethod.Post, $"/change-requests/{createIncidentResult.TicketNumber}/accept") { Content = new FormUrlEncodedContentBuilder() }; diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/IndexTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/IndexTests.cs similarity index 59% rename from TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/IndexTests.cs rename to TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/IndexTests.cs index 0b3a353ee..da4e0c08b 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/IndexTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/IndexTests.cs @@ -1,4 +1,4 @@ -namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Cases.EditCase; +namespace TeachingRecordSystem.SupportUi.Tests.PageTests.ChangeRequests.EditChangeRequest; public class IndexTests : TestBase { @@ -15,7 +15,7 @@ public async Task Get_UserWithNoRoles_ReturnsForbidden() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}"); // Act var response = await HttpClient.SendAsync(request); @@ -32,7 +32,7 @@ public async Task Get_UserWithoutHelpdeskOrAdministratorRole_ReturnsForbidden() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}"); // Act var response = await HttpClient.SendAsync(request); @@ -48,7 +48,7 @@ public async Task Get_WithTicketNumberForNonExistentIncident_ReturnsNotFound() SetCurrentUser(TestUsers.Helpdesk); var nonExistentTicketNumber = Guid.NewGuid().ToString(); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{nonExistentTicketNumber}"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{nonExistentTicketNumber}"); // Act var response = await HttpClient.SendAsync(request); @@ -65,7 +65,7 @@ public async Task Get_WithTicketNumberForInactiveIncident_ReturnsBadRequest() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId).WithCanceledStatus()); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}"); // Act var response = await HttpClient.SendAsync(request); @@ -74,18 +74,30 @@ public async Task Get_WithTicketNumberForInactiveIncident_ReturnsBadRequest() Assert.Equal(StatusCodes.Status400BadRequest, (int)response.StatusCode); } - [Fact] - public async Task Get_WithTicketNumberForActiveNameChangeIncident_RendersExpectedContent() + [Theory] + [InlineData(true, false, false)] + [InlineData(false, true, false)] + [InlineData(false, false, true)] + [InlineData(true, true, false)] + [InlineData(true, false, true)] + [InlineData(false, true, true)] + [InlineData(true, true, true)] + public async Task Get_WithTicketNumberForActiveNameChangeIncident_RendersExpectedContent(bool hasNewFirstName, bool hasNewMiddleName, bool hasNewLastName) { // Arrange SetCurrentUser(TestUsers.Helpdesk); var createPersonResult = await TestData.CreatePerson(); - var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId).WithMultipleEvidenceFiles()); + var createIncidentResult = await TestData.CreateNameChangeIncident( + b => b.WithCustomerId(createPersonResult.ContactId) + .WithNewFirstName(hasNewFirstName ? TestData.GenerateChangedFirstName(createPersonResult.FirstName) : createPersonResult.FirstName) + .WithNewMiddleName(hasNewMiddleName ? TestData.GenerateChangedMiddleName(createPersonResult.MiddleName) : createPersonResult.MiddleName) + .WithNewLastName(hasNewLastName ? TestData.GenerateChangedLastName(createPersonResult.LastName) : createPersonResult.LastName) + .WithMultipleEvidenceFiles()); var imageEvidence = createIncidentResult.Evidence.Single(e => e.MimeType == "image/jpeg"); var pdfEvidence = createIncidentResult.Evidence.Single(e => e.MimeType == "application/pdf"); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}"); // Act var response = await HttpClient.SendAsync(request); @@ -94,25 +106,43 @@ public async Task Get_WithTicketNumberForActiveNameChangeIncident_RendersExpecte Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); var doc = await response.GetDocument(); - Assert.Equal(createIncidentResult.SubjectTitle, doc.GetElementByTestId("page-title")!.TextContent); - var headerRow = doc.GetElementByTestId("case-header"); - Assert.NotNull(headerRow); - Assert.Equal(createIncidentResult.TicketNumber, headerRow.GetElementByTestId("case-header-case-reference")!.TextContent); - Assert.Equal($"{createPersonResult.FirstName} {createPersonResult.LastName}", headerRow.GetElementByTestId("case-header-name")!.TextContent); - Assert.Equal(createIncidentResult.CreatedOn.ToString("dd/MM/yyyy"), headerRow.GetElementByTestId("case-header-created-on")!.TextContent); + Assert.Equal($"{createIncidentResult.SubjectTitle} - {createPersonResult.FirstName} {createPersonResult.LastName}", doc.GetElementByTestId("heading-caption")!.TextContent); var firstNameRow = doc.GetElementByTestId("first-name"); - Assert.NotNull(firstNameRow); - Assert.Equal(createPersonResult.FirstName, firstNameRow.GetElementByTestId("first-name-current")!.TextContent); - Assert.Equal(createIncidentResult.NewFirstName, firstNameRow.GetElementByTestId("first-name-new")!.TextContent); + if (hasNewFirstName) + { + Assert.NotNull(firstNameRow); + Assert.Equal(createPersonResult.FirstName, firstNameRow.GetElementByTestId("first-name-current")!.TextContent); + Assert.Equal(createIncidentResult.NewFirstName, firstNameRow.GetElementByTestId("first-name-new")!.TextContent); + } + else + { + Assert.Null(firstNameRow); + } + var middleNameRow = doc.GetElementByTestId("middle-name"); - Assert.NotNull(middleNameRow); - Assert.Equal(createPersonResult.MiddleName, middleNameRow.GetElementByTestId("middle-name-current")!.TextContent); - Assert.Equal(createIncidentResult.NewMiddleName, middleNameRow.GetElementByTestId("middle-name-new")!.TextContent); + if (hasNewMiddleName) + { + Assert.NotNull(middleNameRow); + Assert.Equal(createPersonResult.MiddleName, middleNameRow.GetElementByTestId("middle-name-current")!.TextContent); + Assert.Equal(createIncidentResult.NewMiddleName, middleNameRow.GetElementByTestId("middle-name-new")!.TextContent); + } + else + { + Assert.Null(middleNameRow); + } + var lastNameRow = doc.GetElementByTestId("last-name"); - Assert.NotNull(lastNameRow); - Assert.Equal(createPersonResult.LastName, lastNameRow.GetElementByTestId("last-name-current")!.TextContent); - Assert.Equal(createIncidentResult.NewLastName, lastNameRow.GetElementByTestId("last-name-new")!.TextContent); + if (hasNewLastName) + { + Assert.NotNull(lastNameRow); + Assert.Equal(createPersonResult.LastName, lastNameRow.GetElementByTestId("last-name-current")!.TextContent); + Assert.Equal(createIncidentResult.NewLastName, lastNameRow.GetElementByTestId("last-name-new")!.TextContent); + } + else + { + Assert.Null(lastNameRow); + } var imageDocument = doc.GetElementByTestId($"image-{imageEvidence.DocumentId}"); Assert.NotNull(imageDocument); @@ -128,7 +158,7 @@ public async Task Get_WithTicketNumberForActiveDateOfBirthChangeIncident_Renders var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}"); // Act var response = await HttpClient.SendAsync(request); @@ -137,17 +167,12 @@ public async Task Get_WithTicketNumberForActiveDateOfBirthChangeIncident_Renders Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); var doc = await response.GetDocument(); - Assert.Equal(createIncidentResult.SubjectTitle, doc.GetElementByTestId("page-title")!.TextContent); - var headerRow = doc.GetElementByTestId("case-header"); - Assert.NotNull(headerRow); - Assert.Equal(createIncidentResult.TicketNumber, headerRow.GetElementByTestId("case-header-case-reference")!.TextContent); - Assert.Equal($"{createPersonResult.FirstName} {createPersonResult.LastName}", headerRow.GetElementByTestId("case-header-name")!.TextContent); - Assert.Equal(createIncidentResult.CreatedOn.ToString("dd/MM/yyyy"), headerRow.GetElementByTestId("case-header-created-on")!.TextContent); + Assert.Equal($"{createIncidentResult.SubjectTitle} - {createPersonResult.FirstName} {createPersonResult.LastName}", doc.GetElementByTestId("heading-caption")!.TextContent); var dateOfBirthRow = doc.GetElementByTestId("date-of-birth"); Assert.NotNull(dateOfBirthRow); - Assert.Equal(createPersonResult.DateOfBirth.ToString("dd/MM/yyyy"), dateOfBirthRow.GetElementByTestId("date-of-birth-current")!.TextContent); - Assert.Equal(createIncidentResult.NewDateOfBirth.ToString("dd/MM/yyyy"), dateOfBirthRow.GetElementByTestId("date-of-birth-new")!.TextContent); + Assert.Equal(createPersonResult.DateOfBirth.ToString("d MMMM yyyy"), dateOfBirthRow.GetElementByTestId("date-of-birth-current")!.TextContent); + Assert.Equal(createIncidentResult.NewDateOfBirth.ToString("d MMMM yyyy"), dateOfBirthRow.GetElementByTestId("date-of-birth-new")!.TextContent); var imageDocument = doc.GetElementByTestId($"image-{createIncidentResult.Evidence.DocumentId}"); Assert.NotNull(imageDocument); diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/RejectTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/RejectTests.cs similarity index 91% rename from TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/RejectTests.cs rename to TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/RejectTests.cs index 520025814..d80f04e02 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/EditCase/RejectTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/EditChangeRequest/RejectTests.cs @@ -1,4 +1,4 @@ -namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Cases.EditCase; +namespace TeachingRecordSystem.SupportUi.Tests.PageTests.ChangeRequests.EditChangeRequest; public class RejectTests : TestBase { @@ -15,7 +15,7 @@ public async Task Get_WhenUserHasNoRoles_ReturnsForbidden() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}/reject"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}/reject"); // Act var response = await HttpClient.SendAsync(request); @@ -32,7 +32,7 @@ public async Task Get_WhenUserDoesNotHaveHelpdeskOrAdministratorRole_ReturnsForb var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}/reject"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}/reject"); // Act var response = await HttpClient.SendAsync(request); @@ -48,7 +48,7 @@ public async Task Get_WithTicketNumberForNonExistentIncident_ReturnsNotFound() SetCurrentUser(TestUsers.Helpdesk); var nonExistentTicketNumber = Guid.NewGuid().ToString(); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{nonExistentTicketNumber}/reject"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{nonExistentTicketNumber}/reject"); // Act var response = await HttpClient.SendAsync(request); @@ -65,7 +65,7 @@ public async Task Get_WithTicketNumberForInactiveIncident_ReturnsBadRequest() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId).WithCanceledStatus()); - var request = new HttpRequestMessage(HttpMethod.Get, $"/cases/{createIncidentResult.TicketNumber}/reject"); + var request = new HttpRequestMessage(HttpMethod.Get, $"/change-requests/{createIncidentResult.TicketNumber}/reject"); // Act var response = await HttpClient.SendAsync(request); @@ -82,7 +82,7 @@ public async Task Post_WhenRejectionReasonChoiceHasNoSelection_ReturnsError() var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Post, $"/cases/{createIncidentResult.TicketNumber}/reject") + var request = new HttpRequestMessage(HttpMethod.Post, $"/change-requests/{createIncidentResult.TicketNumber}/reject") { Content = new FormUrlEncodedContentBuilder() }; @@ -102,7 +102,7 @@ public async Task Post_WhenUserDoesNotHaveHelpdeskOrAdministratorRole_ReturnsFor var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Post, $"/cases/{createIncidentResult.TicketNumber}/reject") + var request = new HttpRequestMessage(HttpMethod.Post, $"/change-requests/{createIncidentResult.TicketNumber}/reject") { Content = new FormUrlEncodedContentBuilder() { @@ -125,7 +125,7 @@ public async Task Post_WhenRejectionReasonChoiceIsNotChangeNoLongerRequired_Redi var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Post, $"/cases/{createIncidentResult.TicketNumber}/reject") + var request = new HttpRequestMessage(HttpMethod.Post, $"/change-requests/{createIncidentResult.TicketNumber}/reject") { Content = new FormUrlEncodedContentBuilder() { @@ -152,7 +152,7 @@ public async Task Post_WhenRejectionReasonChoiceIsChangeNoLongerRequired_Redirec var createPersonResult = await TestData.CreatePerson(); var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Post, $"/cases/{createIncidentResult.TicketNumber}/reject") + var request = new HttpRequestMessage(HttpMethod.Post, $"/change-requests/{createIncidentResult.TicketNumber}/reject") { Content = new FormUrlEncodedContentBuilder() { diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/IndexTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/IndexTests.cs similarity index 76% rename from TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/IndexTests.cs rename to TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/IndexTests.cs index d09fb3b6c..810e81a55 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/Cases/IndexTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/PageTests/ChangeRequests/IndexTests.cs @@ -1,6 +1,6 @@ using TeachingRecordSystem.Core.Dqt.Models; -namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Cases; +namespace TeachingRecordSystem.SupportUi.Tests.PageTests.ChangeRequests; [Collection(nameof(DisableParallelization))] public class IndexTests : TestBase @@ -17,7 +17,7 @@ public async Task Get_UserWithNoRoles_ReturnsForbidden() // Arrange SetCurrentUser(TestUsers.NoRoles); - var request = new HttpRequestMessage(HttpMethod.Get, "/cases"); + var request = new HttpRequestMessage(HttpMethod.Get, "/change-requests"); // Act var response = await HttpClient.SendAsync(request); @@ -35,7 +35,7 @@ public async Task Get_ValidRequest_RendersExpectedContent() var createPerson2Result = await TestData.CreatePerson(); var createIncident2Result = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPerson2Result.ContactId)); - var request = new HttpRequestMessage(HttpMethod.Get, "/cases"); + var request = new HttpRequestMessage(HttpMethod.Get, "/change-requests"); // Act var response = await HttpClient.SendAsync(request); @@ -44,25 +44,25 @@ public async Task Get_ValidRequest_RendersExpectedContent() Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); var doc = await response.GetDocument(); - var tableRow1 = doc.GetElementByTestId($"case-{createIncident1Result.TicketNumber}"); + var tableRow1 = doc.GetElementByTestId($"change-request-{createIncident1Result.TicketNumber}"); Assert.NotNull(tableRow1); - Assert.Equal(createIncident1Result.TicketNumber, tableRow1.GetElementByTestId($"case-reference-{createIncident1Result.TicketNumber}")!.TextContent); + Assert.Equal(createIncident1Result.TicketNumber, tableRow1.GetElementByTestId($"request-reference-{createIncident1Result.TicketNumber}")!.TextContent); Assert.Equal($"{createPerson1Result.FirstName} {createPerson1Result.LastName}", tableRow1.GetElementByTestId($"name-{createIncident1Result.TicketNumber}")!.TextContent); - Assert.Equal(createIncident1Result.SubjectTitle, tableRow1.GetElementByTestId($"case-type-{createIncident1Result.TicketNumber}")!.TextContent); + Assert.Equal(createIncident1Result.SubjectTitle, tableRow1.GetElementByTestId($"change-type-{createIncident1Result.TicketNumber}")!.TextContent); Assert.Equal(createIncident1Result.CreatedOn.ToString("dd/MM/yyyy"), tableRow1.GetElementByTestId($"created-on-{createIncident1Result.TicketNumber}")!.TextContent); - var tableRow2 = doc.GetElementByTestId($"case-{createIncident2Result.TicketNumber}"); + var tableRow2 = doc.GetElementByTestId($"change-request-{createIncident2Result.TicketNumber}"); Assert.NotNull(tableRow2); - Assert.Equal(createIncident2Result.TicketNumber, tableRow2.GetElementByTestId($"case-reference-{createIncident2Result.TicketNumber}")!.TextContent); + Assert.Equal(createIncident2Result.TicketNumber, tableRow2.GetElementByTestId($"request-reference-{createIncident2Result.TicketNumber}")!.TextContent); Assert.Equal($"{createPerson2Result.FirstName} {createPerson2Result.LastName}", tableRow2.GetElementByTestId($"name-{createIncident2Result.TicketNumber}")!.TextContent); - Assert.Equal(createIncident2Result.SubjectTitle, tableRow2.GetElementByTestId($"case-type-{createIncident2Result.TicketNumber}")!.TextContent); + Assert.Equal(createIncident2Result.SubjectTitle, tableRow2.GetElementByTestId($"change-type-{createIncident2Result.TicketNumber}")!.TextContent); Assert.Equal(createIncident2Result.CreatedOn.ToString("dd/MM/yyyy"), tableRow2.GetElementByTestId($"created-on-{createIncident2Result.TicketNumber}")!.TextContent); } [Fact] - public async Task Get_ValidRequestNoActiveCases_RendersExpectedContent() + public async Task Get_ValidRequestNoActiveChangeRequests_RendersExpectedContent() { // Arrange - var request = new HttpRequestMessage(HttpMethod.Get, "/cases"); + var request = new HttpRequestMessage(HttpMethod.Get, "/change-requests"); // Act var response = await HttpClient.SendAsync(request); @@ -70,6 +70,6 @@ public async Task Get_ValidRequestNoActiveCases_RendersExpectedContent() // Assert Assert.Equal(StatusCodes.Status200OK, (int)response.StatusCode); var doc = await response.GetDocument(); - Assert.NotNull(doc.GetElementByTestId("no-cases")); + Assert.NotNull(doc.GetElementByTestId("no-change-requests")); } } diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.TestCommon/TestData.CreateNameChangeIncident.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.TestCommon/TestData.CreateNameChangeIncident.cs index a3f94c8f3..d47c7caf6 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.TestCommon/TestData.CreateNameChangeIncident.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.TestCommon/TestData.CreateNameChangeIncident.cs @@ -30,6 +30,9 @@ public class CreateNameChangeIncidentBuilder private static readonly string _additionalEvidenceFileMimeType = "application/pdf"; private Guid? _customerId; + private string? _newFirstName; + private string? _newMiddleName; + private string? _newLastName; private IncidentStatusType? _incidentStatusType; private bool _hasMultipleEvidenceFiles = false; @@ -44,6 +47,39 @@ public CreateNameChangeIncidentBuilder WithCustomerId(Guid customerId) return this; } + public CreateNameChangeIncidentBuilder WithNewFirstName(string firstName) + { + if (_newFirstName is not null && _newFirstName != firstName) + { + throw new InvalidOperationException("New first name cannot be changed after it's set."); + } + + _newFirstName = firstName; + return this; + } + + public CreateNameChangeIncidentBuilder WithNewMiddleName(string middleName) + { + if (_newMiddleName is not null && _newMiddleName != middleName) + { + throw new InvalidOperationException("New middle name cannot be changed after it's set."); + } + + _newMiddleName = middleName; + return this; + } + + public CreateNameChangeIncidentBuilder WithNewLastName(string lastName) + { + if (_newLastName is not null && _newLastName != lastName) + { + throw new InvalidOperationException("New last name cannot be changed after it's set."); + } + + _newLastName = lastName; + return this; + } + public CreateNameChangeIncidentBuilder WithMultipleEvidenceFiles() { _hasMultipleEvidenceFiles = true; @@ -90,9 +126,9 @@ public async Task Execute(TestData testData) throw new InvalidOperationException("Customer ID must be specified."); } - var firstName = testData.GenerateFirstName(); - var middleName = testData.GenerateMiddleName(); - var lastName = testData.GenerateLastName(); + var firstName = _newFirstName ?? testData.GenerateFirstName(); + var middleName = _newMiddleName ?? testData.GenerateMiddleName(); + var lastName = _newLastName ?? testData.GenerateLastName(); var incidentId = Guid.NewGuid(); var title = "Request to change name";
    @ViewBag.Title
    Case referenceReference NameCase typeType Created on
    No cases
    No change requests
    @caseInfo.CaseReference@caseInfo.Customer@caseInfo.CaseType@caseInfo.CreatedOn.ToString("dd/MM/yyyy")
    @changeRequestInfo.RequestReference@changeRequestInfo.Customer@changeRequestInfo.ChangeType@changeRequestInfo.CreatedOn.ToString("dd/MM/yyyy")