From 6b74b5df5aac6d29cddf839b746fd87bd2eafd63 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 1 Sep 2023 13:31:23 +0000 Subject: [PATCH] Bug 34691: Add cypress tests Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- t/cypress/integration/ERM/Agreements_spec.ts | 3 +++ t/cypress/integration/ERM/Licenses_spec.ts | 3 +++ t/cypress/integration/ERM/Packages_spec.ts | 4 ++++ t/cypress/integration/ERM/Titles_spec.ts | 4 ++++ t/cypress/support/index.js | 4 ++++ 5 files changed, 18 insertions(+) diff --git a/t/cypress/integration/ERM/Agreements_spec.ts b/t/cypress/integration/ERM/Agreements_spec.ts index ad93a6c822..440ed51275 100644 --- a/t/cypress/integration/ERM/Agreements_spec.ts +++ b/t/cypress/integration/ERM/Agreements_spec.ts @@ -255,6 +255,7 @@ describe("Agreement CRUD operations", () => { cy.visit("/cgi-bin/koha/erm/agreements"); cy.contains("New agreement").click(); cy.get("#agreements_add h2").contains("New agreement"); + cy.left_menu_active_item_is("Agreements"); // Fill in the form for normal attributes let agreement = get_agreement(); @@ -492,6 +493,7 @@ describe("Agreement CRUD operations", () => { cy.wait("@get-agreement"); cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! cy.get("#agreements_add h2").contains("Edit agreement"); + cy.left_menu_active_item_is("Agreements"); // Form has been correctly filled in cy.get("#agreement_name").should("have.value", agreements[0].name); @@ -579,6 +581,7 @@ describe("Agreement CRUD operations", () => { cy.get("#agreements_show h2").contains( "Agreement #" + agreement.agreement_id ); + cy.left_menu_active_item_is("Agreements"); // TODO There are more to test here: // Dates correctly formatted diff --git a/t/cypress/integration/ERM/Licenses_spec.ts b/t/cypress/integration/ERM/Licenses_spec.ts index 089536b03b..c3d1649d6a 100644 --- a/t/cypress/integration/ERM/Licenses_spec.ts +++ b/t/cypress/integration/ERM/Licenses_spec.ts @@ -82,6 +82,7 @@ describe("License CRUD operations", () => { cy.visit("/cgi-bin/koha/erm/licenses"); cy.contains("New license").click(); cy.get("#licenses_add h2").contains("New license"); + cy.left_menu_active_item_is("Licenses"); // Fill in the form for normal attributes let license = get_license(); @@ -169,6 +170,7 @@ describe("License CRUD operations", () => { cy.wait("@get-license"); cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! cy.get("#licenses_add h2").contains("Edit license"); + cy.left_menu_active_item_is("Licenses"); // Form has been correctly filled in cy.get("#license_name").should("have.value", license.name); @@ -230,6 +232,7 @@ describe("License CRUD operations", () => { cy.wait("@get-license"); cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! cy.get("#licenses_show h2").contains("License #" + license.license_id); + cy.left_menu_active_item_is("Licenses"); }); it("Delete license", () => { diff --git a/t/cypress/integration/ERM/Packages_spec.ts b/t/cypress/integration/ERM/Packages_spec.ts index 826ef12c55..86199a63f7 100644 --- a/t/cypress/integration/ERM/Packages_spec.ts +++ b/t/cypress/integration/ERM/Packages_spec.ts @@ -86,6 +86,7 @@ describe("Package CRUD operations", () => { cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); cy.contains("New package").click(); cy.get("#packages_add h2").contains("New package"); + cy.left_menu_active_item_is("Packages"); // Fill in the form for normal attributes let erm_package = get_package(); @@ -171,6 +172,7 @@ describe("Package CRUD operations", () => { cy.wait("@get-package"); cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! cy.get("#packages_add h2").contains("Edit package"); + cy.left_menu_active_item_is("Packages"); // Form has been correctly filled in cy.get("#package_name").should("have.value", erm_package.name); @@ -232,6 +234,8 @@ describe("Package CRUD operations", () => { cy.get("#packages_show h2").contains( "Package #" + erm_package.package_id ); + cy.left_menu_active_item_is("Packages"); + // There are no resources, the table should not be displayed cy.contains("Titles (0)"); cy.get("#title_list_result table").should("not.exist"); diff --git a/t/cypress/integration/ERM/Titles_spec.ts b/t/cypress/integration/ERM/Titles_spec.ts index 80709e4997..3ed27112f6 100644 --- a/t/cypress/integration/ERM/Titles_spec.ts +++ b/t/cypress/integration/ERM/Titles_spec.ts @@ -47,6 +47,7 @@ describe("Title CRUD operations", () => { cy.wait(500); cy.get("#toolbar a").contains("Import from list").click(); cy.get("h2").contains("Import from a list"); + cy.left_menu_active_item_is("Titles"); cy.get("#package_list .vs__selected").should("not.exist"); // Make sure packages are returned @@ -127,6 +128,7 @@ describe("Title CRUD operations", () => { cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! cy.contains("New title").click(); cy.get("#titles_add h2").contains("New title"); + cy.left_menu_active_item_is("Titles"); // Fill in the form for normal attributes let erm_title = cy.get_title(); @@ -249,6 +251,7 @@ describe("Title CRUD operations", () => { cy.wait("@get-title"); cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! cy.get("#titles_add h2").contains("Edit title"); + cy.left_menu_active_item_is("Titles"); // Form has been correctly filled in cy.get("#title_publication_title").should( @@ -402,6 +405,7 @@ describe("Title CRUD operations", () => { cy.get("#eholdings_title_show h2").contains( "Title #" + erm_title.title_id ); + cy.left_menu_active_item_is("Titles"); // There are no packages, the table should not be displayed cy.contains("Packages (0)"); cy.get("#table#package_list").should("not.exist"); diff --git a/t/cypress/support/index.js b/t/cypress/support/index.js index 5ced7d5f02..4040e00547 100644 --- a/t/cypress/support/index.js +++ b/t/cypress/support/index.js @@ -19,6 +19,10 @@ import './commands'; // Alternatively you can use CommonJS syntax: // require('./commands') +Cypress.Commands.add('left_menu_active_item_is', (label) => { + cy.get("#navmenulist a.current:not(.disabled)").should('have.length',1).contains(label); +}) + cy.get_title = () => { return { access_type: "access type", -- 2.39.5