Skip to content

Commit

Permalink
Merge pull request #900 from DFE-Digital/feature/178509
Browse files Browse the repository at this point in the history
Updated change links, hidden task status and updated tests
  • Loading branch information
sukhybhullar-nimble authored Oct 11, 2024
2 parents b41a54b + 579d397 commit 243d6e3
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<CreatePDGGrantVariationLetterRequest, ResponseWrapper<never>>(
`/api/v1/client/projects/${projectId}/grant-letters/variation-letter`,
request,
)
.then((response) => {
return response.data;
});
}
}

const grantVariationLetterApi = new GrantVariationLetterApi(new ApiClient());

export default grantVariationLetterApi;
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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");
Expand All @@ -51,7 +52,7 @@ describe("View PDG dashboard", () => {

summaryPage.clickBack();

taskListPage.isTaskStatusIsNotStarted("PDG")
taskListPage.isTaskStatusHidden("PDG")

cy.executeAccessibilityTests();

Expand Down Expand Up @@ -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],
Expand All @@ -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/`);
});
Expand All @@ -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");
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -45,7 +45,7 @@ describe("Payment Schedule Task", () => {

summaryPage.clickBack();

taskListPage.isTaskStatusIsNotStarted("PDG")
taskListPage.isTaskStatusHidden("PDG")

cy.executeAccessibilityTests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down Expand Up @@ -126,17 +128,17 @@
<h2 class="app-task-list__section">
Reference numbers
</h2>
<p>(This part is editable by the School Places Analysis team only)</p>
<div class ="govuk-inset-text">Only the School Places Analysis team should complete this task.</div>
<ul class="app-task-list__items">
<govuk-task-summary-item asp-for="@Model.ProjectTaskListSummary.ReferenceNumbers" href="@referenceNumbersTaskLink" label="Reference numbers" />
</ul>

<h2 class="app-task-list__section">
Project development grant (PDG)
</h2>
<p>(This part is editable by Grant Management and Finance Unit only)</p>
<div class="govuk-inset-text">Only the Grant Management and Finance Unit can complete this task.</div>
<ul class="app-task-list__items">
<govuk-task-summary-item asp-for="@Model.ProjectTaskListSummary.PDG" href="@pdgLink" label="Project development grant (PDG)" />
<govuk-task-summary-item asp-for="@Model.ProjectTaskListSummary.PDG" href="@pdgLink" label="Project development grant (PDG)" hide-status="@(!userAuthorisedToChangePDG)" />
</ul>

<h2 class="app-task-list__section">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
</a>
</span>
@{
RenderStatus(Model.TaskSummary);
if(!@Model.HideStatus)
{
RenderStatus(Model.TaskSummary);
}
}
</li>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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)
Expand All @@ -62,5 +66,7 @@ public record TaskSummaryItemViewModel
public string Href { get; set; }

public string Label { get; set; }

public bool HideStatus { get; set; } = false;
}
}

0 comments on commit 243d6e3

Please sign in to comment.