Files
pedwfrontend/pwe2e/tests/loggedin/raiserep.spec.js
Robert Bond 478fa91004 Merged PR 2558: updated link on awaiting submission view allin welsh
updated link on awaiting submission view allin welsh

Related work items: #24389
2026-08-12 13:58:07 +00:00

730 lines
25 KiB
JavaScript

import { test, expect } from "@playwright/test";
import {
login,
loginAgent,
generatePlanningText,
loginLPA,
loginIP,
} from "../../helpers";
import path from "path";
const today = new Date();
// Add ordinal (st, nd, rd, th)
const day = today.getDate();
const ordinal = (n) => {
if (n > 3 && n < 21) return "th";
switch (n % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
};
const weekday = today.toLocaleDateString("en-GB", { weekday: "long" });
const month = today.toLocaleDateString("en-GB", { month: "long" });
const finalDate = `${weekday}, ${month} ${day}${ordinal(day)}`;
const finalCommentsCase = process.env.FINAL_COMMENTS;
const statementCase = process.env.STATEMENT;
const questionnaireCase = process.env.QUESTIONNAIRE;
const consultationCase = process.env.CONSULTATION;
test("Raise Final Comments representation as an Appellant", async ({
page,
}) => {
await login(page);
await page.getByRole("textbox", { name: "Use the case reference" }).click();
console.log("Value to fill:", finalCommentsCase);
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(finalCommentsCase);
await page.getByRole("button", { name: "Submit search" }).click();
// await page
// .getByRole("link", { name: "DNS3276735 - Gaerwen Wind Farm (test)" })
// .click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page.getByRole("link", { name: "Make representation" }).click();
await page.getByRole("radio", { name: "Appellant" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("radio", { name: "Final comments" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
await page
.getByRole("group")
.locator("div")
.filter({ hasText: "Please note that all" })
.locator("div")
.nth(3)
.fill("s");
await page
.locator("div")
.filter({ hasText: /^s$/ })
.nth(2)
.fill("some text to go here.....");
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise Final Comments representation as an Interested Party", async ({
page,
}) => {
await loginIP(page);
//raise rep
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(finalCommentsCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page.getByRole("link", { name: "Make representation" }).click();
await page.getByRole("radio", { name: "Interested Party" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("radio", { name: "Final comments" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("Yes").click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.fill("Big Company");
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
await page.locator(".ql-editor").fill(generatePlanningText(5));
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise Statement representation as an Interested Party", async ({
page,
}) => {
await loginIP(page);
//raise rep
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(statementCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page.getByRole("link", { name: "Make representation" }).click();
await page.getByRole("radio", { name: "Interested Party" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("radio", { name: "Statement" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("Yes").click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.fill("Big Company");
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
await page.locator(".ql-editor").fill(generatePlanningText(5));
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise Consultation Response as an Interested Party", async ({ page }) => {
await loginIP(page);
//raise rep
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(consultationCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page
.getByRole("link", { name: "Submit a Consultation Response" })
.click();
await page.getByRole("radio", { name: "Interested Party" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("radio", { name: "Consultation Response" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("Yes").click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.fill("Big Company");
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
await page.locator(".ql-editor").fill(generatePlanningText(5));
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise LIR as an Interested Party", async ({ page }) => {
await loginIP(page);
//raise rep
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(consultationCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page
.getByRole("link", { name: "Submit a Consultation Response" })
.click();
await page.getByRole("radio", { name: "Interested Party" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("radio", { name: "Local Impact Report" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("Yes").click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.fill("Big Company");
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise MIR as an Interested Party", async ({ page }) => {
await loginIP(page);
//raise rep
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(consultationCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page
.getByRole("link", { name: "Submit a Consultation Response" })
.click();
await page.getByRole("radio", { name: "Interested Party" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("radio", { name: "Marine Impact Report" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("Yes").click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.fill("Big Company");
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise Final Comments representation as an Agent", async ({ page }) => {
await loginAgent(page);
//raise rep
const acceptButton = page.getByRole("button", { name: "Accept cookies" });
if (await acceptButton.isVisible()) {
await acceptButton.click();
}
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(finalCommentsCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page.getByRole("link", { name: "Make representation" }).click();
await page.getByRole("radio", { name: "Agent" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("radio", { name: "Final comments" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("Yes").click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.fill("Big Company");
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
await page.locator(".ql-editor").fill(generatePlanningText(4));
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise Statement representation as an Agent", async ({ page }) => {
await loginAgent(page);
//raise rep
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(statementCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page.getByRole("link", { name: "Make representation" }).click();
await page.getByRole("radio", { name: "Agent" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("radio", { name: "Statement" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("Yes").click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.click();
await page
.getByRole("textbox", { name: "Enter the name of the company" })
.fill("Big Company");
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
await page.locator(".ql-editor").fill(generatePlanningText(5));
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise questionnaire as an LPA", async ({ page }) => {
await loginLPA(page);
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(questionnaireCase);
await page.getByRole("textbox", { name: "Use the case reference," }).click();
await page
.getByRole("textbox", { name: "Use the case reference," })
.fill(questionnaireCase);
await page.getByRole("button", { name: "Submit Search" }).click();
await page.getByRole("link", { name: questionnaireCase }).click();
// await page.getByRole("button", { name: "Submit search" }).click();
//await page.locator("dd a.govuk-link--no-underline").first().click();
await page.getByRole("link", { name: "Make representation" }).click();
await page.getByRole("radio", { name: "Questionnaire" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("combobox").selectOption("Written representations");
await page.getByText("No").first().click();
await page.getByText("No").nth(1).click();
await page.getByText("No").nth(2).click();
await page.getByText("Yes").nth(2).click();
await page.getByText("No").nth(3).click();
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
// await page.locator(".ql-editor").fill(generatePlanningText(2));
// await page
// .locator("div")
// .filter({ hasText: /^w$/ })
// .nth(2)
// .fill(generatePlanningText(2));
await page.getByRole("button", { name: "Continue" }).click();
await page.locator(".ql-editor").first().fill(generatePlanningText(2));
await page.locator(".ql-editor").nth(1).fill(generatePlanningText(2));
await page.locator(".ql-editor").nth(2).fill(generatePlanningText(2));
// // await page.getByRole("paragraph").nth(4).click();
// await page
// .locator(".ql-editor.ql-blank")
// .first()
// .fill(generatePlanningText(2));
// await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
// await page
// .locator(".ql-editor.ql-blank")
// .first()
// .fill(generatePlanningText(2));
// await page.locator(".ql-editor.ql-blank").fill("w e");
// await page
// .locator("div")
// .filter({ hasText: /^w e$/ })
// .nth(2)
// .fill(generatePlanningText(2));
// await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
// await page
// .locator("div")
// .filter({ hasText: /^w e$/ })
// .nth(2)
// .fill(generatePlanningText(2));
await page.getByText("No", { exact: true }).first().click();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("No").first().click();
await page.getByText("No").nth(1).click();
await page.getByText("No").nth(2).click();
await page.getByText("No").nth(3).click();
await page.getByText("No").nth(4).click();
await page.getByText("No").nth(5).click();
await page
.locator(
"div:nth-child(8) > .govuk-form-group > .govuk-fieldset > .govuk-radios > div:nth-child(2) > .govuk-radios__item > .govuk-label",
)
.click();
await page
.locator(
"div:nth-child(9) > .govuk-fieldset > .govuk-radios > div:nth-child(2) > .govuk-label",
)
.click();
await page
.locator(
"div:nth-child(10) > .govuk-form-group > .govuk-fieldset > .govuk-radios > div:nth-child(2) > .govuk-radios__item > .govuk-label",
)
.click();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("No").nth(2).click();
await page.getByText("No").nth(3).click();
await page.getByText("No").nth(5).click();
await page.getByText("No", { exact: true }).nth(3).click();
await page.getByText("No", { exact: true }).nth(4).click();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("Yes").first().click();
await page.getByText("Yes").nth(1).click();
await page.getByText("No", { exact: true }).nth(2).click();
await page.getByText("Yes").nth(2).click();
await page.getByText("No", { exact: true }).nth(3).click();
await page.getByText("No", { exact: true }).nth(4).click();
await page.getByText("No", { exact: true }).nth(5).click();
await page
.locator(
"div:nth-child(9) > .govuk-form-group > .govuk-fieldset > .govuk-radios > div:nth-child(2) > .govuk-radios__item > .govuk-label",
)
.click();
await page
.locator(
"div:nth-child(10) > .govuk-form-group > .govuk-fieldset > .govuk-radios > div:nth-child(2) > .govuk-radios__item > .govuk-label",
)
.click();
await page.getByRole("button", { name: "Continue" }).click();
// await page.getByText("Drag and drop your files here").click();
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("textbox", { name: "Signed" }).click();
await page.getByRole("textbox", { name: "Signed" }).fill("Bob Bob");
await page.getByRole("textbox", { name: "Date" }).click();
await page.getByRole("option", { name: `Choose ${finalDate}` }).click();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByText("I wish to download a copy of").click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
const downloadPromise = page.waitForEvent("download");
await page.getByRole("button", { name: "Continue" }).click();
const download = await downloadPromise;
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise Statement representation as an LPA", async ({ page }) => {
await loginLPA(page);
//raise rep
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(statementCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page.getByRole("link", { name: "Make representation" }).click();
await page.getByRole("radio", { name: "Statement" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
await page.locator(".ql-editor").fill(generatePlanningText(5));
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Raise LIR as an LPA", async ({ page }) => {
await loginLPA(page);
//raise rep
await page.getByRole("textbox", { name: "Use the case reference" }).click();
await page
.getByRole("textbox", { name: "Use the case reference" })
.fill(consultationCase);
await page.getByRole("button", { name: "Submit search" }).click();
await page.locator("dd a.govuk-link--no-underline").first().click();
await page
.getByRole("link", { name: "Submit a Consultation Response" })
.click();
await page.getByRole("radio", { name: "Local Impact Report" }).check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("paragraph").filter({ hasText: /^$/ }).click();
await page.locator(".ql-editor").fill(generatePlanningText(5));
const files = [
path.resolve(__dirname, "../../testFiles/file1.pdf"),
path.resolve(__dirname, "../../testFiles/file2.pdf"),
];
const fileInput = page.locator("#representationDocuments");
await fileInput.setInputFiles(files);
const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" });
await expect(uploadedFiles).toBeVisible({ timeout: 60000 });
await page.getByRole("button", { name: "Continue" }).click();
await page
.getByRole("checkbox", { name: "I confirm I have read the" })
.check();
await page.getByRole("button", { name: "Continue" }).click();
await page.getByRole("link", { name: "Continue" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});
test("Open Saved Rep as an Interested Party", async ({ page }) => {
await loginIP(page);
//raise rep
const firstCaseLink = page
.locator("#my-representations-card .govuk-link--no-underline")
.first();
await firstCaseLink.click();
await page.getByRole("button", { name: "Save and exit" }).click();
await page.goto("/");
await page.waitForTimeout(2000);
});