diff --git a/cypress.config.ts b/cypress.config.ts index fd17efc785..fed6e7b97b 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -15,9 +15,10 @@ export default defineConfig({ baseUrl: "http://localhost:8081", specPattern: "t/cypress/integration/**/*.*", supportFile: "t/cypress/support/e2e.js", - }, - env: { - apiUsername: "koha", - apiPassword: "koha", + env: { + opacBaseUrl: process.env.KOHA_OPAC_URL || "http://localhost:8080", + apiUsername: "koha", + apiPassword: "koha", + }, }, }); diff --git a/t/cypress/support/e2e.js b/t/cypress/support/e2e.js index b4f07fda5c..bcffe74d50 100644 --- a/t/cypress/support/e2e.js +++ b/t/cypress/support/e2e.js @@ -32,6 +32,10 @@ function get_fallback_login_value(param) { : Cypress.env(env_var); } +Cypress.Commands.add("visitOpac", path => { + cy.visit(Cypress.env("opacBaseUrl") + path); +}); + Cypress.Commands.add("login", (username, password) => { var user = typeof username === "undefined" @@ -47,6 +51,21 @@ Cypress.Commands.add("login", (username, password) => { cy.get("#submit-button").click(); }); +Cypress.Commands.add("loginOpac", (username, password) => { + var user = + typeof username === "undefined" + ? get_fallback_login_value("username") + : username; + var pass = + typeof password === "undefined" + ? get_fallback_login_value("password") + : password; + cy.visitOpac("/cgi-bin/koha/opac-main.pl?logout.x=1"); + cy.get("#userid").type(user); + cy.get("#password").type(pass); + cy.get("#auth .action").contains("Log in").click(); +}); + Cypress.Commands.add("left_menu_active_item_is", label => { cy.get(".sidebar_menu a.current:not(.disabled)") .should("have.length", 1)