diff --git a/cypress/integration/login.js b/cypress/integration/login.js index 912f34c508..4db6170ed1 100644 --- a/cypress/integration/login.js +++ b/cypress/integration/login.js @@ -1,6 +1,6 @@ context("Login", () => { beforeEach(() => { - cy.request("/api/method/logout"); + cy.call("logout"); cy.visit("/login"); cy.location("pathname").should("eq", "/login"); }); @@ -48,7 +48,7 @@ context("Login", () => { base64_string: "aGVsbG8gYWxs", }); - cy.request("/api/method/logout"); + cy.call("logout"); // redirect-to /me page with params to mock OAuth 2.0 like request cy.visit( diff --git a/cypress/integration/navigation.js b/cypress/integration/navigation.js index 5961702ba5..ec7003aa15 100644 --- a/cypress/integration/navigation.js +++ b/cypress/integration/navigation.js @@ -24,7 +24,7 @@ context("Navigation", () => { cy.visit("/app/todo"); cy.get(".page-head").findByTitle("To Do").should("be.visible"); cy.clear_filters(); - cy.request("/api/method/logout"); + cy.call("logout"); cy.reload().as("reload"); cy.get("@reload").get(".page-card .btn-primary").contains("Login").click(); cy.location("pathname").should("eq", "/login"); diff --git a/cypress/integration/web_form.js b/cypress/integration/web_form.js index fcb24219b9..f6268b69cd 100644 --- a/cypress/integration/web_form.js +++ b/cypress/integration/web_form.js @@ -34,7 +34,7 @@ context("Web Form", () => { cy.url().should("include", "/note/new"); - cy.request("/api/method/logout"); + cy.call("logout"); cy.visit("/note"); cy.url().should("include", "/note/new"); @@ -49,6 +49,7 @@ context("Web Form", () => { }); it("Login Required", () => { + cy.call("logout"); cy.login("Administrator"); cy.visit("/app/web-form/note"); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 7252044fc1..5cc68a7c48 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -32,7 +32,7 @@ Cypress.Commands.add("login", (email, password) => { email = Cypress.config("testUser") || "Administrator"; } if (!password) { - password = Cypress.env("adminPassword") || "admin"; + password = Cypress.env("adminPassword"); } cy.session( [email, password] || "", @@ -70,6 +70,9 @@ Cypress.Commands.add("call", (method, args) => { }) .then((res) => { expect(res.status).eq(200); + if (method === "logout") { + Cypress.session.clearAllSavedSessions(); + } return res.body; }); });