Bugzilla – Attachment 179204 Details for
Bug 39315
Missing tests for KohaTable search on coded value's description
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39315: (bug 38108 follow-up) Add Cypress tests
Bug-39315-bug-38108-follow-up-Add-Cypress-tests.patch (text/plain), 8.54 KB, created by
Jonathan Druart
on 2025-03-12 12:24:41 UTC
(
hide
)
Description:
Bug 39315: (bug 38108 follow-up) Add Cypress tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-03-12 12:24:41 UTC
Size:
8.54 KB
patch
obsolete
>From 97e10a01988b65ece88953388c89eca9aabd65a3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 12 Mar 2025 13:18:16 +0100 >Subject: [PATCH] Bug 39315: (bug 38108 follow-up) Add Cypress tests > >1. We move from const to var so that we can modify the value of the >variable from the Cypress tests. > >2. Also remove win.libraries_map as it seems that our code is no longer >failing if it's missing (we added more checks I guess) > >3. Improved selectors for the show/hide filters links >- cy.get(".hide_filters").click(); >+ cy.get(`.${table_id}_table_controls .hide_filters`).click(); > >Test plan: >Both commands should pass > yarn cypress run --spec t/cypress/integration/PatronSearch_spec.ts > yarn cypress run --spec t/cypress/integration/t/mockData.ts >--- > .../tables/items/catalogue_detail.inc | 2 +- > .../integration/KohaTable/Holdings_spec.ts | 121 ++++++++++++++---- > 2 files changed, 99 insertions(+), 24 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >index 7422b988d28..17f37de2602 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >@@ -231,7 +231,7 @@ > const av_courses_term = new Map([% To.json(AuthorisedValues.Get('TERM')) | $raw %].map( av => [av.authorised_value, av.lib])); > [% END %] > >- const coded_values = { >+ var coded_values = { > library: new Map(all_libraries.map( l => [l.branchname, l.branchcode] )), > item_type: new Map(all_item_types.map( i => [i.translated_description, i.itemtype] )), > collection_code: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.ccode' })) | $raw %].map( av => [av.lib, av.authorised_value])), >diff --git a/t/cypress/integration/KohaTable/Holdings_spec.ts b/t/cypress/integration/KohaTable/Holdings_spec.ts >index 0248ba773e6..f6225b2cfb4 100644 >--- a/t/cypress/integration/KohaTable/Holdings_spec.ts >+++ b/t/cypress/integration/KohaTable/Holdings_spec.ts >@@ -151,13 +151,6 @@ describe("catalogue/detail/holdings_table", () => { > "/cgi-bin/koha/catalogue/detail.pl?biblionumber=" + biblio_id > ); > >- cy.window().then(win => { >- win.libraries_map = items.reduce((map, i) => { >- map[i.library_id] = i.library_id; >- return map; >- }, {}); >- }); >- > cy.get(`#${table_id}_wrapper tbody tr`).should( > "have.length", > RESTdefaultPageSize >@@ -210,13 +203,6 @@ describe("catalogue/detail/holdings_table", () => { > "items_table_settings.holdings" > ); > >- cy.window().then(win => { >- win.libraries_map = items.reduce((map, i) => { >- map[i.library_id] = i.library_id; >- return map; >- }, {}); >- }); >- > cy.get("@columns").then(columns => { > cy.get(`#${table_id}_wrapper tbody tr`).should( > "have.length", >@@ -234,7 +220,7 @@ describe("catalogue/detail/holdings_table", () => { > .contains("Course reserves") > .should("not.exist"); > >- cy.get(".show_filters").click(); >+ cy.get(`.${table_id}_table_controls .show_filters`).click(); > cy.get(`#${table_id}_wrapper .dt-info`).contains( > `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries` > ); >@@ -265,13 +251,6 @@ describe("catalogue/detail/holdings_table", () => { > "items_table_settings.holdings" > ); > >- cy.window().then(win => { >- win.libraries_map = items.reduce((map, i) => { >- map[i.library_id] = i.library_id; >- return map; >- }, {}); >- }); >- > cy.get("@columns").then(columns => { > cy.get(`#${table_id}_wrapper tbody tr`).should( > "have.length", >@@ -281,7 +260,7 @@ describe("catalogue/detail/holdings_table", () => { > // Filters are displayed > cy.get(`#${table_id} thead tr`).should("have.length", 2); > >- cy.get(".hide_filters").click(); >+ cy.get(`.${table_id}_table_controls .hide_filters`).click(); > > // Filters are not displayed > cy.get(`#${table_id} thead tr`).should("have.length", 1); >@@ -289,4 +268,100 @@ describe("catalogue/detail/holdings_table", () => { > }); > }); > }); >+ >+ it.only("Filters by code and description", function () { >+ // Do not use `() => {` or this.biblio_id won't be retrieved >+ const biblio_id = this.biblio_id; >+ cy.task("buildSampleObjects", { >+ object: "item", >+ count: RESTdefaultPageSize, >+ values: { >+ biblio_id, >+ checkout: null, >+ transfer: null, >+ lost_status: 0, >+ withdrawn: 0, >+ damaged_status: 0, >+ not_for_loan_status: 0, >+ course_item: null, >+ cover_image_ids: [], >+ }, >+ }).then(items => { >+ cy.intercept("get", `/api/v1/biblios/${biblio_id}/items*`, { >+ statuscode: 200, >+ body: items, >+ headers: { >+ "X-Base-Total-Count": baseTotalCount, >+ "X-Total-Count": baseTotalCount, >+ }, >+ }).as("searchItems"); >+ >+ cy.visit( >+ "/cgi-bin/koha/catalogue/detail.pl?biblionumber=" + biblio_id >+ ); >+ >+ cy.window().then(win => { >+ win.coded_values.library = new Map( >+ items.map(i => [ >+ i.home_library.name, >+ i.home_library.library_id, >+ ]) >+ ); >+ win.coded_values.item_type = new Map( >+ items.map(i => [ >+ i.item_type.description, >+ i.item_type.item_type_id, >+ ]) >+ ); >+ }); >+ cy.wait("@searchItems"); >+ >+ let library_id = items[0].home_library.library_id; >+ let library_name = items[0].home_library.name; >+ cy.get(`#${table_id}_wrapper input.dt-input`).type(library_id); >+ >+ cy.wait("@searchItems").then(interception => { >+ const q = interception.request.query.q; >+ expect(q).to.match( >+ new RegExp( >+ `"me.home_library_id":{"like":"%${library_id}%"}` >+ ) >+ ); >+ }); >+ >+ cy.get(`#${table_id}_wrapper input.dt-input`).clear(); >+ cy.get(`#${table_id}_wrapper input.dt-input`).type(library_name); >+ >+ cy.wait("@searchItems").then(interception => { >+ const q = interception.request.query.q; >+ expect(q).to.match( >+ new RegExp(`"me.home_library_id":\\["${library_id}"\\]`) >+ ); >+ }); >+ >+ let item_type_id = items[0].item_type.item_type_id; >+ let item_type_description = items[0].item_type.description; >+ cy.get(`#${table_id}_wrapper input.dt-input`).clear(); >+ cy.get(`#${table_id}_wrapper input.dt-input`).type(item_type_id); >+ >+ cy.wait("@searchItems").then(interception => { >+ const q = interception.request.query.q; >+ expect(q).to.match( >+ new RegExp(`"me.item_type_id":{"like":"%${item_type_id}%"}`) >+ ); >+ }); >+ >+ cy.get(`#${table_id}_wrapper input.dt-input`).clear(); >+ cy.get(`#${table_id}_wrapper input.dt-input`).type( >+ item_type_description >+ ); >+ >+ cy.wait("@searchItems").then(interception => { >+ const q = interception.request.query.q; >+ expect(q).to.match( >+ new RegExp(`"me.item_type_id":\\["${item_type_id}"\\]`) >+ ); >+ }); >+ }); >+ }); > }); >-- >2.34.1
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 39315
:
179201
|
179202
|
179203
|
179204
|
179365
|
179366
|
179367
|
179368