diff --git a/e2e/tests/ui-driven/src/create-flow/create-flow.spec.ts b/e2e/tests/ui-driven/src/create-flow/create-flow.spec.ts index cd1dc4790d..53763248d3 100644 --- a/e2e/tests/ui-driven/src/create-flow/create-flow.spec.ts +++ b/e2e/tests/ui-driven/src/create-flow/create-flow.spec.ts @@ -69,7 +69,7 @@ test.describe("Navigation", () => { let isRepeatedRequestMade = false; page.on( "request", - (req) => (isRepeatedRequestMade = isGetUserRequest(req)), + (req) => (isRepeatedRequestMade = isGetUserRequest(req)) ); Promise.all([ @@ -127,7 +127,7 @@ test.describe("Navigation", () => { "No", ]); await expect( - page.locator("a").filter({ hasText: questionText }), + page.locator("a").filter({ hasText: questionText }) ).toBeVisible(); // Add a notice to the "Yes" path @@ -137,7 +137,7 @@ test.describe("Navigation", () => { await createNotice( page, yesBranch.locator(".hanger > a"), - yesBranchNoticeText, + yesBranchNoticeText ); // Add a notice to the "No" path @@ -146,68 +146,51 @@ test.describe("Navigation", () => { await createNotice( page, noBranch.locator(".hanger > a"), - noBranchNoticeText, + noBranchNoticeText ); - // TODO: find a nicer way to find the next node - let nextNode = page.locator(".hanger > a").nth(5); - await createChecklist(page, nextNode, "A checklist title", [ + const getNextNode = () => page.locator(".hanger > a").last(); + + await createChecklist(page, getNextNode(), "A checklist title", [ "Checklist item 1", "Second checklist item", "The third checklist item", ]); - nextNode = page.locator(".hanger > a").nth(7); - await createTextInput(page, nextNode, "Tell us about your trees."); - - nextNode = page.locator(".hanger > a").nth(8); - await createNumberInput(page, nextNode, "How old are you?", "years"); - - nextNode = page.locator(".hanger > a").nth(9); - await createDateInput(page, nextNode, "When is your birthday?"); + await createTextInput(page, getNextNode(), "Tell us about your trees."); + await createNumberInput(page, getNextNode(), "How old are you?", "years"); + await createDateInput(page, getNextNode(), "When is your birthday?"); - nextNode = page.locator(".hanger > a").nth(10); await createAddressInput( page, - nextNode, + getNextNode(), "What is your address?", - "some data field", + "some data field" ); - nextNode = page.locator(".hanger > a").nth(11); await createContactInput( page, - nextNode, + getNextNode(), "What is your contact info?", - "some data field", + "some data field" ); - nextNode = page.locator(".hanger > a").nth(12); - await createTaskList(page, nextNode, "What you should do next", [ + await createTaskList(page, getNextNode(), "What you should do next", [ "Have a cup of tea", "Continue through this flow", ]); - nextNode = page.locator(".hanger > a").nth(13); - await createFindProperty(page, nextNode); - - nextNode = page.locator(".hanger > a").nth(14); - await createDrawBoundary(page, nextNode); - - nextNode = page.locator(".hanger > a").nth(15); - await createPlanningConstraints(page, nextNode); - - nextNode = page.locator(".hanger > a").nth(16); - await createFileUpload(page, nextNode, "some data field"); + await createFindProperty(page, getNextNode()); + await createDrawBoundary(page, getNextNode()); + await createPlanningConstraints(page, getNextNode()); + await createFileUpload(page, getNextNode(), "some data field"); - nextNode = page.locator(".hanger > a").nth(17); - await createNextSteps(page, nextNode, [ + await createNextSteps(page, getNextNode(), [ "A possible next step", "Another option", ]); - nextNode = page.locator(".hanger > a").nth(19); - await createReview(page, nextNode); + await createReview(page, getNextNode()); const nodes = page.locator(".card"); await expect(nodes.getByText(questionText)).toBeVisible(); @@ -227,7 +210,7 @@ test.describe("Navigation", () => { await expect(nodes.getByText("Next steps")).toBeVisible(); await expect( - nodes.getByText("Check your answers before sending your application"), + nodes.getByText("Check your answers before sending your application") ).toBeVisible(); }); @@ -242,7 +225,7 @@ test.describe("Navigation", () => { }); await page.goto( - `/${context.team.slug}/${serviceProps.slug}/published?analytics=false`, + `/${context.team.slug}/${serviceProps.slug}/published?analytics=false` ); await expect(page.getByText("Not Found")).toBeVisible(); @@ -276,11 +259,11 @@ test.describe("Navigation", () => { }); await page.goto( - `/${context.team.slug}/${serviceProps.slug}/published?analytics=false`, + `/${context.team.slug}/${serviceProps.slug}/published?analytics=false` ); await expect( - page.getByRole("heading", { level: 1, name: "Offline" }), + page.getByRole("heading", { level: 1, name: "Offline" }) ).toBeVisible(); }); @@ -299,7 +282,7 @@ test.describe("Navigation", () => { page.getByLabel("Offline").click(); page.getByRole("button", { name: "Save", disabled: false }).click(); await expect( - page.getByText("Service settings updated successfully"), + page.getByText("Service settings updated successfully") ).toBeVisible(); // Exit back to main Editor page @@ -322,13 +305,13 @@ test.describe("Navigation", () => { }); await page.goto( - `/${context.team.slug}/${serviceProps.slug}/published?analytics=false`, + `/${context.team.slug}/${serviceProps.slug}/published?analytics=false` ); await answerQuestion({ page, title: "Is this a test?", answer: "Yes" }); await clickContinue({ page }); await expect( - page.locator("h1", { hasText: "Yes! this is a test" }), + page.locator("h1", { hasText: "Yes! this is a test" }) ).toBeVisible(); await page.getByTestId("backButton").click(); @@ -336,7 +319,7 @@ test.describe("Navigation", () => { await answerQuestion({ page, title: "Is this a test?", answer: "No" }); await clickContinue({ page }); await expect( - page.locator("h1", { hasText: "Sorry, this is a test" }), + page.locator("h1", { hasText: "Sorry, this is a test" }) ).toBeVisible(); }); }); diff --git a/e2e/tests/ui-driven/src/helpers/addComponent.ts b/e2e/tests/ui-driven/src/helpers/addComponent.ts index 4ba616b79b..64efb20cdd 100644 --- a/e2e/tests/ui-driven/src/helpers/addComponent.ts +++ b/e2e/tests/ui-driven/src/helpers/addComponent.ts @@ -23,7 +23,7 @@ const createBaseComponent = async ( locatingNode: Locator, type: PlanXEditorComponent, title?: string, - options?: string[], + options?: string[] ) => { await locatingNode.click(); await page.getByRole("dialog").waitFor(); @@ -136,27 +136,27 @@ export const createQuestionWithOptions = async ( page: Page, locatingNode: Locator, questionText: string, - options: string[], + options: string[] ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.QUESTION, questionText, - options, + options ); }; export const createNotice = async ( page: Page, locatingNode: Locator, - noticeText: string, + noticeText: string ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.NOTICE, - noticeText, + noticeText ); }; @@ -164,27 +164,27 @@ export const createChecklist = async ( page: Page, locatingNode: Locator, checklistTitle: string, - checklistOptions: string[], + checklistOptions: string[] ) => { - createBaseComponent( + await createBaseComponent( page, locatingNode, PlanXEditorComponent.CHECKLIST, checklistTitle, - checklistOptions, + checklistOptions ); }; export const createTextInput = async ( page: Page, locatingNode: Locator, - inputTitle: string, + inputTitle: string ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.TEXT, - inputTitle, + inputTitle ); }; @@ -192,27 +192,27 @@ export const createNumberInput = async ( page: Page, locatingNode: Locator, inputTitle: string, - inputUnits: string, + inputUnits: string ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.NUMBER, inputTitle, - [inputUnits], + [inputUnits] ); }; export const createDateInput = async ( page: Page, locatingNode: Locator, - inputTitle: string, + inputTitle: string ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.DATE, - inputTitle, + inputTitle ); }; @@ -220,14 +220,14 @@ export const createAddressInput = async ( page: Page, locatingNode: Locator, inputTitle: string, - inputDataField: string, + inputDataField: string ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.ADDRESS, inputTitle, - [inputDataField], + [inputDataField] ); }; @@ -235,14 +235,14 @@ export const createContactInput = async ( page: Page, locatingNode: Locator, inputTitle: string, - inputDataField: string, + inputDataField: string ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.CONTACT, inputTitle, - [inputDataField], + [inputDataField] ); }; @@ -250,14 +250,14 @@ export const createTaskList = async ( page: Page, locatingNode: Locator, title: string, - taskListOptions: string[], + taskListOptions: string[] ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.TASKLIST, title, - taskListOptions, + taskListOptions ); }; @@ -269,18 +269,18 @@ export const createFindProperty = async (page: Page, locatingNode: Locator) => { await createBaseComponent( page, locatingNode, - PlanXEditorComponent.FIND_PROPERTY, + PlanXEditorComponent.FIND_PROPERTY ); }; export const createPlanningConstraints = async ( page: Page, - locatingNode: Locator, + locatingNode: Locator ) => { await createBaseComponent( page, locatingNode, - PlanXEditorComponent.PLANNING_CONSTRAINTS, + PlanXEditorComponent.PLANNING_CONSTRAINTS ); }; @@ -288,42 +288,42 @@ export const createDrawBoundary = async (page: Page, locatingNode: Locator) => { await createBaseComponent( page, locatingNode, - PlanXEditorComponent.DRAW_BOUNDARY, + PlanXEditorComponent.DRAW_BOUNDARY ); }; export const createNextSteps = async ( page: Page, locatingNode: Locator, - nextSteps: string[], + nextSteps: string[] ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.NEXT_STEPS, undefined, - nextSteps, + nextSteps ); }; export const createFileUpload = async ( page: Page, locatingNode: Locator, - dataField: string, + dataField: string ) => { await createBaseComponent( page, locatingNode, PlanXEditorComponent.FILE_UPLOAD, undefined, - [dataField], + [dataField] ); }; async function createComponentOptions( options: string[], buttonText: string, - page: Page, + page: Page ) { let index = 0; for (const option of options) {