From 448dd0d2fcc97a287218a7aa7af73c5ea0727aba Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 8 May 2024 15:26:52 +0000 Subject: [PATCH] Bug 36774: Add cypress tests Inside k-t-d, run: cypress run --spec t/cypress/integration/flatpickr_spec.ts Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer (cherry picked from commit 46c5a51d58565f2773a9438c195711c0156b866c) Signed-off-by: Fridolin Somers (cherry picked from commit df53cb4e24890baac30270c45d8b4ec7601127ac) Signed-off-by: Lucas Gass --- t/cypress/integration/flatpickr_spec.ts | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 t/cypress/integration/flatpickr_spec.ts diff --git a/t/cypress/integration/flatpickr_spec.ts b/t/cypress/integration/flatpickr_spec.ts new file mode 100644 index 0000000000..60f744776e --- /dev/null +++ b/t/cypress/integration/flatpickr_spec.ts @@ -0,0 +1,33 @@ +import { mount } from "@cypress/vue"; + +const dayjs = require("dayjs"); + +const dates = { + today_iso: dayjs().format("YYYY-MM-DD"), + today_us: dayjs().format("MM/DD/YYYY"), + tomorrow_iso: dayjs().add(1, "day").format("YYYY-MM-DD"), + tomorrow_us: dayjs().add(1, "day").format("MM/DD/YYYY"), +}; + +describe("Flatpickr", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + }); + + it("'Clear filter' works correctly", () => { + cy.visit("/cgi-bin/koha/circ/overdue.pl"); + + cy.get("#from+span > input").click(); + cy.get(".flatpickr-calendar") + .eq(0) + .find("span.today") + .click({ force: true }); + cy.get("#from").invoke("val").should("eq", dates["today_iso"]); + + cy.get("#from+span > a").click(); + cy.get("#from").invoke("val").should("have.length", 0); + + cy.get("#from+span > input").should("exist"); + }); +}); -- 2.39.5