Skip to content

Commit

Permalink
Tweaks following design content changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hortha committed Sep 20, 2024
1 parent 775020c commit 374a50e
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 3,366 deletions.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@page "/alerts/add/check-answers/{handler?}"
@model TeachingRecordSystem.SupportUi.Pages.Alerts.AddAlert.CheckAnswersModel
@{
ViewBag.Title = "Check details and confirm alert";
ViewBag.Title = "Check details and add alert";
}

@section BeforeContent {
Expand Down Expand Up @@ -38,7 +38,7 @@
}
else
{
<span use-empty-fallback />
<span use-empty-fallback></span>
}
</govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
Expand All @@ -60,8 +60,8 @@
</govuk-summary-list-row-actions>
</govuk-summary-list-row>
<govuk-summary-list-row>
<govuk-summary-list-row-key>Reason</govuk-summary-list-row-key>
<govuk-summary-list-row-value data-testid="reason" use-empty-fallback><multi-line-text text="@Model.Reason" /></govuk-summary-list-row-value>
<govuk-summary-list-row-key>Reason for adding</govuk-summary-list-row-key>
<govuk-summary-list-row-value data-testid="reason"><multi-line-text text="@Model.Reason" use-empty-fallback /></govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
<govuk-summary-list-row-action href="@LinkGenerator.AlertAddReason(Model.PersonId, Model.JourneyInstance!.InstanceId, fromCheckAnswers: true)">Change</govuk-summary-list-row-action>
</govuk-summary-list-row-actions>
Expand All @@ -75,7 +75,7 @@
}
else
{
<span use-empty-fallback />
<span use-empty-fallback></span>
}
</govuk-summary-list-row-value>
<govuk-summary-list-row-actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<form action="@LinkGenerator.AlertAddDetails(Model.PersonId, Model.JourneyInstance!.InstanceId, Model.FromCheckAnswers)" method="post">
<span class="govuk-caption-l">Add an alert - @Model.PersonName</span>

<govuk-character-count asp-for="Details" label-class="govuk-label--l" max-length="4000" data-testid="details" />
<govuk-character-count asp-for="Details" max-length="4000" data-testid="details">
<govuk-character-count-label class="govuk-label--l" is-page-heading="true" />
</govuk-character-count>

<div class="govuk-button-group">
<govuk-button type="submit">Continue</govuk-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DetailsModel(TrsLinkGenerator linkGenerator) : PageModel

[BindProperty]
[Required(ErrorMessage = "Enter details")]
[Display(Name = "Details")]
[Display(Name = "Enter details")]
public string? Details { get; set; }

public async Task<IActionResult> OnPost()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
<div class="govuk-grid-column-two-thirds-from-desktop">
<form action="@LinkGenerator.AlertAddEndDate(Model.PersonId, Model.JourneyInstance!.InstanceId, Model.FromCheckAnswers)" method="post">
<span class="govuk-caption-l">Add an alert - @Model.PersonName</span>
<h1 class="govuk-heading-l" data-testid="title">@ViewBag.Title</h1>

<govuk-radios asp-for="HasEndDate">
<govuk-radios-fieldset>
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--m" />
<govuk-radios-fieldset-legend is-page-heading="true" class="govuk-fieldset__legend--l" />
<govuk-radios-item value="@true">Yes
<govuk-radios-item-conditional>
<govuk-date-input asp-for="EndDate"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class LinkModel(TrsLinkGenerator linkGenerator) : PageModel
public string? PersonName { get; set; }

[BindProperty]
[Display(Name = "Link")]
[Display(Name = "Enter link")]
public string? Link { get; set; }

public async Task<IActionResult> OnPost()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<form action="@LinkGenerator.AlertAddReason(Model.PersonId, Model.JourneyInstance!.InstanceId, Model.FromCheckAnswers)" method="post" enctype="multipart/form-data">
<span class="govuk-caption-l">Add an alert - @Model.PersonName</span>

