Bug 36774: Add cypress tests
[koha.git] / t / cypress / integration / flatpickr_spec.ts
1 import { mount } from "@cypress/vue";
2
3 const dayjs = require("dayjs");
4
5 const dates = {
6     today_iso: dayjs().format("YYYY-MM-DD"),
7     today_us: dayjs().format("MM/DD/YYYY"),
8     tomorrow_iso: dayjs().add(1, "day").format("YYYY-MM-DD"),
9     tomorrow_us: dayjs().add(1, "day").format("MM/DD/YYYY"),
10 };
11
12 describe("Flatpickr", () => {
13     beforeEach(() => {
14         cy.login();
15         cy.title().should("eq", "Koha staff interface");
16     });
17
18     it("'Clear filter' works correctly", () => {
19         cy.visit("/cgi-bin/koha/circ/overdue.pl");
20
21         cy.get("#from+span > input").click();
22         cy.get(".flatpickr-calendar")
23             .eq(0)
24             .find("span.today")
25             .click({ force: true });
26         cy.get("#from").invoke("val").should("eq", dates["today_iso"]);
27
28         cy.get("#from+span > a").click();
29         cy.get("#from").invoke("val").should("have.length", 0);
30
31         cy.get("#from+span > input").should("exist");
32     });
33 });