Bugzilla – Attachment 183283 Details for
Bug 40127
JS error on biblio detail page when there are no items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40127: Add a Cypress test
Bug-40127-Add-a-Cypress-test.patch (text/plain), 5.72 KB, created by
Jonathan Druart
on 2025-06-16 13:32:11 UTC
(
hide
)
Description:
Bug 40127: Add a Cypress test
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-06-16 13:32:11 UTC
Size:
5.72 KB
patch
obsolete
>From 94a38c29813febd3d36cd6f23fa0a3f577899eb1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 12 Jun 2025 09:54:37 +0200 >Subject: [PATCH] Bug 40127: Add a Cypress test > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../integration/KohaTable/Holdings_spec.ts | 115 +++++++++++++++++- > 1 file changed, 114 insertions(+), 1 deletion(-) > >diff --git a/t/cypress/integration/KohaTable/Holdings_spec.ts b/t/cypress/integration/KohaTable/Holdings_spec.ts >index 25928874b1b..f39e51e0e75 100644 >--- a/t/cypress/integration/KohaTable/Holdings_spec.ts >+++ b/t/cypress/integration/KohaTable/Holdings_spec.ts >@@ -1,7 +1,7 @@ > const RESTdefaultPageSize = "20"; // FIXME Mock this > const baseTotalCount = "42"; > >-describe("catalogue/detail/holdings_table", () => { >+describe("catalogue/detail/holdings_table with items", () => { > const table_id = "holdings_table"; > beforeEach(() => { > cy.login(); >@@ -409,3 +409,116 @@ describe("catalogue/detail/holdings_table", () => { > }); > }); > }); >+ >+describe("catalogue/detail/holdings_table without items", () => { >+ const table_id = "holdings_table"; >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ cy.window().then(win => { >+ win.localStorage.clear(); >+ }); >+ >+ // FIXME All the following code should not be reused as it >+ // It must be moved to a Cypress command or task "buildSampleBiblio" or even "insertSampleBiblio" >+ let generated_objects = {}; >+ const objects = [{ object: "library" }, { object: "item_type" }]; >+ cy.wrap(Promise.resolve()) >+ .then(() => { >+ return objects.reduce((chain, { object }) => { >+ return chain.then(() => { >+ return cy >+ .task("buildSampleObject", { object }) >+ .then(attributes => { >+ generated_objects[object] = attributes; >+ }); >+ }); >+ }, Promise.resolve()); >+ }) >+ .then(() => { >+ const item_type = generated_objects["item_type"]; >+ const queries = [ >+ { >+ query: "INSERT INTO itemtypes(itemtype, description) VALUES (?, ?)", >+ values: [item_type.item_type_id, item_type.description], >+ }, >+ ]; >+ cy.wrap(Promise.resolve()) >+ .then(() => { >+ return queries.reduce((chain, { query, values }) => { >+ return chain.then(() => cy.query(query, values)); >+ }, Promise.resolve()); >+ }) >+ .then(() => { >+ let biblio = { >+ leader: " nam a22 7a 4500", >+ fields: [ >+ { "005": "20250120101920.0" }, >+ { >+ "245": { >+ ind1: "", >+ ind2: "", >+ subfields: [{ a: "Some boring read" }], >+ }, >+ }, >+ { >+ "100": { >+ ind1: "", >+ ind2: "", >+ subfields: [ >+ { c: "Some boring author" }, >+ ], >+ }, >+ }, >+ { >+ "942": { >+ ind1: "", >+ ind2: "", >+ subfields: [ >+ { c: item_type.item_type_id }, >+ ], >+ }, >+ }, >+ ], >+ }; >+ cy.request({ >+ method: "POST", >+ url: "/api/v1/biblios", >+ headers: { >+ "Content-Type": "application/marc-in-json", >+ "x-confirm-not-duplicate": 1, >+ }, >+ body: biblio, >+ }).then(response => { >+ const biblio_id = response.body.id; >+ cy.wrap(biblio_id).as("biblio_id"); >+ }); >+ }); >+ }); >+ cy.query( >+ "SELECT value FROM systempreferences WHERE variable='AlwaysShowHoldingsTableFilters'" >+ ).then(value => { >+ cy.wrap(value).as("syspref_AlwaysShowHoldingsTableFilters"); >+ }); >+ }); >+ >+ afterEach( >+ () => >+ function () { >+ cleanup(); >+ cy.set_syspref( >+ "AlwaysShowHoldingsTableFilters", >+ this.syspref_AlwaysShowHoldingsTableFilters >+ ); >+ } >+ ); >+ >+ it("Do not display the table", function () { >+ // Do not use `() => {` or this.biblio_id won't be retrieved >+ const biblio_id = this.biblio_id; >+ >+ cy.visit("/cgi-bin/koha/catalogue/detail.pl?biblionumber=" + biblio_id); >+ >+ cy.get(`#${table_id}_wrapper`).should("not.exist"); >+ }); >+}); >-- >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 40127
:
183185
|
183186
|
183187
|
183188
|
183189
|
183190
|
183228
|
183229
|
183230
| 183283