diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/api/domain.ts b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/api/domain.ts index b385be31a..3338e997f 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/api/domain.ts +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/api/domain.ts @@ -80,6 +80,13 @@ export type CreatePDGGrantLettersRequest = finalGrantLetterSavedToWorkplaces: boolean } +export type CreatePDGGrantVariationLetterRequest = +{ + variation: number, + letterDate: string, + savedToWorkplacesFolder: boolean +} + export type ProjectRiskEntryRequest = { riskRating?: number; summary?: string; diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/api/grantVariationLetterApi.ts b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/api/grantVariationLetterApi.ts new file mode 100644 index 000000000..9860212eb --- /dev/null +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/api/grantVariationLetterApi.ts @@ -0,0 +1,24 @@ +import { ApiClient } from "./apiClient"; +import { CreatePDGGrantVariationLetterRequest, ResponseWrapper } from "./domain"; + +class GrantVariationLetterApi { + public constructor(private readonly apiClient: ApiClient) { } + + public put( + projectId: string, + request: CreatePDGGrantVariationLetterRequest, + ): Cypress.Chainable { + return this.apiClient + .put>( + `/api/v1/client/projects/${projectId}/grant-letters/variation-letter`, + request, + ) + .then((response) => { + return response.data; + }); + } +} + +const grantVariationLetterApi = new GrantVariationLetterApi(new ApiClient()); + +export default grantVariationLetterApi; \ No newline at end of file diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/tasks/project-development-grant-central/without-permission.cy.ts b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/tasks/project-development-grant-central/without-permission.cy.ts index 2afc8192f..fabcddb4e 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/tasks/project-development-grant-central/without-permission.cy.ts +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/tasks/project-development-grant-central/without-permission.cy.ts @@ -1,5 +1,6 @@ -import { CreatePDGGrantLettersRequest, CreatePDGPaymentScheduleRequest, ProjectDetailsRequest } from "cypress/api/domain"; +import { CreatePDGGrantLettersRequest, CreatePDGGrantVariationLetterRequest, CreatePDGPaymentScheduleRequest, ProjectDetailsRequest } from "cypress/api/domain"; import grantLettersApi from "cypress/api/grantLettersApi"; +import grantVariationLetterApi from "cypress/api/grantVariationLetterApi"; import paymentScheduleApi from "cypress/api/paymentScheduleApi"; import projectApi from "cypress/api/projectApi"; import { RequestBuilder } from "cypress/api/requestBuilder"; @@ -31,7 +32,7 @@ describe("View PDG dashboard", () => { it("Should hide all links", () => { cy.log("Select Project development grant (PDG)"); - taskListPage.isTaskStatusIsNotStarted("PDG") + taskListPage.isTaskStatusHidden("PDG") .selectPDGFromTaskList(); cy.log("Confirm empty dashboard"); @@ -51,7 +52,7 @@ describe("View PDG dashboard", () => { summaryPage.clickBack(); - taskListPage.isTaskStatusIsNotStarted("PDG") + taskListPage.isTaskStatusHidden("PDG") cy.executeAccessibilityTests(); @@ -83,6 +84,15 @@ describe("View PDG dashboard", () => { finalGrantLetterSavedToWorkplaces : true } + const grantVariationLetter : CreatePDGGrantVariationLetterRequest = + { + variation: 1, + letterDate: "2024-01-01T00:00:00.000Z", + savedToWorkplacesFolder: true + } + + + projectApi .post({ projects: [project], @@ -94,6 +104,9 @@ describe("View PDG dashboard", () => { { grantLettersApi.put(project.projectId, grantLetter) }) + .then(() => { + grantVariationLetterApi.put(project.projectId, grantVariationLetter) + }) .then(() => { cy.visit(`/projects/${project.projectId}/tasks/`); }); @@ -102,7 +115,7 @@ describe("View PDG dashboard", () => { it("Should hide most links but allow Payment schedule and Grant letters to be viewed read-only", () => { cy.log("Select Project development grant (PDG)"); - taskListPage.isTaskStatusIsNotStarted("PDG") + taskListPage.isTaskStatusHidden("PDG") .selectPDGFromTaskList(); cy.log("Confirm empty dashboard"); @@ -144,14 +157,13 @@ describe("View PDG dashboard", () => { .grantTitleIs("Grant letters") .schoolNameIs(project.schoolName) .addGrantLetterNotShown() + .changeGrantLetterNotShown() .changeVariationLetterNotShown("1") - .changeVariationLetterNotShown("2") - .changeVariationLetterNotShown("3") .clickBack() summaryPage.clickBack(); - taskListPage.isTaskStatusIsNotStarted("PDG") + taskListPage.isTaskStatusHidden("PDG") cy.executeAccessibilityTests(); diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/tasks/project-development-grant-presumption/without-permission.cy.ts b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/tasks/project-development-grant-presumption/without-permission.cy.ts index a79924018..fd504910b 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/tasks/project-development-grant-presumption/without-permission.cy.ts +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/e2e/tasks/project-development-grant-presumption/without-permission.cy.ts @@ -26,7 +26,7 @@ describe("Payment Schedule Task", () => { it("Should successfully set payment schedule", () => { cy.log("Select Project development grant (PDG)"); - taskListPage.isTaskStatusIsNotStarted("PDG") + taskListPage.isTaskStatusHidden("PDG") .selectPDGFromTaskList(); cy.log("Confirm empty dashboard"); @@ -45,7 +45,7 @@ describe("Payment Schedule Task", () => { summaryPage.clickBack(); - taskListPage.isTaskStatusIsNotStarted("PDG") + taskListPage.isTaskStatusHidden("PDG") cy.executeAccessibilityTests(); diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/pages/taskListPage.ts b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/pages/taskListPage.ts index 0c6e8b6c7..29fd0b293 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/pages/taskListPage.ts +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/pages/taskListPage.ts @@ -212,6 +212,11 @@ class TaskListPage { return this; } + public isTaskStatusHidden(taskName: string): this { + cy.get(`[data-testid="task-${taskName}-status"]`).should("not.exist"); + return this; + } + private getDraftGovernancePlanTask() { return cy.getByTestId("GovernancePlan-task"); } diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/pages/tasks/project-development-grant-central/edit-grant-letter.ts b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/pages/tasks/project-development-grant-central/edit-grant-letter.ts index 1a53b2cf6..80afed5f9 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/pages/tasks/project-development-grant-central/edit-grant-letter.ts +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/pages/tasks/project-development-grant-central/edit-grant-letter.ts @@ -32,6 +32,11 @@ class editGrantLetter { return this; } + public changeGrantLetterNotShown(): this { + cy.getByTestId(`change-grant-letter`).should("not.exist"); + return this; + } + public withTrustLetterDate(day: string, month: string, year: string): this { const key = "trust-letter-date"; this.setDate(key, day, month, year); diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Project/Tasks/PDG/Central/EditPDGGrantLetters.cshtml b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Project/Tasks/PDG/Central/EditPDGGrantLetters.cshtml index 61f4df81a..018693401 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Project/Tasks/PDG/Central/EditPDGGrantLetters.cshtml +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Project/Tasks/PDG/Central/EditPDGGrantLetters.cshtml @@ -10,7 +10,7 @@ var pageTitle = userAuthorisedToChange ? "Edit Grant letters" : "Grant letters"; ViewData["Title"] = $"{pageTitle} - {Model.CurrentFreeSchoolName}"; var backLink = string.Format(RouteConstants.ViewPDGCentral, Model.ProjectId); - var editGrantLetterLink = string.Format(RouteConstants.EditPDGGrantLetter, Model.ProjectId); + var editGrantLetterLink = userAuthorisedToChange ? string.Format(RouteConstants.EditPDGGrantLetter, Model.ProjectId) : ""; var grantLetters = Model.GrantLetters; var initialGrantLetterSavedToWorkplaces = grantLetters?.InitialGrantLetterSavedToWorkplaces == true ? "Yes" : "No"; @@ -82,7 +82,7 @@ if (grantLetter.LetterDate != null || grantLetter.SavedToWorkplacesFolder != null) { - var editVariationLetterLink = string.Format(RouteConstants.EditPDGVariationLetter, Model.ProjectId, variation); + var editVariationLetterLink = userAuthorisedToChange ? string.Format(RouteConstants.EditPDGVariationLetter, Model.ProjectId, variation) : ""; var grantLetterSavedToWorkplaces = grantLetter.SavedToWorkplacesFolder == true ? "Yes" : "No"; diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Project/Tasks/TaskList.cshtml b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Project/Tasks/TaskList.cshtml index 0ef9dd8c0..affaafada 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Project/Tasks/TaskList.cshtml +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Project/Tasks/TaskList.cshtml @@ -51,6 +51,8 @@ var pdgLink = (@Model.ProjectType == "Presumption") ? pdgPresumptionLink : pdgCentralLink; var governancePlanLink = (@Model.ProjectType == "Presumption") ? governancePlanPresumptionLink : governancePlanCentralLink; + var userAuthorisedToChangePDG = User.IsInRole(RolesConstants.GrantManagers); + ViewData["Title"] = $"{Model.SchoolName} - Task list"; } @@ -126,7 +128,7 @@

Reference numbers

-

(This part is editable by the School Places Analysis team only)

+
Only the School Places Analysis team should complete this task.
@@ -134,9 +136,9 @@

Project development grant (PDG)

-

(This part is editable by Grant Management and Finance Unit only)

+
Only the Grant Management and Finance Unit can complete this task.

diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Shared/_TaskSummaryItem.cshtml b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Shared/_TaskSummaryItem.cshtml index 6462d3606..584edd59e 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Shared/_TaskSummaryItem.cshtml +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/Pages/Shared/_TaskSummaryItem.cshtml @@ -9,7 +9,10 @@ @{ - RenderStatus(Model.TaskSummary); + if(!@Model.HideStatus) + { + RenderStatus(Model.TaskSummary); + } } diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/TagHelpers/TaskSummaryItemTagHelper.cs b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/TagHelpers/TaskSummaryItemTagHelper.cs index e790f5e30..12c2db7a4 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/TagHelpers/TaskSummaryItemTagHelper.cs +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/TagHelpers/TaskSummaryItemTagHelper.cs @@ -19,6 +19,9 @@ public class TaskSummaryItemTagHelper : TagHelper [HtmlAttributeName("label")] public string Label { get; set; } + [HtmlAttributeName("hide-status")] + public bool HideStatus { get; set; } + [ViewContext] public ViewContext ViewContext { get; set; } @@ -38,7 +41,8 @@ public async override void Process(TagHelperContext context, TagHelperOutput out { TaskSummary = For.Model as TaskSummaryResponse, Href = Href, - Label = Label + Label = Label, + HideStatus = HideStatus }; if (model.TaskSummary.IsHidden) @@ -62,5 +66,7 @@ public record TaskSummaryItemViewModel public string Href { get; set; } public string Label { get; set; } + + public bool HideStatus { get; set; } = false; } }