From 8d9788864d035c428aba1f05b453e166d6d0ce8d Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Mon, 7 Aug 2023 13:23:22 +0200 Subject: [PATCH] test(e2e): logout return_to --- test/e2e/cypress/helpers/express.ts | 1 + .../profiles/email/logout/success.spec.ts | 49 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/test/e2e/cypress/helpers/express.ts b/test/e2e/cypress/helpers/express.ts index 60ead1bd13e..138cf433fc5 100644 --- a/test/e2e/cypress/helpers/express.ts +++ b/test/e2e/cypress/helpers/express.ts @@ -10,4 +10,5 @@ export const routes = { settings: APP_URL + "/settings", recovery: APP_URL + "/recovery", verification: APP_URL + "/verification", + welcome: APP_URL + "/welcome", } diff --git a/test/e2e/cypress/integration/profiles/email/logout/success.spec.ts b/test/e2e/cypress/integration/profiles/email/logout/success.spec.ts index ca965c2d0c2..f13358166af 100644 --- a/test/e2e/cypress/integration/profiles/email/logout/success.spec.ts +++ b/test/e2e/cypress/integration/profiles/email/logout/success.spec.ts @@ -12,14 +12,16 @@ context("Testing logout flows", () => { app: "express" as "express", profile: "email", settings: express.settings, + welcome: express.welcome, }, { route: react.login, app: "react" as "react", profile: "spa", settings: react.settings, + welcome: "", }, - ].forEach(({ route, profile, app, settings }) => { + ].forEach(({ route, profile, app, settings, welcome }) => { describe(`for app ${app}`, () => { let email: string let password: string @@ -61,6 +63,45 @@ context("Testing logout flows", () => { cy.url().should("include", "/login") }) + it("should be able to sign out on settings page", () => { + if (app === "react") { + return + } + cy.sessionRequiresNo2fa() + cy.useLaxAal() + + cy.getSession({ expectAal: "aal1" }) + cy.getCookie("ory_kratos_session").should("not.be.null") + + cy.visit(settings, { + qs: { + return_to: "https://www.ory.sh", + }, + }) + + cy.get("a[href*='logout']").click() + cy.location("host").should("eq", "www.ory.sh") + }) + + it("should be able to sign out on welcome page", () => { + if (app === "react") { + return + } + cy.sessionRequiresNo2fa() + cy.useLaxAal() + + cy.getSession({ expectAal: "aal1" }) + + cy.visit(welcome, { + qs: { + return_to: "https://www.ory.sh", + }, + }) + + cy.get("a[href*='logout']").click() + cy.location("host").should("eq", "www.ory.sh") + }) + it("should be able to sign out at 2fa page", () => { if (app === "react") { return @@ -79,7 +120,11 @@ context("Testing logout flows", () => { cy.expectSettingsSaved() cy.logout() - cy.visit(route + "?return_to=https://www.ory.sh") + cy.visit(route, { + qs: { + return_to: "https://www.ory.sh", + }, + }) cy.get('[name="identifier"]').clear().type(email)