From e0cd1313172b27b7874bf5fd1e226f2265293b76 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 13 Apr 2023 18:12:13 +0100 Subject: [PATCH] Bug 33490: Make url consistent This ensures we populate the max_expiration_date param on the browser url for consistency with selected dates. Signed-off-by: Jonathan Druart --- .../prog/js/vue/components/ERM/AgreementsList.vue | 12 ++++++------ t/cypress/integration/ERM/Agreements_spec.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue index 4712cc5f3e8..d7c9f82a1ee 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue @@ -208,18 +208,18 @@ export default { }, table_url: function () { let url = "/api/v1/erm/agreements" - if (this.filters.by_expired) { - if (!this.filters.max_expiration_date) - this.filters.max_expiration_date = new Date() - .toISOString() - .substring(0, 10) - } if (this.filters.by_expired) url += "?max_expiration_date=" + this.filters.max_expiration_date return url }, filter_table: async function () { + if (this.filters.by_expired) { + if (!this.filters.max_expiration_date) + this.filters.max_expiration_date = new Date() + .toISOString() + .substring(0, 10) + } if (!this.embedded) { let new_route = build_url( "/cgi-bin/koha/erm/agreements", diff --git a/t/cypress/integration/ERM/Agreements_spec.ts b/t/cypress/integration/ERM/Agreements_spec.ts index 48e222d1013..8a1dfc91482 100644 --- a/t/cypress/integration/ERM/Agreements_spec.ts +++ b/t/cypress/integration/ERM/Agreements_spec.ts @@ -170,10 +170,10 @@ describe("Agreement CRUD operations", () => { .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"); // Browser url also updated + 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"); + 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 -- 2.25.1