import { test, expect } from "@playwright/test"; import path from "path"; import { login } from "../../helpers"; const date = new Date(); date.setDate(date.getDate() - 1); // 👈 subtract 1 day const day = date.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 = date.toLocaleDateString("en-GB", { weekday: "long" }); const month = date.toLocaleDateString("en-GB", { month: "long" }); const finalDate = `${weekday}, ${month} ${day}${ordinal(day)}`; test("Login and Raise new appeal", async ({ page }) => { await login(page); // create new appeal await page.getByRole("link", { name: "Make a new appeal" }).click(); await page .getByRole("textbox", { name: "Appellant or organisation's" }) .click(); await page .getByRole("textbox", { name: "Appellant or organisation's" }) .fill("Bob"); await page.getByText("Appellant", { exact: true }).click(); await page.getByText("English").click(); await page.getByText("I confirm that I am making an").click(); await page.getByRole("button", { name: "Continue" }).click(); await page .getByLabel("Select your Local Planning") .selectOption("b9aee444-6ff0-eb11-aac7-00224800be9c"); await page.getByLabel("Select a case type").selectOption("846040000"); await page.getByRole("button", { name: "Continue" }).click(); await page.getByRole("button", { name: "Continue" }).click(); const step2 = page.locator('[aria-controls="step-panel-appeal-details"]'); await step2.click(); await page.getByRole("textbox", { name: "Development description" }).click(); await page .getByRole("textbox", { name: "Development description" }) .fill("Something in here"); await page.getByText("No", { exact: true }).click(); await page .getByRole("textbox", { name: "LPA's application reference" }) .click(); await page .getByRole("textbox", { name: "LPA's application reference" }) .fill("AB1234"); await page.getByRole("textbox", { name: "Application form dated" }).click(); await page.getByRole("option", { name: `Choose ${finalDate}` }).click(); await page.getByLabel("Reason for appeal").selectOption("846040005"); await page.getByRole("textbox", { name: "Site address line 1" }).click(); await page .getByRole("textbox", { name: "Site address line 1" }) .fill("1 High Road"); await page.getByRole("textbox", { name: "Site address line 1" }).press("Tab"); await page.getByRole("textbox", { name: "Site address line 2" }).press("Tab"); await page .getByRole("textbox", { name: "Site address town" }) .fill("Big town"); await page.getByRole("textbox", { name: "Site address town" }).press("Tab"); await page .getByRole("textbox", { name: "Site address county" }) .fill("Cardiff"); await page.getByRole("textbox", { name: "Site address county" }).press("Tab"); await page .getByRole("textbox", { name: "Site address postcode" }) .fill("cf21 3qa"); await page .getByRole("textbox", { name: "Site address postcode" }) .press("Tab"); await page .getByRole("textbox", { name: "Size of overall appeal site (" }) .fill("1"); await page .getByRole("textbox", { name: "Size of overall appeal site (" }) .press("Tab"); await page .getByRole("textbox", { name: "What is the area of floor" }) .fill("1"); await page .getByRole("textbox", { name: "What is the area of floor" }) .press("Tab"); await page.getByRole("button", { name: "Continue" }).click(); await page.getByText("Certificate A - (for sole").click(); await page.getByText("(a) None of the land to which").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.getByRole("button", { name: "Continue" }).click(); await page.getByText("No").first().click(); await page.getByRole("button", { name: "Continue" }).click(); // await page // .getByRole("paragraph") // .filter({ hasText: /^$/ }) // .click(); await page.locator(".ql-editor").fill("something here"); await page.getByText("No").nth(1).click(); await page .getByLabel("What procedure would you like") .selectOption("846040000"); await page.getByText("No").nth(3).click(); await page.getByText("No").nth(4).click(); await page.getByText("YesNo").nth(2).click(); await page.getByRole("button", { name: "Continue" }).click(); // upload files to statement of case const files = [ path.resolve(__dirname, "../../testFiles/file1.pdf"), path.resolve(__dirname, "../../testFiles/file2.pdf"), ]; const fileInput = page.locator("#pinswg_fileUpload"); await fileInput.setInputFiles(files); const uploadedFiles = page.locator("h4", { hasText: "Uploaded files" }); await expect(uploadedFiles).toBeVisible({ timeout: 60000 }); await page.getByRole("button", { name: "Submit" }).click(); await page .getByRole("checkbox", { name: "I wish to download a copy of the form" }) .check(); await page .getByRole("checkbox", { name: "I confirm that all sections" }) .check(); await page.getByText("Submit appeal").click(); await page.getByRole("link", { name: "Home" }).click(); await page.goto("/"); await page.waitForTimeout(20000); });