From 6c2bdf198ea6e9c6e4c36f6a45393e1ebf671864 Mon Sep 17 00:00:00 2001 From: Gary Dawson Date: Tue, 28 Apr 2026 12:04:06 +0100 Subject: [PATCH 1/2] Added more environments and updated ReadMe --- e2e/README.md | 23 +++++++++++++++-------- e2e/environments.js | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/e2e/README.md b/e2e/README.md index 9479cce0..6a27d138 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -77,14 +77,13 @@ All Playwright locator logic lives here. Tests never call `page.getByRole(...)` | Method | Description | |--------|-------------| -| `clearPdfFiles()` | Remove previously generated PDFs from `_results_/downloads` | -| `waitForDownload(triggerDownload, timeout)` | Wait for a PDF via browser download event or PDF response capture | +| `awaitDownload(timeout)` | Wait for a PDF download event, save to `_results_/downloads`, and return the file path | | `parsePdf(filePath)` | Parse PDF text and links using `pdf-parse` | +| `expectPdfContent(pdf, { reference, scale, floodZone, polygon, expectedLinks })` | Validate all PDF content: core text, flood zone, location, and links | | `expectCoreContent(pdf, { reference, scale })` | Validate core report text, reference handling, and scale formatting | | `expectFloodZone(pdf, floodZone)` | Validate zone text in PDF matches expected flood zone | | `expectLocation(pdf, polygonString)` | Validate centroid easting/northing rendered in PDF | -| `expectRequiredLinks(pdf, expectedLinks)` | Validate required static links are embedded in PDF | -| `expectAllLinksAreValid(pdf)` | Validate extracted links are syntactically valid URLs | +| `expectLinks(pdf, expectedLinks)` | Validate required links are present and all extracted links are valid URLs | ### Page Objects (`pages/`) @@ -184,9 +183,7 @@ npx playwright install # all browsers, or pick one as above PDF tests generate files in `_results_/downloads/`. -- The folder is cleared once at the start of the PDF suite. -- Files generated during that run are retained (for example, 6 PDF tests produce 6 PDFs). -- On the next run, the folder is cleared again before new PDF files are created. +- PDF files accumulate across runs — they are not cleared automatically. - Generated PDFs are ignored by git (`e2e/_results_/downloads/*.pdf`), so they are not committed. ## Docker (WIP) @@ -216,6 +213,10 @@ Set the target environment with `TEST_ENV`. Defaults to `tst` locally and `local | local | `TEST_ENV=local` | `http://localhost:8050` | `http://localhost:8050` | | dev | `TEST_ENV=dev` | `https://fmp2-dev.aws-int.defra.cloud/` | `https://fmp2-internal-dev.aws-int.defra.cloud/` | | tst | `TEST_ENV=tst` | `https://fmp2-tst.aws-int.defra.cloud/` | `https://fmp2-internal-tst.aws-int.defra.cloud/` | +| pre | `TEST_ENV=pre` | `https://fmp2-pre.aws.defra.cloud/` | `https://fmp2-internal-pre.aws-int.defra.cloud/` | +| prd-green | `TEST_ENV=prd-green` | `https://fmp2-prd-green.aws.defra.cloud/` | `https://fmp2-internal-prd-green.aws-int.defra.cloud/` | +| prd-blue | `TEST_ENV=prd-blue` | `https://fmp2-prd-blue.aws.defra.cloud/` | `https://fmp2-internal-prd-blue.aws-int.defra.cloud/` | +| prod | `TEST_ENV=prod` | `https://flood-map-for-planning.service.gov.uk/` | `https://fmp-internal.prd.defra.cloud/` | ### Projects @@ -275,6 +276,12 @@ npm run test:urlCheck npm run test:tst npm run test:dev +# Additional environments (run via TEST_ENV) +TEST_ENV=pre npm run test +TEST_ENV=prd-green npm run test +TEST_ENV=prd-blue npm run test +TEST_ENV=prod npm run test + # Other browsers npm run test:firefox npm run test:all-browsers @@ -423,7 +430,7 @@ test('interacts with the map', async ({ steps, mapSteps }) => { | Problem | Solution | |---------|----------| -| `Unknown TEST_ENV "..."` | Set `TEST_ENV` to `local`, `dev`, or `tst` | +| `Unknown TEST_ENV "..."` | Set `TEST_ENV` to one of: `local`, `dev`, `tst`, `pre`, `prd-green`, `prd-blue`, `prod` | | `Missing base URL config` | Check `environments.js` has `baseUrl` and `internalBaseUrl` for the chosen environment | | Map test timeouts | Map interactions depend on tile loading — ensure the target environment is responsive | | Strict mode violation | A link's text matches multiple elements — update the page object to use the full exact link text | diff --git a/e2e/environments.js b/e2e/environments.js index bc15f6a6..3ac4b5f3 100644 --- a/e2e/environments.js +++ b/e2e/environments.js @@ -13,4 +13,20 @@ export const environments = { baseUrl: 'https://fmp2-tst.aws-int.defra.cloud/', internalBaseUrl: 'https://fmp2-internal-tst.aws-int.defra.cloud/', }, + pre: { + baseUrl: 'https://fmp2-pre.aws.defra.cloud/', + internalBaseUrl: 'https://fmp2-internal-pre.aws-int.defra.cloud/', + }, + 'prd-green': { + baseUrl: 'https://fmp2-prd-green.aws.defra.cloud/', + internalBaseUrl: 'https://fmp2-internal-prd-green.aws-int.defra.cloud/', + }, + 'prd-blue': { + baseUrl: 'https://fmp2-prd-blue.aws.defra.cloud/', + internalBaseUrl: 'https://fmp2-internal-prd-blue.aws-int.defra.cloud/', + }, + prod: { + baseUrl: 'https://flood-map-for-planning.service.gov.uk/', + internalBaseUrl: 'https://fmp-internal.prd.defra.cloud/', + }, } From b6e8e725d4c07dc3425031d56de9b9b015b7f081 Mon Sep 17 00:00:00 2001 From: Gary Dawson Date: Tue, 28 Apr 2026 12:20:31 +0100 Subject: [PATCH 2/2] Added test runner scripts to package json and updated to E2E only runs against PRE --- e2e/README.md | 11 ++++++----- e2e/package.json | 6 +++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/e2e/README.md b/e2e/README.md index 6a27d138..0ca682c0 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -275,12 +275,13 @@ npm run test:urlCheck # Other environments npm run test:tst npm run test:dev +npm run test:pre +npm run test:prd-green +npm run test:prd-blue +npm run test:prod -# Additional environments (run via TEST_ENV) -TEST_ENV=pre npm run test -TEST_ENV=prd-green npm run test -TEST_ENV=prd-blue npm run test -TEST_ENV=prod npm run test +# End-to-end journey test — always runs against the pre environment +npm run test:e2e # Other browsers npm run test:firefox diff --git a/e2e/package.json b/e2e/package.json index f12eb41e..0ee9a927 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -10,9 +10,13 @@ "test:local": "TEST_ENV=local npx playwright test --project=noDeps-local-chromium", "test:tst": "TEST_ENV=tst npm run test", "test:dev": "TEST_ENV=dev npm run test", + "test:pre": "TEST_ENV=pre npm run test", + "test:prd-green": "TEST_ENV=prd-green npm run test", + "test:prd-blue": "TEST_ENV=prd-blue npm run test", + "test:prod": "TEST_ENV=prod npm run test", "test:edge": "npx playwright test --project=public-edge --project=internal-edge", "test:firefox": "npx playwright test --project=public-firefox --project=internal-firefox", - "test:e2e": "npx playwright test --project=e2e-public-chromium --project=e2e-internal-chromium", + "test:e2e": "TEST_ENV=pre npx playwright test --project=e2e-public-chromium --project=e2e-internal-chromium", "test:all-browsers": "npx playwright test", "report:open": "npx playwright show-report", "prepare": "husky"