|
Line 0
Link Here
|
| 0 |
- |
1 |
import { mount } from "@cypress/vue"; |
|
|
2 |
|
| 3 |
describe("Table search", () => { |
| 4 |
beforeEach(() => { |
| 5 |
cy.login(); |
| 6 |
cy.title().should("eq", "Koha staff interface"); |
| 7 |
cy.intercept( |
| 8 |
"GET", |
| 9 |
"/api/v1/erm/config", |
| 10 |
'{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' |
| 11 |
); |
| 12 |
}); |
| 13 |
|
| 14 |
it("Input search bar and clear filter ", () => { |
| 15 |
let erm_title = cy.get_title(); |
| 16 |
let titles = [erm_title]; |
| 17 |
|
| 18 |
cy.intercept("GET", "/api/v1/erm/eholdings/local/titles*", { |
| 19 |
statusCode: 200, |
| 20 |
body: titles, |
| 21 |
headers: { |
| 22 |
"X-Base-Total-Count": "1", |
| 23 |
"X-Total-Count": "1", |
| 24 |
}, |
| 25 |
}).as("get_titles"); |
| 26 |
|
| 27 |
cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); |
| 28 |
cy.get("#titles_list").contains("Showing 1 to 1 of 1 entries"); |
| 29 |
|
| 30 |
// Should be disabled by default - empty search bar |
| 31 |
cy.get(".datatable button.dt_button_clear_filter").should( |
| 32 |
"have.class", |
| 33 |
"disabled" |
| 34 |
); |
| 35 |
|
| 36 |
// Type something in the input search bar |
| 37 |
cy.get(".datatable input[type='search']").type( |
| 38 |
erm_title.publication_title |
| 39 |
); |
| 40 |
cy.get(".datatable input[type='search']").should( |
| 41 |
"have.value", |
| 42 |
erm_title.publication_title |
| 43 |
); |
| 44 |
|
| 45 |
// Should no longer be disabled |
| 46 |
cy.get(".datatable button.dt_button_clear_filter").should( |
| 47 |
"not.have.class", |
| 48 |
"disabled" |
| 49 |
); |
| 50 |
|
| 51 |
// Click the clear_filter button |
| 52 |
cy.get(".datatable button.dt_button_clear_filter").click(); |
| 53 |
cy.get(".datatable input[type='search']").should("have.value", ""); |
| 54 |
|
| 55 |
// TODO: Some actual live API with data requests to test the search actually works |
| 56 |
// and returns results accordingly (or not) |
| 57 |
}); |
| 58 |
}); |