Bugzilla – Attachment 183752 Details for
Bug 40301
Missing Cypress tests for 'Type' column visibility
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40301: Add insertSampleCheckout
Bug-40301-Add-insertSampleCheckout.patch (text/plain), 6.27 KB, created by
Jonathan Druart
on 2025-07-03 12:13:13 UTC
(
hide
)
Description:
Bug 40301: Add insertSampleCheckout
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-07-03 12:13:13 UTC
Size:
6.27 KB
patch
obsolete
>From f5b74bde57f3a9bce0507b2153a72cb2bbe0cb8f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 3 Jul 2025 12:30:51 +0200 >Subject: [PATCH] Bug 40301: Add insertSampleCheckout > >--- > t/cypress/integration/t/insertData.ts | 21 ++++++++- > t/cypress/plugins/index.js | 4 ++ > t/cypress/plugins/insertData.js | 66 ++++++++++++++++++++++++++- > 3 files changed, 88 insertions(+), 3 deletions(-) > >diff --git a/t/cypress/integration/t/insertData.ts b/t/cypress/integration/t/insertData.ts >index 69a45c84644..0a06e9dca68 100644 >--- a/t/cypress/integration/t/insertData.ts >+++ b/t/cypress/integration/t/insertData.ts >@@ -7,13 +7,13 @@ const { APIClient } = require("./../../plugins/dist/api-client.cjs.js"); > let client = APIClient.default; > > describe("insertData", () => { >- > let tablesToCheck = [ > "borrowers", > "branches", > "items", > "biblio", > "reserves", >+ "issues", > ]; > beforeEach(() => { > const counts = {}; >@@ -202,6 +202,25 @@ describe("insertData", () => { > }); > }); > >+ describe("insertSampleCheckout", () => { >+ it("insertSampleCheckout - without parameter", () => { >+ cy.task("insertSampleCheckout").then(objects_checkout => { >+ cy.task("apiGet", { >+ endpoint: `/api/v1/checkouts/${objects_checkout.checkout.checkout_id}`, >+ headers: { >+ "Content-Type": "application/json", >+ }, >+ }).then(checkout => { >+ expect(checkout.item_id).to.be.equal( >+ objects_checkout.items[0].item_id >+ ); >+ }); >+ >+ cy.task("deleteSampleObjects", [objects_checkout]); >+ }); >+ }); >+ }); >+ > afterEach(function () { > cy.get("@initialCounts").then(initialCounts => { > const queries = tablesToCheck.map(table => { >diff --git a/t/cypress/plugins/index.js b/t/cypress/plugins/index.js >index a3cbd0c908b..77ae3098980 100644 >--- a/t/cypress/plugins/index.js >+++ b/t/cypress/plugins/index.js >@@ -5,6 +5,7 @@ const { buildSampleObject, buildSampleObjects } = require("./mockData.js"); > const { > insertSampleBiblio, > insertSampleHold, >+ insertSampleCheckout, > insertObject, > deleteSampleObjects, > } = require("./insertData.js"); >@@ -43,6 +44,9 @@ module.exports = (on, config) => { > insertSampleHold(args) { > return insertSampleHold({ ...args, baseUrl, authHeader }); > }, >+ insertSampleCheckout(args) { >+ return insertSampleCheckout({ ...args, baseUrl, authHeader }); >+ }, > insertObject(args) { > return insertObject({ ...args, baseUrl, authHeader }); > }, >diff --git a/t/cypress/plugins/insertData.js b/t/cypress/plugins/insertData.js >index 6869d308718..f4cb4241c01 100644 >--- a/t/cypress/plugins/insertData.js >+++ b/t/cypress/plugins/insertData.js >@@ -212,6 +212,49 @@ const insertSampleHold = async ({ > return { hold, patron }; > }; > >+const insertSampleCheckout = async ({ baseUrl, authHeader }) => { >+ let client = APIClient.default; >+ >+ const { biblio, items, libraries, item_type } = await insertSampleBiblio({ >+ item_count: 1, >+ baseUrl, >+ authHeader, >+ }); >+ const generatedPatron = await buildSampleObject({ >+ object: "patron", >+ values: { >+ library_id: libraries[0].library_id, >+ incorrect_address: null, >+ patron_card_lost: null, >+ }, >+ baseUrl, >+ authHeader, >+ }); >+ >+ const patron = await insertObject({ >+ type: "patron", >+ object: generatedPatron, >+ baseUrl, >+ authHeader, >+ }); >+ >+ const generatedCheckout = buildSampleObject({ >+ object: "checkout", >+ values: { >+ patron_id: patron.patron_id, >+ item_id: items[0].item_id, >+ }, >+ }); >+ delete generatedCheckout.external_id; >+ const checkout = await insertObject({ >+ type: "checkout", >+ object: generatedCheckout, >+ baseUrl, >+ authHeader, >+ }); >+ return { biblio, items, libraries, item_type, patron, checkout }; >+}; >+ > const deleteSampleObjects = async allObjects => { > if (!Array.isArray(allObjects)) { > allObjects = [allObjects]; >@@ -219,6 +262,7 @@ const deleteSampleObjects = async allObjects => { > > const deletionOrder = [ > "hold", >+ "checkout", > "patron", > "item", > "items", >@@ -276,6 +320,12 @@ const deleteSampleObjects = async allObjects => { > values: [objects[type].hold_id], > }); > break; >+ case "checkout": >+ await query({ >+ sql: "DELETE FROM issues WHERE issue_id = ?", >+ values: [objects[type].checkout_id], >+ }); >+ break; > case "item_type": > await query({ > sql: "DELETE FROM itemtypes WHERE itemtype = ?", >@@ -289,7 +339,7 @@ const deleteSampleObjects = async allObjects => { > }); > break; > default: >- console.log( >+ throw Error( > `Not implemented yet: cannot deleted object '${type}'` > ); > } >@@ -438,8 +488,19 @@ const insertObject = async ({ type, object, baseUrl, authHeader }) => { > }, > body: hold, > }); >+ } else if (type == "checkout") { >+ const { issuer, patron, ...checkout } = object; >+ >+ return client.koha.post({ >+ endpoint: `${baseUrl}/api/v1/checkouts`, >+ headers: { >+ "Content-Type": "application/json", >+ Authorization: authHeader, >+ }, >+ body: checkout, >+ }); > } else { >- return false; >+ throw Error(`Unsupported object type '${type}' to insert`); > } > > return true; >@@ -448,6 +509,7 @@ const insertObject = async ({ type, object, baseUrl, authHeader }) => { > module.exports = { > insertSampleBiblio, > insertSampleHold, >+ insertSampleCheckout, > insertObject, > deleteSampleObjects, > }; >-- >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 40301
: 183752 |
183753