|
Lines 1-6
Link Here
|
| 1 |
import { mount } from "@cypress/vue"; |
1 |
import { mount } from "@cypress/vue"; |
| 2 |
|
2 |
|
| 3 |
describe("Table search", () => { |
3 |
describe("kohaTable (using REST API)", () => { |
|
|
4 |
beforeEach(() => { |
| 5 |
cy.login(); |
| 6 |
cy.title().should("eq", "Koha staff interface"); |
| 7 |
}); |
| 8 |
|
| 9 |
afterEach(() => {}); |
| 10 |
|
| 11 |
const RESTdefaultPageSize = 20; // FIXME Mock this |
| 12 |
|
| 13 |
it("Simple tables", () => { |
| 14 |
const table_id = "libraries"; |
| 15 |
|
| 16 |
it("Input search bar and clear filter ", () => { |
| 17 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
| 18 |
|
| 19 |
cy.query("SELECT COUNT(*) as count FROM branches").then(result => { |
| 20 |
let count = result[0].count; |
| 21 |
let display = Math.min(RESTdefaultPageSize, count); |
| 22 |
cy.get(`#${table_id}_wrapper .dt-info`).contains( |
| 23 |
`Showing 1 to ${display} of ${count} entries` |
| 24 |
); |
| 25 |
}); |
| 26 |
|
| 27 |
// Should be disabled by default - empty search bar |
| 28 |
cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( |
| 29 |
"have.class", |
| 30 |
"disabled" |
| 31 |
); |
| 32 |
|
| 33 |
// Type something in the input search bar |
| 34 |
cy.get(`#${table_id}_wrapper input.dt-input`).type("centerville"); |
| 35 |
cy.get(`#${table_id}_wrapper input.dt-input`).should( |
| 36 |
"have.value", |
| 37 |
"centerville" |
| 38 |
); |
| 39 |
|
| 40 |
// Should no longer be disabled |
| 41 |
cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( |
| 42 |
"not.have.class", |
| 43 |
"disabled" |
| 44 |
); |
| 45 |
|
| 46 |
// Click the clear_filter button |
| 47 |
cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).click(); |
| 48 |
cy.get(`#${table_id}_wrapper input.dt-input`).should( |
| 49 |
"have.value", |
| 50 |
"" |
| 51 |
); |
| 52 |
}); |
| 53 |
}); |
| 54 |
|
| 55 |
it("Patrons search", () => { |
| 56 |
const table_id = "memberresultst"; |
| 57 |
|
| 58 |
it("Input search bar and clear filter ", () => { |
| 59 |
cy.visit("/cgi-bin/koha/members/members-home.pl"); |
| 60 |
|
| 61 |
cy.get("form.patron_search_form input[type='submit']").click(); |
| 62 |
|
| 63 |
cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { |
| 64 |
let count = result[0].count; |
| 65 |
let display = Math.min(RESTdefaultPageSize, count); |
| 66 |
cy.get(`#${table_id}_wrapper .dt-info`).contains( |
| 67 |
`Showing 1 to ${display} of ${count} entries` |
| 68 |
); |
| 69 |
}); |
| 70 |
|
| 71 |
// Should be disabled by default - empty search bar |
| 72 |
cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( |
| 73 |
"have.class", |
| 74 |
"disabled" |
| 75 |
); |
| 76 |
|
| 77 |
// Type something in the input search bar |
| 78 |
cy.get(`#${table_id}_wrapper input.dt-input`).type( |
| 79 |
"edna", |
| 80 |
{ force: true } // Needs to force because of sticky header? It's not clear what's happening, Cypress bug? |
| 81 |
); |
| 82 |
cy.get(`#${table_id}_wrapper input.dt-input`).should( |
| 83 |
"have.value", |
| 84 |
"edna" |
| 85 |
); |
| 86 |
|
| 87 |
// Should no longer be disabled |
| 88 |
cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( |
| 89 |
"not.have.class", |
| 90 |
"disabled" |
| 91 |
); |
| 92 |
|
| 93 |
// Click the clear_filter button |
| 94 |
cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).click(); |
| 95 |
cy.get(`#${table_id}_wrapper input.dt-input`).should( |
| 96 |
"have.value", |
| 97 |
"" |
| 98 |
); |
| 99 |
}); |
| 100 |
}); |
| 101 |
}); |
| 102 |
|
| 103 |
describe("ERM ", () => { |
| 4 |
beforeEach(() => { |
104 |
beforeEach(() => { |
| 5 |
cy.login(); |
105 |
cy.login(); |
| 6 |
cy.title().should("eq", "Koha staff interface"); |
106 |
cy.title().should("eq", "Koha staff interface"); |
|
Lines 11-58
describe("Table search", () => {
Link Here
|
| 11 |
); |
111 |
); |
| 12 |
}); |
112 |
}); |
| 13 |
|
113 |
|
| 14 |
it("Input search bar and clear filter ", () => { |
114 |
it("Local titles", () => { |
| 15 |
let erm_title = cy.get_title(); |
115 |
const container_id = "title_list_result"; |
| 16 |
let titles = [erm_title]; |
116 |
it("Input search bar and clear filter ", () => { |
| 17 |
|
117 |
let erm_title = cy.get_title(); |
| 18 |
cy.intercept("GET", "/api/v1/erm/eholdings/local/titles*", { |
118 |
let titles = [erm_title]; |
| 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 |
|
119 |
|
| 36 |
// Type something in the input search bar |
120 |
cy.intercept("GET", "/api/v1/erm/eholdings/local/titles*", { |
| 37 |
cy.get(".datatable input[type='search']").type( |
121 |
statusCode: 200, |
| 38 |
erm_title.publication_title |
122 |
body: titles, |
| 39 |
); |
123 |
headers: { |
| 40 |
cy.get(".datatable input[type='search']").should( |
124 |
"X-Base-Total-Count": "1", |
| 41 |
"have.value", |
125 |
"X-Total-Count": "1", |
| 42 |
erm_title.publication_title |
126 |
}, |
| 43 |
); |
127 |
}).as("get_titles"); |
| 44 |
|
128 |
|
| 45 |
// Should no longer be disabled |
129 |
cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); |
| 46 |
cy.get(".datatable button.dt_button_clear_filter").should( |
130 |
cy.get("#titles_list").contains("Showing 1 to 1 of 1 entries"); |
| 47 |
"not.have.class", |
131 |
cy.get(`#${container_id} .dt-info`).contains( |
| 48 |
"disabled" |
132 |
`Showing 1 to 1 of 1 entries` |
| 49 |
); |
133 |
); |
|
|
134 |
|
| 135 |
// Should be disabled by default - empty search bar |
| 136 |
cy.get(`#${container_id} .dt_button_clear_filter`).should( |
| 137 |
"have.class", |
| 138 |
"disabled" |
| 139 |
); |
| 140 |
|
| 141 |
// Type something in the input search bar |
| 142 |
cy.get(`#${container_id} input.dt-input`).type( |
| 143 |
erm_title.publication_title |
| 144 |
); |
| 145 |
cy.get(`#${container_id} input.dt-input`).type( |
| 146 |
"have.value", |
| 147 |
erm_title.publication_title |
| 148 |
); |
| 149 |
|
| 150 |
// Should no longer be disabled |
| 151 |
cy.get(`#${container_id} .dt_button_clear_filter`).should( |
| 152 |
"not.have.class", |
| 153 |
"disabled" |
| 154 |
); |
| 50 |
|
155 |
|
| 51 |
// Click the clear_filter button |
156 |
// Click the clear_filter button |
| 52 |
cy.get(".datatable button.dt_button_clear_filter").click(); |
157 |
cy.get(`#${container_id} .dt_button_clear_filter`).click(); |
| 53 |
cy.get(".datatable input[type='search']").should("have.value", ""); |
158 |
cy.get(`#${container_id} input.dt-input`).should("have.value", ""); |
| 54 |
|
159 |
|
| 55 |
// TODO: Some actual live API with data requests to test the search actually works |
160 |
// TODO: Some actual live API with data requests to test the search actually works |
| 56 |
// and returns results accordingly (or not) |
161 |
// and returns results accordingly (or not) |
|
|
162 |
}); |
| 57 |
}); |
163 |
}); |
| 58 |
}); |
164 |
}); |
| 59 |
- |
|
|