<govuk-character-count asp-for="Detail" label-class="govuk-label--l" max-length="4000">
<govuk-character-count asp-for="Detail" max-length="4000">
<govuk-character-count-label class="govuk-label--l" is-page-heading="true" />
<govuk-character-count-hint>Optional</govuk-character-count-hint>
</govuk-character-count>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public class ReasonModel(TrsLinkGenerator linkGenerator, IFileService fileServic
public string? PersonName { get; set; }

[BindProperty]
[Display(Name = "Reason for adding")]
[Display(Name = "Why are you adding this alert?")]
public string? Detail { get; set; }

[BindProperty]
[Display(Name = "Upload evidence")]
[Display(Name = "Do you want to upload evidence?")]
[Required(ErrorMessage = "Select yes if you want to upload evidence")]
public bool? UploadEvidence { get; set; }

Expand Down Expand Up @@ -115,6 +115,12 @@ public async Task<IActionResult> OnPostCancel()

public override void OnPageHandlerExecuting(PageHandlerExecutingContext context)
{
if (JourneyInstance!.State.HasEndDate is null)
{
context.Result = Redirect(linkGenerator.AlertAddEndDate(PersonId, JourneyInstance.InstanceId));
return;
}

var personInfo = context.HttpContext.GetCurrentPersonFeature();

PersonName = personInfo.Name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class StartDateModel(TrsLinkGenerator linkGenerator) : PageModel

[BindProperty]
[Required(ErrorMessage = "Enter a start date")]
[Display(Name = "Start date")]
[Display(Name = "Enter start date")]
public DateOnly? StartDate { get; set; }

public async Task<IActionResult> OnPost()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
<div class="govuk-grid-column-two-thirds-from-desktop">
<form action="@LinkGenerator.AlertAddType(Model.PersonId, Model.JourneyInstance!.InstanceId, Model.FromCheckAnswers)" method="post">
<span class="govuk-caption-l">Add an alert - @Model.PersonName</span>
<h1 class="govuk-heading-l" data-testid="title">@ViewBag.Title</h1>

<govuk-radios asp-for="AlertTypeId" data-testid="alert-category-list">
<govuk-radios-fieldset>
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--m">Select one</govuk-radios-fieldset-legend>
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--l" is-page-heading="true" />

@foreach (var category in Model.Categories!)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TypeModel(
public string? PersonName { get; set; }

[BindProperty]
[Display(Name = "Alert Type")]
[Display(Name = "Select an alert type")]
[Required(ErrorMessage = "Select an alert type")]
public Guid? AlertTypeId { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public async Task AddAlert()

await page.AssertOnAddAlertDetailsPage();

await page.FillAsync("label:text-is('Details')", details);
await page.FillAsync("label:text-is('Enter details')", details);

await page.ClickContinueButton();

await page.AssertOnAddAlertLinkPage();

await page.FillAsync("label:text-is('Link')", link);
await page.FillAsync("label:text-is('Enter link')", link);

await page.ClickContinueButton();

Expand All @@ -56,11 +56,11 @@ public async Task AddAlert()

await page.AssertOnAddAlertReasonPage();

await page.FillAsync("label:text-is('Reason')", reason);
await page.FillAsync("label:text-is('Why are you adding this alert?')", reason);

await page.CheckAsync("text=Yes");
await page
.GetByLabel("Upload file")
.GetByLabel("Upload a file")
.SetInputFilesAsync(
new FilePayload()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public async Task Get_WithPersonIdForNonExistentPerson_ReturnsNotFound()
AlertTypeId = Guid.NewGuid(),
Details = "Details",
StartDate = new DateOnly(2021, 1, 1),
HasEndDate = true,
EndDate = new DateOnly(2021, 1, 1),
UploadEvidence = false
});
Expand All @@ -29,17 +30,12 @@ public async Task Get_WithPersonIdForNonExistentPerson_ReturnsNotFound()
}

[Fact]
public async Task Get_MissingDataInJourneyState_RedirectsToReasonPage()
public async Task Get_MissingDataInJourneyState_RedirectsToAlertTypePage()
{
// Arrange
var person = await TestData.CreatePerson();

var journeyInstance = await CreateJourneyInstance(person.PersonId, new AddAlertState
{
AlertTypeId = Guid.NewGuid(),
Details = "Details",
StartDate = new DateOnly(2021, 1, 1)
});
var journeyInstance = await CreateJourneyInstance(person.PersonId);

var request = new HttpRequestMessage(HttpMethod.Get, $"/alerts/add/check-answers?personId={person.PersonId}&{journeyInstance.GetUniqueIdQueryParameter()}");

Expand All @@ -48,7 +44,7 @@ public async Task Get_MissingDataInJourneyState_RedirectsToReasonPage()

// Assert
Assert.Equal(StatusCodes.Status302Found, (int)response.StatusCode);
Assert.StartsWith($"/alerts/add/reason?personId={person.PersonId}", response.Headers.Location?.OriginalString);
Assert.StartsWith($"/alerts/add/type?personId={person.PersonId}", response.Headers.Location?.OriginalString);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ public async Task Post_WithMissingDataInJourneyState_RedirectsToStartDatePage()
Assert.StartsWith($"/alerts/add/start-date?personId={person.PersonId}", response.Headers.Location?.OriginalString);
}

[Fact]
public async Task Post_WhenNoHasEndDateOptionIsSelected_ReturnsError()
{
// Arrange
var person = await TestData.CreatePerson();

var journeyInstance = await CreateJourneyInstance(person.PersonId, new AddAlertState
{
AlertTypeId = Guid.NewGuid(),
Details = "Details",
StartDate = new DateOnly(2021, 1, 1)
});

var request = new HttpRequestMessage(HttpMethod.Post, $"/alerts/add/end-date?personId={person.PersonId}&{journeyInstance.GetUniqueIdQueryParameter()}");

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

// Assert
await AssertEx.HtmlResponseHasError(response, "HasEndDate", "Select yes if there is an end date for this alert");
}

[Fact]
public async Task Post_WhenEndDateOptionIsYesAndNoEndDateIsEntered_ReturnsError()
{
Expand All @@ -174,7 +196,7 @@ public async Task Post_WhenEndDateOptionIsYesAndNoEndDateIsEntered_ReturnsError(
var response = await HttpClient.SendAsync(request);

// Assert
await AssertEx.HtmlResponseHasError(response, "HasEndDate", "Select yes if there is an end date for this alert");
await AssertEx.HtmlResponseHasError(response, "EndDate", "Enter an end date");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace TeachingRecordSystem.SupportUi.Tests.PageTests.Alerts.AddAlert;
public class IndexTests(HostFixture hostFixture) : TestBase(hostFixture)
{
[Fact]
public async Task Get_RedirectsToAlertAddCategory()
public async Task Get_RedirectsToAlertAddType()
{
// Arrange
var person = await TestData.CreatePerson();
Expand All @@ -16,6 +16,6 @@ public async Task Get_RedirectsToAlertAddCategory()

// Assert
Assert.Equal(StatusCodes.Status302Found, (int)response.StatusCode);
Assert.StartsWith($"/alerts/add/category?personId={person.PersonId}", response.Headers.Location?.OriginalString);
Assert.StartsWith($"/alerts/add/type?personId={person.PersonId}", response.Headers.Location?.OriginalString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ public async Task Get_ValidRequestWithPopulatedDataInJourneyState_PopulatesModel
}

[Fact]
public async Task Get_MissingDataInJourneyState_RedirectsToStartDatePage()
public async Task Get_MissingDataInJourneyState_RedirectsToEndDatePage()
{
var person = await TestData.CreatePerson();

var journeyInstance = await CreateJourneyInstance(person.PersonId, new AddAlertState
{
AlertTypeId = Guid.NewGuid(),
Details = "Details"
Details = "Details",
StartDate = new DateOnly(2022, 1, 1)
});

var request = new HttpRequestMessage(HttpMethod.Get, $"/alerts/add/reason?personId={person.PersonId}&{journeyInstance.GetUniqueIdQueryParameter()}");
Expand All @@ -83,7 +84,7 @@ public async Task Get_MissingDataInJourneyState_RedirectsToStartDatePage()

// Assert
Assert.Equal(StatusCodes.Status302Found, (int)response.StatusCode);
Assert.StartsWith($"/alerts/add/start-date?personId={person.PersonId}", response.Headers.Location?.OriginalString);
Assert.StartsWith($"/alerts/add/end-date?personId={person.PersonId}", response.Headers.Location?.OriginalString);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@ public async Task Post_ValidInput_RedirectsToDetailsPage()
{
// Arrange
var person = await TestData.CreatePerson();
var alertType = await TestData.ReferenceDataCache.GetAlertTypeById(Guid.Parse("ed0cd700-3fb2-4db0-9403-ba57126090ed")); // Prohibition by the Secretary of State - misconduct

var journeyInstance = await CreateJourneyInstance(person.PersonId);

var request = new HttpRequestMessage(HttpMethod.Post, $"/alerts/add/type?personId={person.PersonId}&{journeyInstance.GetUniqueIdQueryParameter()}")
{
Content = new FormUrlEncodedContent(new Dictionary<string, string>
{
["AlertTypeId"] = Guid.NewGuid().ToString()
["AlertTypeId"] = alertType.AlertTypeId.ToString()
})
};

Expand Down

0 comments on commit 374a50e

Please sign in to comment.