From ab61530287dd8583da43c7fcf88937e7191434b9 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. --- .../prog/js/vue/components/ERM/AgreementsList.vue | 12 ++++++------ t/cypress/integration/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 a20d406fc2..fba8c7fa5a 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 @@ -200,12 +200,6 @@ 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 @@ -216,6 +210,12 @@ export default { this.$emit("close") }, 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.before_route_entered) { let new_route = build_url( "/cgi-bin/koha/erm/agreements", diff --git a/t/cypress/integration/Agreements_spec.ts b/t/cypress/integration/Agreements_spec.ts index 5bfd27fae3..7183e41331 100644 --- a/t/cypress/integration/Agreements_spec.ts +++ b/t/cypress/integration/Agreements_spec.ts @@ -177,10 +177,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.40.0