From 95235e633d16ca82666a518f1fc420a941f10337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 24 May 2024 16:30:44 +0100 Subject: [PATCH] test(e2e): Update tests to account for flow status --- e2e/tests/api-driven/package.json | 2 +- e2e/tests/api-driven/pnpm-lock.yaml | 8 ++-- .../api-driven/src/invite-to-pay/helpers.ts | 1 + e2e/tests/ui-driven/package.json | 2 +- e2e/tests/ui-driven/pnpm-lock.yaml | 8 ++-- e2e/tests/ui-driven/src/context.ts | 1 + .../src/create-flow/create-flow.spec.ts | 46 +++++++++++++++++++ 7 files changed, 58 insertions(+), 10 deletions(-) diff --git a/e2e/tests/api-driven/package.json b/e2e/tests/api-driven/package.json index 3f52e24cc1..5421a8e761 100644 --- a/e2e/tests/api-driven/package.json +++ b/e2e/tests/api-driven/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@cucumber/cucumber": "^9.3.0", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#550634a", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#5710d52", "axios": "^1.6.8", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", diff --git a/e2e/tests/api-driven/pnpm-lock.yaml b/e2e/tests/api-driven/pnpm-lock.yaml index 184f04ac00..3005fa893d 100644 --- a/e2e/tests/api-driven/pnpm-lock.yaml +++ b/e2e/tests/api-driven/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^9.3.0 version: 9.3.0 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#550634a - version: github.com/theopensystemslab/planx-core/550634a + specifier: git+https://github.com/theopensystemslab/planx-core#5710d52 + version: github.com/theopensystemslab/planx-core/5710d52 axios: specifier: ^1.6.8 version: 1.6.8 @@ -2935,8 +2935,8 @@ packages: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} dev: false - github.com/theopensystemslab/planx-core/550634a: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/550634a} + github.com/theopensystemslab/planx-core/5710d52: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/5710d52} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/e2e/tests/api-driven/src/invite-to-pay/helpers.ts b/e2e/tests/api-driven/src/invite-to-pay/helpers.ts index c12649c4d9..302be5dd57 100644 --- a/e2e/tests/api-driven/src/invite-to-pay/helpers.ts +++ b/e2e/tests/api-driven/src/invite-to-pay/helpers.ts @@ -45,6 +45,7 @@ export async function buildITPFlow({ const flowId: string = await $admin.flow.create({ teamId, slug: `test-invite-to-pay-flow-with-send-to-${destination.toLowerCase()}`, + status: "online", data: flowGraph, }); const publishedFlowId = await $admin.flow.publish({ diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index e472938bcd..7957fa2819 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -8,7 +8,7 @@ "postinstall": "./install-dependencies.sh" }, "dependencies": { - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#550634a", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#5710d52", "axios": "^1.6.8", "dotenv": "^16.3.1", "eslint": "^8.56.0", diff --git a/e2e/tests/ui-driven/pnpm-lock.yaml b/e2e/tests/ui-driven/pnpm-lock.yaml index a0e6dbe733..551c17f74f 100644 --- a/e2e/tests/ui-driven/pnpm-lock.yaml +++ b/e2e/tests/ui-driven/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#550634a - version: github.com/theopensystemslab/planx-core/550634a + specifier: git+https://github.com/theopensystemslab/planx-core#5710d52 + version: github.com/theopensystemslab/planx-core/5710d52 axios: specifier: ^1.6.8 version: 1.6.8 @@ -2684,8 +2684,8 @@ packages: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} dev: false - github.com/theopensystemslab/planx-core/550634a: - resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/550634a} + github.com/theopensystemslab/planx-core/5710d52: + resolution: {tarball: https://codeload.github.com/theopensystemslab/planx-core/tar.gz/5710d52} name: '@opensystemslab/planx-core' version: 1.0.0 prepare: true diff --git a/e2e/tests/ui-driven/src/context.ts b/e2e/tests/ui-driven/src/context.ts index ac06eab02e..b9369b6e02 100644 --- a/e2e/tests/ui-driven/src/context.ts +++ b/e2e/tests/ui-driven/src/context.ts @@ -74,6 +74,7 @@ export async function setUpTestContext( slug: context.flow.slug, teamId: context.team.id, data: context.flow!.data!, + status: "online", }); context.flow.publishedId = await $admin.flow.publish({ flow: { 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 8c10cffec2..f003cb5045 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 @@ -179,6 +179,52 @@ test.describe("Navigation", () => { await expect(previewLink).toBeVisible(); }); + test("Cannot preview an offline flow", async ({ + browser, + }: { + browser: Browser; + }) => { + const page = await createAuthenticatedSession({ + browser, + userId: context.user!.id!, + }); + + await page.goto( + `/${context.team.slug}/${serviceProps.slug}/published?analytics=false`, + ); + + await expect(page.getByText("Not Found")).toBeVisible(); + }); + + test("Turn a flow online", async ({ browser }) => { + const page = await createAuthenticatedSession({ + browser, + userId: context.user!.id!, + }); + + await page.goto(`/${context.team.slug}/${serviceProps.slug}`); + + // Open flow settings + // TODO: Access via sidebar when EDITOR_NAVIGATION flag is removed + page.getByLabel("Toggle Menu").click(); + page.getByText("Flow Settings").click(); + + // Toggle flow online + page.getByLabel("Offline").click(); + page.getByRole("button", { name: "Save", disabled: false }).click(); + await expect( + page.getByText("Service settings updated successfully"), + ).toBeVisible(); + + // Exit back to main Editor page + page.getByRole("link", { name: "Close" }).click(); + + const previewLink = page.getByRole("link", { + name: "Open published service", + }); + await expect(previewLink).toBeVisible(); + }); + test("Can preview a published flow", async ({ browser, }: {