Skip to content

Commit

Permalink
test[e2e]: add filter and internal portal into create flow test (#3739)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamdelion authored Oct 1, 2024
1 parent 916f89d commit 660654b
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 12 deletions.
12 changes: 9 additions & 3 deletions doc/how-to/how-to-setup-aws-sso-credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ This document describes the process of setting up credentials for your local AWS
## Process
As part of onboarding, you should be set up to access AWS via [the SSO portal](https://opensystemslab.awsapps.com/start#/). Please ensure that you have set up and enabled MFA.

1. Download the AWS CLI
1. Run `aws configure sso` - the required details can be found via the SSO portal
1. For the "profile" field please use the format `planx-<STACK>`, e.g. `planx-staging`
1. Download the AWS CLI - see https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
1. Run `aws configure sso` - some of the required details can be found via [the SSO portal](https://opensystemslab.awsapps.com/start#/) in the 'Access keys' section:
- e.g. `SSO start URL` and `SSO Region` are listed under `AWS IAM Identity Center credentials (Recommended)`.
- `SSO registration scopes` can be left as the default (`sso:account:access`).
1. Allow access from the authorisation page that should open in your browser.
1. You should be prompted for more details in the terminal:
- `CLI default client region` should be `eu-west-2`
- `CLI default output format` should be `json`
- For the `CLI profile name` field, please use the format `planx-<STACK>`, e.g. `planx-staging`
1. Repeat for all environments (staging, production)
1. Test! You should be able to call commands using the CLI, for example `aws sts get-caller-identity --profile planx-staging` and get the expected result.

Expand Down
14 changes: 14 additions & 0 deletions e2e/tests/ui-driven/src/create-flow-with-geospatial.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ test.describe("Flow creation, publish and preview", () => {
context.flow = { ...serviceProps };

await editor.createFindProperty();
await expect(editor.nodeList).toContainText(["Find property"]);
await editor.createInternalPortal();
await editor.populateInternalPortal();
await page.getByRole("link", { name: "start" }).click(); // return to main flow
await editor.createFilter();
await editor.createUploadAndLabel();
// TODO: editor.createPropertyInfo()
await editor.createDrawBoundary();
Expand All @@ -56,6 +61,8 @@ test.describe("Flow creation, publish and preview", () => {

await expect(editor.nodeList).toContainText([
"Find property",
"an internal portalEdit Portal",
"(Flags Filter)ImmuneMissing informationPermission neededPrior approvalNoticePermitted developmentNot development(No Result)",
"Upload and label",
"Confirm your location plan",
"Planning constraints",
Expand Down Expand Up @@ -106,6 +113,13 @@ test.describe("Flow creation, publish and preview", () => {
).toBeVisible();
await answerFindProperty(page);
await clickContinue({ page });

await expect(
page.locator("h1", { hasText: "A notice inside a portal!" }),
).toBeVisible();
await clickContinue({ page });

// TODO: answer filter?
// TODO: answer uploadAndLabel
// TODO: answerPropertyInfo, answerDrawBoundary, answerPlanningConstraints
});
Expand Down
18 changes: 10 additions & 8 deletions e2e/tests/ui-driven/src/create-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getTeamPage } from "./helpers/getPage";
import { createAuthenticatedSession } from "./helpers/globalHelpers";
import {
answerAddressInput,
answerChecklist,
answerContactInput,
answerDateInput,
answerListInput,
Expand Down Expand Up @@ -59,7 +60,7 @@ test.describe("Flow creation, publish and preview", () => {

await editor.createQuestion();
await editor.createNoticeOnEachBranch();
// await editor.createChecklist();
await editor.createChecklist();
await editor.createTextInput();
await editor.createNumberInput();
await editor.createDateInput();
Expand All @@ -68,6 +69,7 @@ test.describe("Flow creation, publish and preview", () => {
await editor.createList();
await editor.createTaskList();
await editor.createContent();

await editor.createResult();
await editor.createNextSteps();
await editor.createReview();
Expand All @@ -77,7 +79,7 @@ test.describe("Flow creation, publish and preview", () => {
"Is this a test?",
"Yes! this is a test",
"Sorry, this is a test",
// "Checklist item 1",
"Checklist item 1",
"Tell us about your trees.",
"How old are you?",
"When is your birthday?",
Expand Down Expand Up @@ -202,12 +204,12 @@ test.describe("Flow creation, publish and preview", () => {
).toBeVisible();
await clickContinue({ page });

// await answerChecklist({
// page,
// title: "A checklist title",
// answers: ["Checklist item 1", "Second checklist item"],
// });
// await clickContinue({ page });
await answerChecklist({
page,
title: "A checklist title",
answers: ["Checklist item 1", "Second checklist item"],
});
await clickContinue({ page });

await answerTextInput(page, {
expectedQuestion: "Tell us about your trees.",
Expand Down
23 changes: 22 additions & 1 deletion e2e/tests/ui-driven/src/helpers/addComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ const createBaseComponent = async (
await page
.locator("p[data-placeholder='Content']")
.fill(options?.[0] || "");

break;
case ComponentType.Filter:
break;
case ComponentType.InternalPortal:
await page.getByPlaceholder("Portal name").fill(title || "");
break;
default:
throw new Error(`Unsupported type: ${type}`);
Expand Down Expand Up @@ -365,3 +369,20 @@ export const createContent = async (
[content],
);
};

export const createFilter = async (page: Page, locatingNode: Locator) => {
await createBaseComponent(page, locatingNode, ComponentType.Filter);
};

export const createInternalPortal = async (
page: Page,
locatingNode: Locator,
portalName: string,
) => {
await createBaseComponent(
page,
locatingNode,
ComponentType.InternalPortal,
portalName,
);
};
35 changes: 35 additions & 0 deletions e2e/tests/ui-driven/src/pages/Editor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ComponentType } from "@opensystemslab/planx-core/types";

import { expect, type Locator, type Page } from "@playwright/test";
import {
createAddressInput,
Expand All @@ -8,7 +10,9 @@ import {
createDateInput,
createDrawBoundary,
createFileUpload,
createFilter,
createFindProperty,
createInternalPortal,
createList,
createNextSteps,
createNotice,
Expand Down Expand Up @@ -44,6 +48,7 @@ export class PlaywrightEditor {
this.yesBranch = page.locator("#flow .card .options .option").nth(0);
this.noBranch = page.locator("#flow .card .options .option").nth(1);
this.nodeList = page.locator(".card");

this.answers = {
questionText: "Is this a test?",
yesBranchNoticeText: "Yes! this is a test",
Expand Down Expand Up @@ -205,4 +210,34 @@ export class PlaywrightEditor {
async createContent() {
await createContent(this.page, this.getNextNode(), "Some content");
}

async createFilter() {
await createFilter(this.page, this.getNextNode());
}

async createInternalPortal() {
await createInternalPortal(
this.page,
this.getNextNode(),
"an internal portal",
);
}

async populateInternalPortal() {
const internalPortalButton = this.page.getByRole("link", {
name: "an internal portal",
});
await internalPortalButton.click();

// create a notice inside the portal
await this.page.locator(".hanger > a").last().click();
await this.page.getByRole("dialog").waitFor();
await this.page
.locator("select")
.selectOption({ value: ComponentType.Notice.toString() });
await this.page
.getByPlaceholder("Notice")
.fill("A notice inside a portal!");
await this.page.locator('button[form="modal"][type="submit"]').click();
}
}

0 comments on commit 660654b

Please sign in to comment.