Skip to content

Commit

Permalink
getNextNode as function
Browse files Browse the repository at this point in the history
  • Loading branch information
jamdelion committed Sep 16, 2024
1 parent ceba074 commit 780964a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 75 deletions.
75 changes: 29 additions & 46 deletions e2e/tests/ui-driven/src/create-flow/create-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test.describe("Navigation", () => {
let isRepeatedRequestMade = false;
page.on(
"request",
(req) => (isRepeatedRequestMade = isGetUserRequest(req)),
(req) => (isRepeatedRequestMade = isGetUserRequest(req))
);

Promise.all([
Expand Down Expand Up @@ -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
Expand All @@ -137,7 +137,7 @@ test.describe("Navigation", () => {
await createNotice(
page,
yesBranch.locator(".hanger > a"),
yesBranchNoticeText,
yesBranchNoticeText
);

// Add a notice to the "No" path
Expand All @@ -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();
Expand All @@ -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();
});

Expand All @@ -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();
Expand Down Expand Up @@ -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();
});

Expand All @@ -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
Expand All @@ -322,21 +305,21 @@ 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();

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();
});
});
Loading

0 comments on commit 780964a

Please sign in to comment.