Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/is form a mat flag - Change route names #1013

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public int Id { get; set; }
public int? Urn { get; set; }
public int? FormAMatProjectId { get; set; }
public bool? IsFormAMat { get; set; }
public DateTime CreatedOn { get; set; }
public string SchoolName { get; set; }
public string SchoolPhase { get; set; }
Expand Down Expand Up @@ -59,7 +60,7 @@

// External Application Form
public bool? ExternalApplicationFormSaved { get; set; }
public string? ExternalApplicationFormUrl { get; set; }

Check warning on line 63 in Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

// School Overview
public string PublishedAdmissionNumber { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Dfe.PrepareConversions.Data.Models
public static class AcademyTypeAndRoutes
{
public const string Voluntary = "Converter";
public const string FormAMat = "Form a MAT";
public const string Sponsored = "Sponsored";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,37 @@ public void ToBool_Should_ThrowArgumentException_When_StringIsNotYesOrNo()
[Fact]
public void Should_be_able_to_convert_voluntary_conversion_route_to_the_correct_description()
{
AcademyTypeAndRoutes.Voluntary.RouteDescription().Should().Be("Voluntary conversion");
AcademyTypeAndRoutes.Voluntary.RouteDescription(false).Should().Be("Voluntary conversion");
}

[Fact]
public void Should_be_able_to_convert_sponsored_conversion_route_to_the_correct_description()
{
AcademyTypeAndRoutes.Sponsored.RouteDescription().Should().Be("Sponsored conversion");
AcademyTypeAndRoutes.Sponsored.RouteDescription(false).Should().Be("Sponsored conversion");
}

[Fact]
public void Should_convert_form_a_mat_route_to_the_correct_description()
public void Should_convert_voluntary_form_a_mat_route_to_the_correct_description()
{
AcademyTypeAndRoutes.FormAMat.RouteDescription().Should().Be("Form a MAT");
AcademyTypeAndRoutes.Voluntary.RouteDescription(true).Should().Be("Form a MAT Voluntary conversion");
}

[Fact]
public void Should_convert_sponsored_form_a_mat_route_to_the_correct_description()
{
AcademyTypeAndRoutes.Sponsored.RouteDescription(true).Should().Be("Form a MAT Sponsored conversion");
}

[Fact]
public void Should_pass_through_unrecognised_routes_unchanged()
{
"This is unknown".RouteDescription().Should().Be("This is unknown");
"This is unknown".RouteDescription(null).Should().Be("This is unknown");
}

[Fact]
public void Should_ignore_capitalisation_and_spaces_in_routes()
{
"CoN vEr TeR".RouteDescription().Should().Be("Voluntary conversion");
"FORMaMAT".RouteDescription().Should().Be("Form a MAT");
"CoN vEr TeR".RouteDescription(null).Should().Be("Voluntary conversion");
}

[Theory]
Expand All @@ -133,6 +138,6 @@ public void Should_ignore_capitalisation_and_spaces_in_routes()
[InlineData("")]
public void RouteDescription_Should_Return_EmptyString_When_Passed_NullOrWhitespace(string input)
{
input.RouteDescription().Should().Be(string.Empty);
input.RouteDescription(null).Should().Be(string.Empty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Dfe.PrepareConversions.Tests.Pages;

public abstract partial class BaseIntegrationTests
{
private readonly string[] _routes = { AcademyTypeAndRoutes.Voluntary, AcademyTypeAndRoutes.Sponsored, AcademyTypeAndRoutes.FormAMat };
private readonly string[] _routes = { AcademyTypeAndRoutes.Voluntary, AcademyTypeAndRoutes.Sponsored };

protected IEnumerable<AcademyConversionProject> AddGetProjects(Action<AcademyConversionProject> postSetup = null,
int? recordCount = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ static void PostProjectSetup(AcademyConversionProject project)

[Theory]
[InlineData(AcademyTypeAndRoutes.Voluntary)]
[InlineData(AcademyTypeAndRoutes.FormAMat)]
public async Task Given_Not_SponsoredConversion_When_Previewed_Then_LegalRequirements_Are_Shown(string routeToConversion)
{
void PostProjectSetup(AcademyConversionProject project)
Expand All @@ -58,7 +57,6 @@ void PostProjectSetup(AcademyConversionProject project)

[Theory]
[InlineData(AcademyTypeAndRoutes.Voluntary)]
[InlineData(AcademyTypeAndRoutes.FormAMat)]
public async Task Given_Not_SponsoredConversion_When_Previewed_Then_RationaleForProject_Is_Shown(string routeToConversion)
{
void PostProjectSetup(AcademyConversionProject project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ public void Should_be_considered_sponsored_if_the_route_is_sponsored()
.IsSponsored.Should().BeFalse();
}

[Fact]
public void Should_be_considered_a_form_a_mat_project_if_the_route_is_form_a_met()
{
new ProjectListViewModel { TypeAndRoute = AcademyTypeAndRoutes.FormAMat }
.IsFormAMat.Should().BeTrue();

new ProjectListViewModel { TypeAndRoute = "Anything else" }
.IsFormAMat.Should().BeFalse();
}

[Fact]
public void Should_be_considered_a_voluntary_conversion_if_the_project_is_neither_sponsored_nor_form_a_mat()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@

public static class StringExtensions
{
public static string RouteDescription(this string @string)
public static string RouteDescription(this string @string, bool? isFormAMat)
{
const string converter = nameof(converter);
const string sponsored = nameof(sponsored);
const string formamat = nameof(formamat);

if (string.IsNullOrWhiteSpace(@string))
{
return string.Empty;
}
var stringPrefix = isFormAMat.HasValue && isFormAMat.Value ? "Form a MAT " : string.Empty;

return @string.SquishToLower() switch
{
sponsored => "Sponsored conversion",
converter => "Voluntary conversion",
formamat => "Form a MAT",
sponsored => stringPrefix + "Sponsored conversion",
converter => stringPrefix + "Voluntary conversion",
_ => @string,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<div id="@("type-and-route-" + projectRow.Index)" class="govuk-!-margin-top-1">
<strong>Route:</strong>
<span if="projectRow.Item.TypeAndRoute.IsEmpty()" class="empty">Unconfirmed</span>
<span if="projectRow.Item.TypeAndRoute.IsPresent()">@projectRow.Item.TypeAndRoute.RouteDescription()</span>
<span if="projectRow.Item.TypeAndRoute.IsPresent()">@projectRow.Item.TypeAndRoute.RouteDescription(project.IsFormAMat)</span>
</div>
@if (!isFormAMat)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<span id="@("urn-" + Model.Index)">URN: @Model.Item.SchoolURN</span>
</h2>
<p class="govuk-!-margin-top-3">
<div data-cy="route">Route: @Model.Item.TypeAndRoute.RouteDescription()</div>
<div data-cy="route">Route: @Model.Item.TypeAndRoute.RouteDescription(true)</div>
<div id="@("application-to-join-trust-" + Model.Index)">Application to join a trust: @Model.Item.NameOfTrust</div>
@if (@Model.Item.LocalAuthority.IsEmpty() is false)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@using Dfe.PrepareConversions.Data.Models
@if (ViewData["AcademyTypeAndRoute"] is not null)
{
@if (ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.Voluntary) || ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.FormAMat))
paullocknimble marked this conversation as resolved.
Show resolved Hide resolved
@if (ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.Voluntary))
{
<p>
This information comes from TRAMS and the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@Model.SchoolName
</h1>
<p class="govuk-body govuk-!-margin-bottom-1">
Route: @Model.AcademyTypeAndRoute.RouteDescription()
Route: @Model.AcademyTypeAndRoute.RouteDescription(@Model.IsFormAMat)
</p>
<p class="govuk-body govuk-!-margin-bottom-5">
Project owner:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div id="@("type-and-route-" + projectRow.Index)" class="govuk-!-margin-top-1">
<strong>Route:</strong>
<span if="projectRow.Item.TypeAndRoute.IsEmpty()" class="empty">Unconfirmed</span>
<span if="projectRow.Item.TypeAndRoute.IsPresent()">@projectRow.Item.TypeAndRoute.RouteDescription()</span>
<span if="projectRow.Item.TypeAndRoute.IsPresent()">@projectRow.Item.TypeAndRoute.RouteDescription(project.IsFormAMat)</span>
</div>
@if (!isFormAMat)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{
<partial name="_SponsoredUsefulInformation"/>
}
else if (ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.Voluntary) || ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.FormAMat))
else if (ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.Voluntary))
{
<partial name="_UsefulInformation"/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
School application form
</sub-menu-link>
</li>
<li if="@Model.IsFormAMat" class="moj-sub-navigation__item">
<li if="@Model.IsFormAMat;" class="moj-sub-navigation__item">
<sub-menu-link class="moj-sub-navigation__link"
asp-page="@Links.FormAMat.Index.Page"
asp-route-id="@id">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Confirm project and trust rationale
</h1>
<div class="govuk-body">
@if (ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.Voluntary) || ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.FormAMat))
@if (ViewData["AcademyTypeAndRoute"].Equals(AcademyTypeAndRoutes.Voluntary))
{
<p>
This information comes from the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static ProjectListViewModel Build(AcademyConversionProject academyConvers
return new ProjectListViewModel
{
Id = academyConversionProject.Id.ToString(),
IsFormAMat = academyConversionProject.IsFormAMat.HasValue && academyConversionProject.IsFormAMat.Value,
SchoolURN = academyConversionProject.Urn.HasValue ? academyConversionProject.Urn.ToString() : "",
SchoolName = academyConversionProject.SchoolName,
LocalAuthority = academyConversionProject.LocalAuthority,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace Dfe.PrepareConversions.ViewModels;
public abstract class ProjectTypeBase
{
protected abstract string TypeAndRouteValue { get; }

public bool IsFormAMat { get; init; }

public virtual bool IsExternalSchoolApplication { get; } = false;


Expand All @@ -14,7 +17,4 @@ public abstract class ProjectTypeBase

public bool IsVoluntary => string.IsNullOrWhiteSpace(TypeAndRouteValue) is false &&
TypeAndRouteValue.Equals(AcademyTypeAndRoutes.Voluntary, StringComparison.InvariantCultureIgnoreCase);

public bool IsFormAMat => string.IsNullOrWhiteSpace(TypeAndRouteValue) is false &&
TypeAndRouteValue.Equals(AcademyTypeAndRoutes.FormAMat, StringComparison.InvariantCultureIgnoreCase);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public ProjectViewModel(AcademyConversionProject project)
{
Id = project.Id.ToString();
FormAMatProjectId = project.FormAMatProjectId;
IsFormAMat = project.IsFormAMat.HasValue && project.IsFormAMat.Value;
ProjectStatus = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Value;
ProjectStatusColour = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Colour;
ApplicationReferenceNumber = project.ApplicationReferenceNumber;
Expand Down Expand Up @@ -129,6 +130,7 @@ public ProjectViewModel(AcademyConversionProject project)

public string Id { get; }
public int? FormAMatProjectId { get; }
public bool IsFormAMat { get; }
public string ProjectStatus { get; }
public string ProjectStatusColour { get; }
public string ApplicationReferenceNumber { get; set; }
Expand Down
Loading