diff --git a/e2e/tests/ui-driven/src/create-flow.spec.ts b/e2e/tests/ui-driven/src/create-flow.spec.ts index 1774704a6b..6fcfc002c7 100644 --- a/e2e/tests/ui-driven/src/create-flow.spec.ts +++ b/e2e/tests/ui-driven/src/create-flow.spec.ts @@ -5,7 +5,11 @@ import { tearDownTestContext, } from "./helpers/context"; import { getTeamPage } from "./helpers/getPage"; -import { createAuthenticatedSession, planningPermissionFlags } from "./helpers/globalHelpers"; +import { + createAuthenticatedSession, + filterFlags, + selectedFlag, +} from "./helpers/globalHelpers"; import { answerAddressInput, answerChecklist, @@ -99,7 +103,7 @@ test.describe("Flow creation, publish and preview", () => { "A list title", "What you should do next", "Some content", - ...planningPermissionFlags, + ...filterFlags, "Planning permission", // default result flag "Next steps", "Check your answers before sending your application", @@ -337,6 +341,14 @@ test.describe("Flow creation, publish and preview", () => { await expect(page.locator("p", { hasText: "Some content" })).toBeVisible(); await clickContinue({ page }); + // this is the content placed in the permission needed branch + await expect( + page.locator("p", { + hasText: `This is the ${selectedFlag.toLowerCase()} filter`, + }), + ).toBeVisible(); + await clickContinue({ page }); + await expect(page.locator("h1", { hasText: "No result" })).toBeVisible(); await clickContinue({ page }); diff --git a/e2e/tests/ui-driven/src/helpers/addComponent.ts b/e2e/tests/ui-driven/src/helpers/addComponent.ts index a54336c18f..d2f3d8cac5 100644 --- a/e2e/tests/ui-driven/src/helpers/addComponent.ts +++ b/e2e/tests/ui-driven/src/helpers/addComponent.ts @@ -2,6 +2,7 @@ import { ComponentType } from "@opensystemslab/planx-core/types"; import { expect, Locator, Page } from "@playwright/test"; import { contextDefaults } from "./context"; import { externalPortalServiceProps } from "./serviceData"; +import { selectedFlag } from "./globalHelpers"; const createBaseComponent = async ( page: Page, @@ -119,6 +120,9 @@ const createBaseComponent = async ( .fill(options?.[0] || ""); break; case ComponentType.Filter: + await page + .getByTestId("flagset-category-select") + .selectOption(selectedFlag); break; case ComponentType.Feedback: break; @@ -330,6 +334,8 @@ async function createComponentOptions( await page.getByPlaceholder("Option").nth(index).fill(option); index++; } + await page.getByPlaceholder("Flags (up to one per category)").nth(1).click(); + await page.getByRole("option", { name: selectedFlag, exact: true }).click(); } export const createList = async ( diff --git a/e2e/tests/ui-driven/src/helpers/globalHelpers.ts b/e2e/tests/ui-driven/src/helpers/globalHelpers.ts index 55236be4ed..ec39631eae 100644 --- a/e2e/tests/ui-driven/src/helpers/globalHelpers.ts +++ b/e2e/tests/ui-driven/src/helpers/globalHelpers.ts @@ -81,7 +81,10 @@ export async function setFeatureFlag(page: Page, featureFlag: string) { ); } -export const planningPermissionFlags = flatFlags.filter((flag) => flag.category === "Planning permission").map((flag) => flag.text) +export const selectedFlag = "Material change of use"; +export const filterFlags = flatFlags + .filter((flag) => flag.category === selectedFlag) + .map((flag) => flag.text); export async function getSessionId(page: Page): Promise { // @ts-expect-error - Property api does not exist on type Window & typeof globalThis diff --git a/e2e/tests/ui-driven/src/pages/Editor.ts b/e2e/tests/ui-driven/src/pages/Editor.ts index d19ae67146..e4c27cb9a7 100644 --- a/e2e/tests/ui-driven/src/pages/Editor.ts +++ b/e2e/tests/ui-driven/src/pages/Editor.ts @@ -27,6 +27,7 @@ import { createTextInput, createUploadAndLabel, } from "../helpers/addComponent"; +import { selectedFlag } from "../helpers/globalHelpers"; export class PlaywrightEditor { readonly page: Page; @@ -222,6 +223,17 @@ export class PlaywrightEditor { async createFilter() { await createFilter(this.page, this.getNextNode()); + // select the branch filter and add some content + const permissionNeededNode = this.page + .locator("li") + .filter({ hasText: /Material change of use$/ }) + .getByRole("listitem") + .getByRole("link"); + await createContent( + this.page, + permissionNeededNode, + `This is the ${selectedFlag.toLowerCase()} filter`, + ); } async createInternalPortal() {