Bugzilla – Attachment 190071 Details for
Bug 38311
DataTables - Simplify the building of the dropdown list filters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38311: Fix Selenium and Cypress tests
481993d.patch (text/plain), 8.17 KB, created by
Jonathan Druart
on 2025-12-02 10:20:44 UTC
(
hide
)
Description:
Bug 38311: Fix Selenium and Cypress tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-12-02 10:20:44 UTC
Size:
8.17 KB
patch
obsolete
>From 481993dda4c2afd2e1e295947009d6569efabd7e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 2 Dec 2025 11:19:20 +0100 >Subject: [PATCH] Bug 38311: Fix Selenium and Cypress tests > >.dt-select-filter does no longer exist > >Here we rely on DT's API to retrieve the correct visible column index. >However we cannot for Selenium tests, not ideal but it fixes the >failure. >--- > .../prog/en/includes/patron-search.inc | 14 ++-- > .../KohaTable/PatronSearch_spec.ts | 72 +++++++++++++------ > t/db_dependent/selenium/patrons_search.t | 3 +- > 3 files changed, 62 insertions(+), 27 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 5e995e1f7dc..d83f219dac0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -624,6 +624,7 @@ > } > [% CASE 'branch' %] > { >+ name: "library", > data: "library.name:me.library_id", > dataFilter: "libraries", > searchable: true, >@@ -638,6 +639,7 @@ > } > [% CASE 'category' %] > { >+ name: "category", > data: "category_id", > dataFilter: "categories", > searchable: true, >@@ -907,12 +909,16 @@ > [% SWITCH c %] > [% CASE 'branch' %] > let library_id = patron_search_form.find(".branchcode_filter").val() || ""; >- patrons_table.find('thead tr:eq(1) th[data-filter="libraries"] select').val('^' + library_id + '$'); >- table_dt.column([% loop.count - 1 %]).search(library_id ? '^'+library_id+'$' : ''); >+ let library_column = table_dt.column('library:name'); >+ let library_visible_index = library_column.index("visible"); >+ patrons_table.find(`thead tr:eq(1) th:eq(${library_visible_index}) select`).val('^' + library_id + '$'); >+ library_column.search(library_id ? '^'+library_id+'$' : ''); > [% CASE 'category' %] > let category_id = patron_search_form.find(".categorycode_filter").val() || ""; >- patrons_table.find('thead tr:eq(1) th[data-filter="categories"] select').val('^' + category_id.toLowerCase() + '$'); >- table_dt.column([% loop.count - 1 %]).search(category_id ? '^'+category_id+'$' : ''); >+ let category_column = table_dt.column('category:name'); >+ let category_visible_index = category_column.index("visible"); >+ patrons_table.find(`thead tr:eq(1) th:eq(${category_visible_index}) select`).val('^' + category_id.toLowerCase() + '$'); >+ category_column.search(category_id ? '^'+category_id+'$' : ''); > [% END %] > [% END %] > } >diff --git a/t/cypress/integration/KohaTable/PatronSearch_spec.ts b/t/cypress/integration/KohaTable/PatronSearch_spec.ts >index 92dd23c852a..f1c9be33c28 100644 >--- a/t/cypress/integration/KohaTable/PatronSearch_spec.ts >+++ b/t/cypress/integration/KohaTable/PatronSearch_spec.ts >@@ -159,25 +159,45 @@ describe("Filters", () => { > `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries` > ); > >- cy.get(`#${table_id} thead tr`).should("have.length", 2); >- >- cy.get( >- `#${table_id} thead tr th[data-filter='libraries'] select` >- ).should("have.value", "^CPL$"); >- // Lowercase see bug 32517 and related code in datatables.js >- cy.get( >- `#${table_id} thead tr th[data-filter='categories'] select` >- ).should("have.value", "^s$"); >- >- cy.get(`form.patron_search_form input.clear_search`).click(); >- cy.get("form.patron_search_form input[type='submit']").click(); >- cy.get( >- `#${table_id} thead tr th[data-filter='libraries'] select` >- ).should("have.value", null); >- // Lowercase see bug 32517 and related code in datatables.js >- cy.get( >- `#${table_id} thead tr th[data-filter='categories'] select` >- ).should("have.value", null); >+ cy.get(`#${table_id}`).then($table => { >+ const dt = $table.DataTable(); >+ const libraryCol = dt.column("library:name"); >+ const libraryVisibleIndex = libraryCol.index("visible"); >+ const categoryCol = dt.column("category:name"); >+ const categoryVisibleIndex = categoryCol.index("visible"); >+ >+ cy.get(`#${table_id} thead tr`).should("have.length", 2); >+ cy.get(`#${table_id} thead tr`) >+ .eq(1) >+ .find("th") >+ .eq(libraryVisibleIndex) >+ .find("select") >+ .should("have.value", "^CPL$"); >+ >+ // Lowercase see bug 32517 and related code in datatables.js >+ cy.get(`#${table_id} thead tr`) >+ .eq(1) >+ .find("th") >+ .eq(categoryVisibleIndex) >+ .find("select") >+ .should("have.value", "^s$"); >+ >+ cy.get(`form.patron_search_form input.clear_search`).click(); >+ cy.get("form.patron_search_form input[type='submit']").click(); >+ cy.get(`#${table_id} thead tr`) >+ .eq(1) >+ .find("th") >+ .eq(libraryVisibleIndex) >+ .find("select") >+ .should("have.value", null); >+ // Lowercase see bug 32517 and related code in datatables.js >+ cy.get(`#${table_id} thead tr`) >+ .eq(1) >+ .find("th") >+ .eq(categoryVisibleIndex) >+ .find("select") >+ .should("have.value", null); >+ }); > }); > }); > >@@ -257,9 +277,17 @@ describe("Filters", () => { > > cy.wait("@searchPatrons"); > >- cy.get( >- `#${table_id} thead tr th[data-filter='libraries'] select` >- ).select("^CPL$"); >+ cy.get(`#${table_id}`).then($table => { >+ const dt = $table.DataTable(); >+ const libraryCol = dt.column("library:name"); >+ const libraryVisibleIndex = libraryCol.index("visible"); >+ cy.get(`#${table_id} thead tr`) >+ .eq(1) >+ .find("th") >+ .eq(libraryVisibleIndex) >+ .find("select") >+ .select("^CPL$"); >+ }); > > cy.wait("@searchPatrons").then(interception => { > const q = interception.request.query.q; >diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t >index 095f2b476dc..0ee86fe2282 100755 >--- a/t/db_dependent/selenium/patrons_search.t >+++ b/t/db_dependent/selenium/patrons_search.t >@@ -342,9 +342,10 @@ subtest 'Search patrons' => sub { > 'Searching in standard brings back correct results' > ); > >+ # Not ideal as there are 2 select.dt-select-filter in the header (for library and category) > $s->driver->find_element( '//table[@id="' > . $table_id >- . '"]//th[@data-filter="libraries"]/select/option[@value="^' >+ . '"]//th/select[@class="dt-select-filter"]/option[@value="^' > . $first_patron->library->branchcode > . '$"]' )->click; > sleep $DT_delay && $s->wait_for_ajax; >-- >2.43.0 >
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 38311
:
184926
|
184927
|
186209
|
187376
|
187377
|
188314
|
188468
|
188469
|
188924
|
189184
|
189185
|
189186
| 190071