Skip to content

Commit

Permalink
Bugs/179195 - Fixes - Alphabetical order for statuses & show all stat…
Browse files Browse the repository at this point in the history
…uses for central route (#842)

* Filter statuses for Presumption proj and show all for Central route

* cypress tests
  • Loading branch information
zhodges-nimble authored Sep 24, 2024
1 parent 4f19616 commit 2cd3098
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,115 @@ describe("Testing that we can change the project status", () => {
Logger.log("user is sent back to projects overview page");

projectOverviewPage
.hasWithdrawnDate("1 January 2045");
.hasWithdrawnDate("1 January 2045")
.clickChangeProjectStatus();

projectStatusPage
.selectOpen()
.clickSaveAndContine()

projectOverviewPage
.hasProjectStatus("Open")
.selectTaskListTab()
.clickChangeProjectStatus();

projectStatusPage
.openIsChecked()
.selectCancelled()
.clickSaveAndContine()
.errorForCancelledDate("Enter a date in the correct format")
.addCancelledYear("1", "1", "error")
.clickSaveAndContine()
.errorForCancelledDate("Enter a date in the correct format")
.addCancelledYear("1", "1", "1999")
.clickSaveAndContine()
.errorForCancelledDate("Year must be between 2000 and 2050")
.clickSaveAndContine()
.addCancelledYear("1", "1", "2051")
.errorForCancelledDate("Year must be between 2000 and 2050")
.addCancelledYear("1", "1", "2050")
.clickSaveAndContine()


Logger.log("user is sent back to tasklist");

taskListPage
.onTasklistTab()
.hasProjectStatus("Cancelled")
.selectAboutTheProjectTab()


Logger.log("cancelled date is shown on project overview");

projectOverviewPage
.hasCancelledDate("1 January 2050")
.selectContactsTab();


Logger.log("change status to closed");

contactsPage
.hasProjectStatus("Cancelled")
.clickChangeProjectStatus();

projectStatusPage
.cancelledIsChecked()
.cancelledYearHasValue("1", "1", "2050")
.selectClosed()
.clickSaveAndContine()
.errorForClosedDate("Enter a date in the correct format")
.addClosedYear("1", "1", "error")
.clickSaveAndContine()
.errorForClosedDate("Enter a date in the correct format")
.addClosedYear("1", "1", "1999")
.clickSaveAndContine()
.errorForClosedDate("Year must be between 2000 and 2050")
.clickSaveAndContine()
.addClosedYear("1", "1", "2051")
.errorForClosedDate("Year must be between 2000 and 2050")
.addClosedYear("1", "1", "2048")
.clickSaveAndContine()

Logger.log("user is sent back to contacts page");

contactsPage
.onContactsTab()
.hasProjectStatus("Closed")
.selectAboutTheProjectTab();

Logger.log("closed date is shown on project overview");

projectOverviewPage
.hasClosedDate("1 January 2048")

Logger.log("change status to withdrawn");

projectOverviewPage
.clickChangeProjectStatus()

projectStatusPage
.closedIsChecked()
.closedYearHasValue("1", "1", "2048")
.selectWithdrawn()
.clickSaveAndContine()
.errorForWithdrawnDate("Enter a date in the correct format")
.addWithdrawnYear("1", "1", "error")
.clickSaveAndContine()
.errorForWithdrawnDate("Enter a date in the correct format")
.addWithdrawnYear("1", "1", "1999")
.clickSaveAndContine()
.errorForWithdrawnDate("Year must be between 2000 and 2050")
.clickSaveAndContine()
.addWithdrawnYear("1", "1", "2051")
.errorForWithdrawnDate("Year must be between 2000 and 2050")
.addWithdrawnYear("1", "1", "2047")
.clickSaveAndContine()

Logger.log("user is sent back to projects overview page");

projectOverviewPage
.hasWithdrawnDate("1 January 2047")

});

it("Change status for Presumption project", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,39 @@
var backlink = string.Format(RouteConstants.ProjectOverview, Model.ProjectId);
ViewData["Title"] = "Edit Project status - " + $"{Model.Project.ProjectStatus.CurrentFreeSchoolName}";

var isVisibleToPresumption = Model.Project.ProjectType.Contains("Presumption");
var isPresumptionProject = Model.Project.ProjectType.Contains("Presumption");

var options = new List<ProjectStatusOption>
ProjectStatus[] presumptionStatuses = [ProjectStatus.Cancelled, ProjectStatus.Closed, ProjectStatus.Open, ProjectStatus.Preopening, ProjectStatus.WithdrawnDuringPreOpening];

var projectStatusOptions = new List<ProjectStatusOption>
{
new("project-status-application-competition-stage", ProjectStatus.ApplicationCompetitionStage, !isVisibleToPresumption,
new("project-status-application-competition-stage", ProjectStatus.ApplicationCompetitionStage,
ProjectStatus.ApplicationCompetitionStage.ToDescription(), "The special or alternative provision application is being considered.", false),

new("project-status-application-stage", ProjectStatus.ApplicationStage, !isVisibleToPresumption,
new("project-status-application-stage", ProjectStatus.ApplicationStage,
ProjectStatus.ApplicationStage.ToDescription(), "The school's application is being considered.", false),

new("project-status-cancelled", ProjectStatus.Cancelled, isVisibleToPresumption,
ProjectStatus.Cancelled.ToDescription(), "The project was cancelled in pre-opening.", true,
new("project-status-cancelled", ProjectStatus.Cancelled, ProjectStatus.Cancelled.ToDescription(), "The project was cancelled in pre-opening.", true,
"year-cancelled", "year-cancelled", "Date the project was cancelled", "For example, 27 3 2021", Model.CancelledYear),

new("project-status-closed", ProjectStatus.Closed, isVisibleToPresumption,
ProjectStatus.Closed.ToDescription(), "The school has closed.", true,
new("project-status-closed", ProjectStatus.Closed, ProjectStatus.Closed.ToDescription(), "The school has closed.", true,
"year-closed", "year-closed", "Date the school was closed", "For example, 23 2 2021", Model.ClosedYear),

new("project-status-open", ProjectStatus.Open, isVisibleToPresumption,
ProjectStatus.Open.ToDescription(), "The school has opened.", false),
new("project-status-open", ProjectStatus.Open, ProjectStatus.Open.ToDescription(), "The school has opened.", false),

new("project-status-open-not-included", ProjectStatus.OpenNotIncludedInFigures, !isVisibleToPresumption,
ProjectStatus.OpenNotIncludedInFigures.ToDescription(), "For example, this project is not a free school but is using free schools budget.", false),
new("project-status-open-not-included", ProjectStatus.OpenNotIncludedInFigures, ProjectStatus.OpenNotIncludedInFigures.ToDescription(), "For example, this project is not a free school but is using free schools budget.", false),

new("project-status-pre-opening", ProjectStatus.Preopening, isVisibleToPresumption,
ProjectStatus.Preopening.ToDescription(), "The project stage after the application stage.", false),
new("project-status-pre-opening", ProjectStatus.Preopening, ProjectStatus.Preopening.ToDescription(), "The project stage after the application stage.", false),

new("project-status-pre-opening-not-included", ProjectStatus.PreopeningNotIncludedInFigures, !isVisibleToPresumption,
ProjectStatus.PreopeningNotIncludedInFigures.ToDescription(), "For example, this project is not a free school but is using free schools budget.", false),
new("project-status-pre-opening-not-included", ProjectStatus.PreopeningNotIncludedInFigures, ProjectStatus.PreopeningNotIncludedInFigures.ToDescription(), "For example, this project is not a free school but is using free schools budget.", false),

new("project-status-rejected", ProjectStatus.Rejected, !isVisibleToPresumption,
new("project-status-rejected", ProjectStatus.Rejected,
ProjectStatus.Rejected.ToDescription(), "A Regional Director did not approve the project to move into pre-opening.", false),

new("project-status-withdrawn-application", ProjectStatus.WithdrawnDuringApplication, !isVisibleToPresumption,
ProjectStatus.WithdrawnDuringApplication.ToDescription(), "For example, the trust withdrew their application.", true,
new("project-status-withdrawn-application", ProjectStatus.WithdrawnDuringApplication, ProjectStatus.WithdrawnDuringApplication.ToDescription(), "For example, the trust withdrew their application.", true,
"year-withdrawn-application", "year-withdrawn-application", "Date the project was withdrawn", "For example, 23 2 2021", Model.WithdrawnApplicationYear),

new("project-status-withdrawn", ProjectStatus.WithdrawnDuringPreOpening, isVisibleToPresumption,
ProjectStatus.WithdrawnDuringPreOpening.ToDescription(), "For example, the trust withdrew in the pre-opening stage.", true,
new("project-status-withdrawn", ProjectStatus.WithdrawnDuringPreOpening, ProjectStatus.WithdrawnDuringPreOpening.ToDescription(), "For example, the trust withdrew in the pre-opening stage.", true,
"year-withdrawn-preopening", "year-withdrawn-preopening", "Date the project was withdrawn", "For example, 23 2 2021", Model.WithdrawnYear)
};
}
Expand All @@ -70,17 +64,21 @@

<div class="govuk-form-group" id="project-status">
<govuk-radios-list>
@foreach (var option in options.Where(option => option.IsVisible).ToList())
{
if (option.IsConditional)
{
<govuk-radios-list-conditional-item id="@option.Id" value="@option.Value" description="@option.Description" hint="@option.Hint" asp-for="@Model.ProjectStatus" name="project-status">
<govuk-date-input id="@option.DateInputId" name="@option.DateInputName" asp-for="@option.DateInputValueAspFor" label="@option.DateInputLabel" hint="@option.DateInputHint"/>
</govuk-radios-list-conditional-item>
}
else
@{
var options = isPresumptionProject ? projectStatusOptions.Where(x => presumptionStatuses.Contains(x.Value)) : projectStatusOptions;

foreach (var option in options.OrderBy(x => Enum.GetName(typeof(ProjectStatus), x.Value)))
{
<govuk-radios-list-item id="@option.Id" value="@option.Value" description="@option.Description" hint="@option.Hint" asp-for="@Model.ProjectStatus" name="project-status"/>
if (option.IsConditional)
{
<govuk-radios-list-conditional-item id="@option.Id" value="@option.Value" description="@option.Description" hint="@option.Hint" asp-for="@Model.ProjectStatus" name="project-status">
<govuk-date-input id="@option.DateInputId" name="@option.DateInputName" asp-for="@option.DateInputValueAspFor" label="@option.DateInputLabel" hint="@option.DateInputHint"/>
</govuk-radios-list-conditional-item>
}
else
{
<govuk-radios-list-item id="@option.Id" value="@option.Value" description="@option.Description" hint="@option.Hint" asp-for="@Model.ProjectStatus" name="project-status"/>
}
}
}
</govuk-radios-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class ProjectStatusOption
{
public string Id { get; set; }
public API.Contracts.Project.ProjectStatus Value { get; set; }
public bool IsVisible { get; set; } // Remains here as the third property
public string Description { get; set; }
public string Hint { get; set; }
public bool IsConditional { get; set; }
Expand All @@ -20,19 +19,18 @@ private ProjectStatusOption()
{
}

public ProjectStatusOption(string id, API.Contracts.Project.ProjectStatus value, bool isVisible, string description, string hint, bool isConditional)
public ProjectStatusOption(string id, API.Contracts.Project.ProjectStatus value, string description, string hint, bool isConditional)
{
Id = id;
Value = value;
IsVisible = isVisible;
Description = description;
Hint = hint;
IsConditional = isConditional;
}

public ProjectStatusOption(string id, API.Contracts.Project.ProjectStatus value, bool isVisible, string description, string hint,
public ProjectStatusOption(string id, API.Contracts.Project.ProjectStatus value, string description, string hint,
bool isConditional, string dateInputId, string dateInputName, string dateInputLabel,
string dateInputHint, DateTime? dateInputValueAspFor) : this(id, value, isVisible, description, hint, isConditional)
string dateInputHint, DateTime? dateInputValueAspFor) : this(id, value, description, hint, isConditional)
{
DateInputId = dateInputId;
DateInputName = dateInputName;
Expand Down

0 comments on commit 2cd3098

Please sign in to comment.