Bug 40346: Introduce loginOpac and visitOpac - Cypress

To be able to test the OPAC interface we need to add those 2 new
commands

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2025-07-10 22:05:57 +02:00 committed by Lucas Gass
parent 5e4032f0f1
commit 3ff1e96931
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 24 additions and 4 deletions

View File

@ -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",
},
},
});

View File

@ -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)