Bugzilla – Attachment 176793 Details for
Bug 38461
Table features needs to be covered by e2e tests using Cypress
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38461: Do not rely on biblio_id=1
Bug-38461-Do-not-rely-on-biblioid1.patch (text/plain), 7.79 KB, created by
Jonathan Druart
on 2025-01-20 12:45:12 UTC
(
hide
)
Description:
Bug 38461: Do not rely on biblio_id=1
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-01-20 12:45:12 UTC
Size:
7.79 KB
patch
obsolete
>From 6bd6e75106e86de00f3f92259ab44c85e62892c2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 20 Jan 2025 13:38:46 +0100 >Subject: [PATCH] Bug 38461: Do not rely on biblio_id=1 > >It might not exist! > >This code is not trivial and should ideally be moved to somewhere it >could be reused easily. But good enough for now to fix the failing tests. >--- > api/v1/swagger/definitions/item_type.yaml | 2 + > t/cypress/integration/KohaTable_spec.ts | 125 +++++++++++++++++++++- > 2 files changed, 123 insertions(+), 4 deletions(-) > >diff --git a/api/v1/swagger/definitions/item_type.yaml b/api/v1/swagger/definitions/item_type.yaml >index 274c393b83d..ec9f1781c6c 100644 >--- a/api/v1/swagger/definitions/item_type.yaml >+++ b/api/v1/swagger/definitions/item_type.yaml >@@ -5,6 +5,8 @@ properties: > type: string > description: Unique key, a code associated with the item type > readOnly: true >+ maxLength: 10 >+ minLength: 1 > parent_type: > description: Unique key, a code associated with the parent item type > type: >diff --git a/t/cypress/integration/KohaTable_spec.ts b/t/cypress/integration/KohaTable_spec.ts >index 7eacab0824c..f5f10146dbe 100644 >--- a/t/cypress/integration/KohaTable_spec.ts >+++ b/t/cypress/integration/KohaTable_spec.ts >@@ -488,8 +488,124 @@ describe("Hit all tables", () => { > > describe("catalogue/detail/holdings_table", () => { > const table_id = "holdings_table"; >- it("correctly init", () => { >- const biblio_id = 1; >+ beforeEach(() => { >+ // 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 library = generated_objects["library"]; >+ const item_type = generated_objects["item_type"]; >+ const queries = [ >+ { >+ query: "INSERT INTO branches(branchcode, branchname) VALUES (?, ?)", >+ values: [library.library_id, library.name], >+ }, >+ { >+ 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", >+ auth: { >+ username: "koha", >+ password: "koha", >+ }, >+ 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.request({ >+ method: "POST", >+ url: `/api/v1/biblios/${biblio_id}/items`, >+ auth: { >+ username: "koha", >+ password: "koha", >+ }, >+ headers: { >+ "Content-Type": "application/json", >+ }, >+ body: { >+ home_library_id: library.library_id, >+ holding_library_id: library.library_id, >+ }, >+ }); >+ }); >+ }); >+ }); >+ }); >+ >+ afterEach(() => {}); >+ >+ it("Correctly init the table", 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, >@@ -537,8 +653,9 @@ describe("Hit all tables", () => { > }); > }); > >- it("Show filters", () => { >- const biblio_id = 1; >+ it("Show filters", 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, >-- >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 38461
:
174877
|
174878
|
175004
|
175005
|
175006
|
175007
|
175008
|
175009
|
175010
|
175011
|
175015
|
175016
|
175179
|
175223
|
175224
|
175225
|
175226
|
175227
|
175228
|
175229
|
175230
|
175231
|
175232
|
175233
|
175234
|
175235
|
175289
|
175290
|
175291
|
175292
|
176082
|
176083
|
176084
|
176085
|
176086
|
176087
|
176088
|
176089
|
176090
|
176091
|
176092
|
176093
| 176793 |
176846
|
176902