Skip to content

Commit

Permalink
switch filter and check for automations
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Dec 3, 2024
1 parent 4a33bb7 commit fd9f618
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
16 changes: 14 additions & 2 deletions e2e/tests/ui-driven/src/create-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 });

Expand Down
6 changes: 6 additions & 0 deletions e2e/tests/ui-driven/src/helpers/addComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 (
Expand Down
5 changes: 4 additions & 1 deletion e2e/tests/ui-driven/src/helpers/globalHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
// @ts-expect-error - Property api does not exist on type Window & typeof globalThis
Expand Down
12 changes: 12 additions & 0 deletions e2e/tests/ui-driven/src/pages/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
createTextInput,
createUploadAndLabel,
} from "../helpers/addComponent";
import { selectedFlag } from "../helpers/globalHelpers";

export class PlaywrightEditor {
readonly page: Page;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit fd9f618

Please sign in to comment.