diff --git a/workspaces/e2e/tests/branch/branch.html b/workspaces/e2e/tests/branch/branch.html index dfc906e..ddabe89 100644 --- a/workspaces/e2e/tests/branch/branch.html +++ b/workspaces/e2e/tests/branch/branch.html @@ -7,12 +7,14 @@
+ + diff --git a/workspaces/e2e/tests/branch/branch.spec.ts b/workspaces/e2e/tests/branch/branch.spec.ts index f7143cb..c2904da 100644 --- a/workspaces/e2e/tests/branch/branch.spec.ts +++ b/workspaces/e2e/tests/branch/branch.spec.ts @@ -34,3 +34,22 @@ test("branch can have multiple steps", async ({ page }) => { await page.locator(".flows-continue").click(); await expect(page.locator(".flows-tooltip")).toContainText("Last Step"); }); +test("should reset flow when entering branch without targetBranch", async ({ page }) => { + await page.goto("/branch/branch.html?hideNext=false&logErrors=true"); + await expect(page.locator(".flows-tooltip")).toBeVisible(); + await page.locator(".flows-continue").click(); + await expect(page.locator(".flows-tooltip")).toBeHidden(); + await page.locator(".start-flow").click(); + await expect(page.locator(".flows-tooltip")).toBeVisible(); + await expect(page.locator("[data-type='invalidStepError']")).toHaveCount(1); +}); +test("should reset flow when entering out of bound step", async ({ page }) => { + await page.goto("/branch/branch.html?lastStep=true&logErrors=true"); + await page.locator(".enter-1").click(); + await page.locator(".flows-continue").click(); + await page.locator(".flows-option").click(); + await expect(page.locator(".flows-tooltip")).toBeHidden(); + await page.locator(".start-flow").click(); + await expect(page.locator(".flows-tooltip")).toBeVisible(); + await expect(page.locator("[data-type='invalidStepError']")).toHaveCount(1); +}); diff --git a/workspaces/e2e/tests/branch/branch.ts b/workspaces/e2e/tests/branch/branch.ts index 8c99c62..9462ccc 100644 --- a/workspaces/e2e/tests/branch/branch.ts +++ b/workspaces/e2e/tests/branch/branch.ts @@ -1,13 +1,15 @@ import type { FlowSteps } from "@flows/js"; -import { init } from "@flows/js/core"; +import { init, startFlow } from "@flows/js/core"; const lastStep = new URLSearchParams(window.location.search).get("lastStep") === "true"; +const hideNext = new URLSearchParams(window.location.search).get("hideNext") !== "false"; +const logErrors = new URLSearchParams(window.location.search).get("logErrors") === "true"; const steps: FlowSteps = [ { targetElement: ".target", title: "Hello", - hideNext: true, + hideNext, wait: [ { clickElement: ".enter-1", targetBranch: 0 }, { clickElement: ".enter-2", targetBranch: 1 }, @@ -43,6 +45,7 @@ if (lastStep) steps.push({ targetElement: ".target", title: "Last Step", + footerActions: { right: [{ label: "Continue", targetBranch: undefined }] }, }); void init({ @@ -53,4 +56,19 @@ void init({ steps, }, ], + _debug: async (e) => { + if (logErrors) { + const p = document.createElement("p"); + p.classList.add("log-item"); + p.dataset.type = e.type; + p.dataset.referenceId = e.referenceId; + p.innerText = JSON.stringify(e); + document.querySelector(".log")?.appendChild(p); + } + return { referenceId: "" }; + }, +}); + +document.querySelector(".start-flow")?.addEventListener("click", () => { + startFlow("flow"); }); diff --git a/workspaces/e2e/tests/error/error.html b/workspaces/e2e/tests/tooltip-error/tooltip-error.html similarity index 89% rename from workspaces/e2e/tests/error/error.html rename to workspaces/e2e/tests/tooltip-error/tooltip-error.html index 32e05ad..6656db8 100644 --- a/workspaces/e2e/tests/error/error.html +++ b/workspaces/e2e/tests/tooltip-error/tooltip-error.html @@ -12,6 +12,6 @@ - +