From ab9fc5c21a394d377790f8531fe8c872e12df506 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 17 May 2023 14:24:00 +0200 Subject: [PATCH] Bug 33625: Tidy remaining cypress test files --- t/cypress/integration/ERM/Agreements_spec.ts | 73 +++++++++++++++----- t/cypress/integration/ERM/Searchbar_spec.ts | 2 +- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/t/cypress/integration/ERM/Agreements_spec.ts b/t/cypress/integration/ERM/Agreements_spec.ts index 4f23d9b5396..5638fb9d9ee 100644 --- a/t/cypress/integration/ERM/Agreements_spec.ts +++ b/t/cypress/integration/ERM/Agreements_spec.ts @@ -164,25 +164,43 @@ describe("Agreement CRUD operations", () => { cy.intercept("GET", "/api/v1/erm/agreements/*", agreement); cy.visit("/cgi-bin/koha/erm/agreements"); cy.get("#agreements_list").contains("Showing 1 to 1 of 1 entries"); - cy.get(".filters").find("label").should(($labels) => { - expect($labels).to.have.length(2) - expect($labels.eq(0)).to.contain('Filter by expired') - expect($labels.eq(1)).to.contain('Show mine only') - }); // Filter options appear + cy.get(".filters") + .find("label") + .should($labels => { + expect($labels).to.have.length(2); + expect($labels.eq(0)).to.contain("Filter by expired"); + expect($labels.eq(1)).to.contain("Show mine only"); + }); // Filter options appear // Test filtering - cy.intercept("GET", "/api/v1/erm/agreements?max_expiration_date=*", []).as("getActiveAgreements"); + cy.intercept( + "GET", + "/api/v1/erm/agreements?max_expiration_date=*", + [] + ).as("getActiveAgreements"); cy.get("#expired_filter").check(); cy.get("#filter_table").click(); - cy.wait('@getActiveAgreements') - .its('request.url') - .should('include', 'max_expiration_date='+dates["today_iso"]); // Defaults to today - cy.get("#max_expiration_date_filter").should("have.value", dates["today_iso"]); // Input box reflects default - cy.url().should('include', "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["today_iso"]); // Browser url also updated + cy.wait("@getActiveAgreements") + .its("request.url") + .should("include", "max_expiration_date=" + dates["today_iso"]); // Defaults to today + cy.get("#max_expiration_date_filter").should( + "have.value", + dates["today_iso"] + ); // Input box reflects default + cy.url().should( + "include", + "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date=" + + dates["today_iso"] + ); // Browser url also updated // Now test that the url for this particular state works - cy.visit("/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["today_iso"]); - cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["today_iso"]); + cy.visit( + "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date=" + + dates["today_iso"] + ); + cy.wait("@getActiveAgreements") + .its("request.url") + .should("include", "max_expiration_date=" + dates["today_iso"]); // Now test with a user entered date cy.get("#max_expiration_date_filter+input").click({ force: true }); @@ -192,20 +210,37 @@ describe("Agreement CRUD operations", () => { .next("span") .click(); // select tomorrow cy.get("#filter_table").click(); - cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["tomorrow_iso"]); - cy.get("#max_expiration_date_filter").should("have.value", dates["tomorrow_iso"]); + cy.wait("@getActiveAgreements") + .its("request.url") + .should("include", "max_expiration_date=" + dates["tomorrow_iso"]); + cy.get("#max_expiration_date_filter").should( + "have.value", + dates["tomorrow_iso"] + ); // Assert that browser url changed again to reflect the user entered date - cy.url().should('include', "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["tomorrow_iso"]); + cy.url().should( + "include", + "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date=" + + dates["tomorrow_iso"] + ); // Now test that the url for the updated state works - cy.visit("/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["tomorrow_iso"]); - cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["tomorrow_iso"]); + cy.visit( + "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date=" + + dates["tomorrow_iso"] + ); + cy.wait("@getActiveAgreements") + .its("request.url") + .should("include", "max_expiration_date=" + dates["tomorrow_iso"]); // Verify that the date input is automatically filled if "by_expired" ticked but date is empty cy.get("#max_expiration_date_filter+input").clear(); cy.get("#expired_filter").check(); cy.get("#filter_table").click(); - cy.get("#max_expiration_date_filter").should('have.value', dates["today_iso"]); + cy.get("#max_expiration_date_filter").should( + "have.value", + dates["today_iso"] + ); // Test filter button with show mine_only ticked }); diff --git a/t/cypress/integration/ERM/Searchbar_spec.ts b/t/cypress/integration/ERM/Searchbar_spec.ts index 34715868b58..a5caf780b1c 100644 --- a/t/cypress/integration/ERM/Searchbar_spec.ts +++ b/t/cypress/integration/ERM/Searchbar_spec.ts @@ -26,7 +26,7 @@ describe("Searchbar header changes", () => { it("Should change to licenses when in licenses", () => { cy.visit("/cgi-bin/koha/erm/licenses"); - cy.get("#license_search_tab").parent().should("have.class", "active") + cy.get("#license_search_tab").parent().should("have.class", "active"); }); it("Should change to packages when in local packages", () => { -- 2.25.1