From 68baf8a7c13e77dc8fa5208665044498fa3f936c Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 31 Aug 2023 16:14:45 +0000 Subject: [PATCH] Bug 34466: Cypress tests Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- t/cypress/integration/KohaTable_spec.ts | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 t/cypress/integration/KohaTable_spec.ts diff --git a/t/cypress/integration/KohaTable_spec.ts b/t/cypress/integration/KohaTable_spec.ts new file mode 100644 index 0000000000..c24dae0985 --- /dev/null +++ b/t/cypress/integration/KohaTable_spec.ts @@ -0,0 +1,58 @@ +import { mount } from "@cypress/vue"; + +describe("Table search", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + cy.intercept( + "GET", + "/api/v1/erm/config", + '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' + ); + }); + + it("Input search bar and clear filter ", () => { + let erm_title = cy.get_title(); + let titles = [erm_title]; + + cy.intercept("GET", "/api/v1/erm/eholdings/local/titles*", { + statusCode: 200, + body: titles, + headers: { + "X-Base-Total-Count": "1", + "X-Total-Count": "1", + }, + }).as("get_titles"); + + cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); + cy.get("#titles_list").contains("Showing 1 to 1 of 1 entries"); + + // Should be disabled by default - empty search bar + cy.get(".datatable button.dt_button_clear_filter").should( + "have.class", + "disabled" + ); + + // Type something in the input search bar + cy.get(".datatable input[type='search']").type( + erm_title.publication_title + ); + cy.get(".datatable input[type='search']").should( + "have.value", + erm_title.publication_title + ); + + // Should no longer be disabled + cy.get(".datatable button.dt_button_clear_filter").should( + "not.have.class", + "disabled" + ); + + // Click the clear_filter button + cy.get(".datatable button.dt_button_clear_filter").click(); + cy.get(".datatable input[type='search']").should("have.value", ""); + + // TODO: Some actual live API with data requests to test the search actually works + // and returns results accordingly (or not) + }); +}); -- 2.20.1