|
Lines 2-7
describe("Display patron - search", () => {
Link Here
|
| 2 |
beforeEach(() => { |
2 |
beforeEach(() => { |
| 3 |
cy.login(); |
3 |
cy.login(); |
| 4 |
cy.title().should("eq", "Koha staff interface"); |
4 |
cy.title().should("eq", "Koha staff interface"); |
|
|
5 |
cy.task("query", { |
| 6 |
sql: "SELECT value FROM systempreferences WHERE variable='ShowPatronFirstnameIfDifferentThanPreferredname'", |
| 7 |
}).then(rows => { |
| 8 |
cy.wrap(rows[0].value).as( |
| 9 |
"syspref_ShowPatronFirstnameIfDifferentThanPreferredname" |
| 10 |
); |
| 11 |
}); |
| 12 |
cy.set_syspref("ShowPatronFirstnameIfDifferentThanPreferredname", 0); |
| 13 |
}); |
| 14 |
|
| 15 |
afterEach(function () { |
| 16 |
cy.set_syspref( |
| 17 |
"ShowPatronFirstnameIfDifferentThanPreferredname", |
| 18 |
this.syspref_ShowPatronFirstnameIfDifferentThanPreferredname |
| 19 |
); |
| 5 |
}); |
20 |
}); |
| 6 |
|
21 |
|
| 7 |
const table_id = "memberresultst"; |
22 |
const table_id = "memberresultst"; |
|
Lines 93-104
describe("Display patron - search", () => {
Link Here
|
| 93 |
}); |
108 |
}); |
| 94 |
}); |
109 |
}); |
| 95 |
}); |
110 |
}); |
|
|
111 |
|
| 112 |
it("should display patron firstname and preferred name when different and ShowPatronFirstnameIfDifferentThanPreferredname is enabled", function () { |
| 113 |
cy.task("buildSampleObjects", { |
| 114 |
object: "patron", |
| 115 |
count: 2, |
| 116 |
values: {}, |
| 117 |
}).then(patrons => { |
| 118 |
// Needs more properties to not explode |
| 119 |
// account_balace: balance_str.escapeHtml(...).format_price is not a function |
| 120 |
patrons = patrons.map(p => ({ ...p, account_balance: 0 })); |
| 121 |
|
| 122 |
cy.intercept("GET", "/api/v1/patrons*", { |
| 123 |
statusCode: 200, |
| 124 |
body: patrons, |
| 125 |
headers: { |
| 126 |
"X-Base-Total-Count": "2", |
| 127 |
"X-Total-Count": "2", |
| 128 |
}, |
| 129 |
}); |
| 130 |
|
| 131 |
cy.set_syspref( |
| 132 |
"ShowPatronFirstnameIfDifferentThanPreferredname", |
| 133 |
1 |
| 134 |
).then(() => { |
| 135 |
cy.visit("/cgi-bin/koha/members/members-home.pl"); |
| 136 |
|
| 137 |
cy.window().then(win => { |
| 138 |
win.categories_map = patrons.reduce((map, p) => { |
| 139 |
map[p.category_id.toLowerCase()] = p.category_id; |
| 140 |
return map; |
| 141 |
}, {}); |
| 142 |
}); |
| 143 |
|
| 144 |
cy.get("form.patron_search_form input[type='submit']").click(); |
| 145 |
|
| 146 |
const patron = patrons[0]; |
| 147 |
// invert_name is set |
| 148 |
cy.get(`#${table_id} tbody tr:eq(0) td:eq(2)`).should($el => { |
| 149 |
let re = new RegExp( |
| 150 |
`${patron.surname}, ${patron.preferred_name} ${patron.middle_name} \\(${patron.other_name}\\) \\[${patron.firstname}\\]` |
| 151 |
); |
| 152 |
const displayedText = $el.text().replace(/ /g, " ").trim(); |
| 153 |
expect(displayedText).to.match(re); |
| 154 |
re = new RegExp(patron.cardnumber); |
| 155 |
expect(displayedText).to.not.match(re); |
| 156 |
}); |
| 157 |
}); |
| 158 |
}); |
| 159 |
}); |
| 160 |
|
| 161 |
it("should not display patron firstname when same as preferred_name and ShowPatronFirstnameIfDifferentThanPreferredname is enabled", function () { |
| 162 |
cy.task("buildSampleObjects", { |
| 163 |
object: "patron", |
| 164 |
count: 2, |
| 165 |
values: { |
| 166 |
firstname: "SameFirstnameAndPreferredname", |
| 167 |
preferred_name: "SameFirstnameAndPreferredname", |
| 168 |
}, |
| 169 |
}).then(patrons => { |
| 170 |
// Needs more properties to not explode |
| 171 |
// account_balace: balance_str.escapeHtml(...).format_price is not a function |
| 172 |
patrons = patrons.map(p => ({ ...p, account_balance: 0 })); |
| 173 |
|
| 174 |
cy.intercept("GET", "/api/v1/patrons*", { |
| 175 |
statusCode: 200, |
| 176 |
body: patrons, |
| 177 |
headers: { |
| 178 |
"X-Base-Total-Count": "2", |
| 179 |
"X-Total-Count": "2", |
| 180 |
}, |
| 181 |
}); |
| 182 |
|
| 183 |
cy.set_syspref( |
| 184 |
"ShowPatronFirstnameIfDifferentThanPreferredname", |
| 185 |
1 |
| 186 |
).then(() => { |
| 187 |
cy.visit("/cgi-bin/koha/members/members-home.pl"); |
| 188 |
|
| 189 |
cy.window().then(win => { |
| 190 |
win.categories_map = patrons.reduce((map, p) => { |
| 191 |
map[p.category_id.toLowerCase()] = p.category_id; |
| 192 |
return map; |
| 193 |
}, {}); |
| 194 |
}); |
| 195 |
|
| 196 |
cy.get("form.patron_search_form input[type='submit']").click(); |
| 197 |
|
| 198 |
const patron = patrons[0]; |
| 199 |
// invert_name is set |
| 200 |
cy.get(`#${table_id} tbody tr:eq(0) td:eq(2)`).should($el => { |
| 201 |
let re = new RegExp( |
| 202 |
`${patron.surname}, ${patron.preferred_name} ${patron.middle_name} \\(${patron.other_name}\\)` |
| 203 |
); |
| 204 |
const displayedText = $el.text().replace(/ /g, " ").trim(); |
| 205 |
expect(displayedText).to.match(re); |
| 206 |
re = new RegExp(patron.cardnumber); |
| 207 |
expect(displayedText).to.not.match(re); |
| 208 |
re = new RegExp(`\\[${patron.firstname}\\]`); |
| 209 |
expect(displayedText).to.not.match(re); |
| 210 |
}); |
| 211 |
}); |
| 212 |
}); |
| 213 |
}); |
| 96 |
}); |
214 |
}); |
| 97 |
|
215 |
|
| 98 |
describe("Display patron - autocomplete", () => { |
216 |
describe("Display patron - autocomplete", () => { |
| 99 |
beforeEach(() => { |
217 |
beforeEach(() => { |
| 100 |
cy.login(); |
218 |
cy.login(); |
| 101 |
cy.title().should("eq", "Koha staff interface"); |
219 |
cy.title().should("eq", "Koha staff interface"); |
|
|
220 |
cy.task("query", { |
| 221 |
sql: "SELECT value FROM systempreferences WHERE variable='ShowPatronFirstnameIfDifferentThanPreferredname'", |
| 222 |
}).then(rows => { |
| 223 |
cy.wrap(rows[0].value).as( |
| 224 |
"syspref_ShowPatronFirstnameIfDifferentThanPreferredname" |
| 225 |
); |
| 226 |
}); |
| 227 |
cy.set_syspref("ShowPatronFirstnameIfDifferentThanPreferredname", 0); |
| 228 |
}); |
| 229 |
|
| 230 |
afterEach(function () { |
| 231 |
cy.set_syspref( |
| 232 |
"ShowPatronFirstnameIfDifferentThanPreferredname", |
| 233 |
this.syspref_ShowPatronFirstnameIfDifferentThanPreferredname |
| 234 |
); |
| 102 |
}); |
235 |
}); |
| 103 |
|
236 |
|
| 104 |
it("should display all patron info", function () { |
237 |
it("should display all patron info", function () { |
|
Lines 162-167
describe("Display patron - autocomplete", () => {
Link Here
|
| 162 |
}); |
295 |
}); |
| 163 |
}); |
296 |
}); |
| 164 |
}); |
297 |
}); |
|
|
298 |
|
| 299 |
it("should display patron firstname and preferred name when different and ShowPatronFirstnameIfDifferentThanPreferredname is enabled", function () { |
| 300 |
cy.task("buildSampleObjects", { |
| 301 |
object: "patron", |
| 302 |
count: 1, |
| 303 |
values: {}, |
| 304 |
}).then(patrons => { |
| 305 |
cy.intercept("GET", "/api/v1/patrons*", { |
| 306 |
statusCode: 200, |
| 307 |
body: patrons, |
| 308 |
headers: { |
| 309 |
"X-Base-Total-Count": "1", |
| 310 |
"X-Total-Count": "1", |
| 311 |
}, |
| 312 |
}); |
| 313 |
cy.set_syspref( |
| 314 |
"ShowPatronFirstnameIfDifferentThanPreferredname", |
| 315 |
1 |
| 316 |
).then(() => { |
| 317 |
cy.visit("/cgi-bin/koha/mainpage.pl"); |
| 318 |
|
| 319 |
const patron = patrons[0]; |
| 320 |
cy.get("#findborrower").type(patron.surname); |
| 321 |
|
| 322 |
// invert_name is set |
| 323 |
cy.get(`ul.ui-autocomplete li a`).should($el => { |
| 324 |
let re = new RegExp( |
| 325 |
`${patron.surname}, ${patron.preferred_name} ${patron.middle_name} \\(${patron.other_name}\\) \\[${patron.firstname}\\] \\(${patron.cardnumber}\\)` |
| 326 |
); |
| 327 |
const displayedText = $el.text().replace(/ /g, " ").trim(); |
| 328 |
expect(displayedText).to.match(re); |
| 329 |
}); |
| 330 |
}); |
| 331 |
}); |
| 332 |
}); |
| 333 |
|
| 334 |
it("should not display patron firstname when same as preferred_name and ShowPatronFirstnameIfDifferentThanPreferredname is enabled", function () { |
| 335 |
cy.task("buildSampleObjects", { |
| 336 |
object: "patron", |
| 337 |
count: 1, |
| 338 |
values: { |
| 339 |
firstname: "SameFirstnameAndPreferredname", |
| 340 |
preferred_name: "SameFirstnameAndPreferredname", |
| 341 |
}, |
| 342 |
}).then(patrons => { |
| 343 |
cy.intercept("GET", "/api/v1/patrons*", { |
| 344 |
statusCode: 200, |
| 345 |
body: patrons, |
| 346 |
headers: { |
| 347 |
"X-Base-Total-Count": "1", |
| 348 |
"X-Total-Count": "1", |
| 349 |
}, |
| 350 |
}); |
| 351 |
|
| 352 |
cy.set_syspref( |
| 353 |
"ShowPatronFirstnameIfDifferentThanPreferredname", |
| 354 |
1 |
| 355 |
).then(() => { |
| 356 |
cy.visit("/cgi-bin/koha/mainpage.pl"); |
| 357 |
|
| 358 |
const patron = patrons[0]; |
| 359 |
cy.get("#findborrower").type(patron.surname); |
| 360 |
|
| 361 |
// invert_name is set |
| 362 |
cy.get(`ul.ui-autocomplete li a`).should($el => { |
| 363 |
let re = new RegExp( |
| 364 |
`${patron.surname}, ${patron.preferred_name} ${patron.middle_name} \\(${patron.other_name}\\) \\(${patron.cardnumber}\\)` |
| 365 |
); |
| 366 |
const displayedText = $el.text().replace(/ /g, " ").trim(); |
| 367 |
expect(displayedText).to.match(re); |
| 368 |
re = new RegExp(`\\[${patron.firstname}\\]`); |
| 369 |
expect(displayedText).to.not.match(re); |
| 370 |
}); |
| 371 |
}); |
| 372 |
}); |
| 373 |
}); |
| 165 |
}); |
374 |
}); |
| 166 |
|
375 |
|
| 167 |
describe("Display patron - no search", () => { |
376 |
describe("Display patron - no search", () => { |
| 168 |
- |
|
|