Bugzilla – Attachment 184338 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), 5.78 KB, created by
Martin Renvoize (ashimema)
on 2025-07-18 11:25:24 UTC
(
hide
)
Description:
Bug 40301: Add insertSampleCheckout
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-18 11:25:24 UTC
Size:
5.78 KB
patch
obsolete
>From f1fba316a638efa4ad7049664828e930602f365f 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 > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > t/cypress/integration/t/insertData.ts | 17 ++++++++ > t/cypress/plugins/index.js | 4 ++ > t/cypress/plugins/insertData.js | 60 +++++++++++++++++++++++++++ > 3 files changed, 81 insertions(+) > >diff --git a/t/cypress/integration/t/insertData.ts b/t/cypress/integration/t/insertData.ts >index 00c651a6d05..745137fee26 100644 >--- a/t/cypress/integration/t/insertData.ts >+++ b/t/cypress/integration/t/insertData.ts >@@ -8,6 +8,7 @@ describe("insertData", () => { > "items", > "biblio", > "reserves", >+ "issues", > ]; > beforeEach(() => { > const counts = {}; >@@ -215,6 +216,22 @@ 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}`, >+ }).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 06077a00811..61705a01f66 100644 >--- a/t/cypress/plugins/insertData.js >+++ b/t/cypress/plugins/insertData.js >@@ -205,6 +205,47 @@ const insertSampleHold = async ({ > return { hold, patron }; > }; > >+const insertSampleCheckout = async ({ baseUrl, authHeader }) => { >+ 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]; >@@ -212,6 +253,7 @@ const deleteSampleObjects = async allObjects => { > > const pluralMap = { > hold: "holds", >+ checkout: "checkouts", > patron: "patrons", > item: "items", > biblio: "biblios", >@@ -237,6 +279,7 @@ const deleteSampleObjects = async allObjects => { > > const deletionOrder = [ > "holds", >+ "checkouts", > "patrons", > "items", > "biblios", >@@ -280,6 +323,13 @@ const deleteSampleObjects = async allObjects => { > values: ids, > }); > break; >+ case "checkouts": >+ ids = objects.map(i => i.checkout_id); >+ await query({ >+ sql: `DELETE FROM issues WHERE issue_id IN (${ids.map(() => "?").join(",")})`, >+ values: ids, >+ }); >+ break; > case "item_types": > ids = objects.map(i => i.item_type_id); > await query({ >@@ -431,6 +481,15 @@ const insertObject = async ({ type, object, baseUrl, authHeader }) => { > baseUrl, > authHeader, > }); >+ } else if (type == "checkout") { >+ const { issuer, patron, ...checkout } = object; >+ >+ return apiPost({ >+ endpoint: "/api/v1/checkouts", >+ body: checkout, >+ baseUrl, >+ authHeader, >+ }); > } else { > throw Error(`Unsupported object type '${type}' to insert`); > } >@@ -441,6 +500,7 @@ const insertObject = async ({ type, object, baseUrl, authHeader }) => { > module.exports = { > insertSampleBiblio, > insertSampleHold, >+ insertSampleCheckout, > insertObject, > deleteSampleObjects, > }; >-- >2.50.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
|
183938
|
183939
|
184214
|
184215
| 184338 |
184339