Bugzilla – Attachment 178082 Details for
Bug 36025
Extended attributes clause added to patron search query even when there are no searchable attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36025: Add cypress tests
Bug-36025-Add-cypress-tests.patch (text/plain), 5.71 KB, created by
Marcel de Rooy
on 2025-02-14 08:33:49 UTC
(
hide
)
Description:
Bug 36025: Add cypress tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-02-14 08:33:49 UTC
Size:
5.71 KB
patch
obsolete
>From ee5b61cf51e7ded0a4b253624abbf394c8624b66 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 20 Jan 2025 16:01:29 +0100 >Subject: [PATCH] Bug 36025: Add cypress tests >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Magnus Enger <magnus@libriotech.no> >Tests pass, with the followup patch. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/cypress/integration/PatronSearch_spec.ts | 116 +++++++++++++++++++++ > t/cypress/support/e2e.js | 7 ++ > 2 files changed, 123 insertions(+) > create mode 100644 t/cypress/integration/PatronSearch_spec.ts > >diff --git a/t/cypress/integration/PatronSearch_spec.ts b/t/cypress/integration/PatronSearch_spec.ts >new file mode 100644 >index 0000000000..b706f1eb80 >--- /dev/null >+++ b/t/cypress/integration/PatronSearch_spec.ts >@@ -0,0 +1,116 @@ >+import { mount } from "@cypress/vue"; >+ >+const RESTdefaultPageSize = "20"; // FIXME Mock this >+const baseTotalCount = "42"; >+ >+const ExtendedPatronAttributes = 42; >+ >+const patron_attr_type = "attribute_type4TEST"; >+ >+function cleanup() { >+ const sql = "DELETE FROM borrower_attribute_types WHERE code=?"; >+ cy.query(sql, patron_attr_type); >+} >+describe("ExtendedPatronAttributes", () => { >+ beforeEach(() => { >+ cleanup(); >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ cy.window().then(win => { >+ win.localStorage.clear(); >+ }); >+ cy.query( >+ "SELECT value FROM systempreferences WHERE variable='ExtendedPatronAttributes'" >+ ).then(value => { >+ cy.wrap(value).as("syspref_ExtendedPatronAttributes"); >+ }); >+ }); >+ >+ afterEach( >+ () => >+ function () { >+ cleanup(); >+ cy.set_syspref( >+ "ExtendedPatronAttributes", >+ this.syspref_ExtendedPatronAttributes >+ ); >+ } >+ ); >+ >+ const table_id = "memberresultst"; >+ >+ it("ExtendedPatronAttributes=0", () => { >+ cy.intercept("GET", "/api/v1/patrons*").as("searchPatrons"); >+ >+ cy.set_syspref("ExtendedPatronAttributes", 0).then(() => { >+ cy.visit("/cgi-bin/koha/members/members-home.pl"); >+ >+ cy.get("#search_patron_filter").type("something"); >+ cy.get("form.patron_search_form input[type='submit']").click(); >+ >+ cy.query( >+ "select count(*) as nb_searchable from borrower_attribute_types where staff_searchable=1" >+ ).then(result => { >+ const has_searchable = result[0].nb_searchable; >+ cy.wait("@searchPatrons").then(interception => { >+ const q = interception.request.query.q; >+ expect(q).to.not.match(/extended_attributes/); >+ }); >+ }); >+ >+ cy.query( >+ "INSERT INTO borrower_attribute_types(code, description, staff_searchable, searched_by_default) VALUES (?, 'only for tests', 1, 1)", >+ patron_attr_type >+ ).then(() => { >+ cy.visit("/cgi-bin/koha/members/members-home.pl"); >+ >+ cy.get("#search_patron_filter").type("something"); >+ cy.get("form.patron_search_form input[type='submit']").click(); >+ >+ cy.wait("@searchPatrons").then(interception => { >+ const q = interception.request.query.q; >+ expect(q).to.not.match(/extended_attributes/); >+ }); >+ }); >+ }); >+ }); >+ it("ExtendedPatronAttributes=1", () => { >+ cy.intercept("GET", "/api/v1/patrons*").as("searchPatrons"); >+ >+ cy.set_syspref("ExtendedPatronAttributes", 1).then(() => { >+ cy.visit("/cgi-bin/koha/members/members-home.pl"); >+ >+ cy.get("#search_patron_filter").type("something"); >+ cy.get("form.patron_search_form input[type='submit']").click(); >+ >+ cy.query( >+ "select count(*) as nb_searchable from borrower_attribute_types where staff_searchable=1 AND searched_by_default=1" >+ ).then(result => { >+ const has_searchable = result[0].nb_searchable; >+ cy.wait("@searchPatrons").then(interception => { >+ const q = interception.request.query.q; >+ if (has_searchable) { >+ expect(q).to.match(/extended_attributes/); >+ } else { >+ expect(q).to.not.match(/extended_attributes/); >+ } >+ }); >+ }); >+ >+ cy.query( >+ "INSERT INTO borrower_attribute_types(code, description, staff_searchable, searched_by_default) VALUES (?, 'only for tests', 1, 1)", >+ patron_attr_type >+ ).then(() => { >+ cy.visit("/cgi-bin/koha/members/members-home.pl"); >+ >+ cy.get("#search_patron_filter").type("something"); >+ cy.get("form.patron_search_form input[type='submit']").click(); >+ >+ cy.wait("@searchPatrons").then(interception => { >+ const q = interception.request.query.q; >+ expect(q).to.match(/extended_attributes/); >+ }); >+ }); >+ }); >+ }); >+}); >diff --git a/t/cypress/support/e2e.js b/t/cypress/support/e2e.js >index 01e5c19bd7..ae5c10d019 100644 >--- a/t/cypress/support/e2e.js >+++ b/t/cypress/support/e2e.js >@@ -1815,3 +1815,10 @@ cy.getSushiService = () => { > > const mysql = require("cypress-mysql"); > mysql.addCommands(); >+ >+Cypress.Commands.add('set_syspref', (variable, value) => { >+ cy.window().then(win => { >+ const client = win.APIClient.syspref; >+ return client.sysprefs.update(variable, value); >+ }); >+}); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36025
:
161873
|
161874
|
161914
|
161915
|
175917
|
175918
|
175952
|
176747
|
176748
|
176823
|
176824
|
178037
|
178038
|
178039
|
178081
| 178082 |
178083