Bugzilla – Attachment 184238 Details for
Bug 40430
Toolbar_spec.ts is failing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40430: Fix Toolbar_spec.ts
Bug-40430-Fix-Toolbarspects.patch (text/plain), 7.18 KB, created by
Owen Leonard
on 2025-07-17 17:11:26 UTC
(
hide
)
Description:
Bug 40430: Fix Toolbar_spec.ts
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2025-07-17 17:11:26 UTC
Size:
7.18 KB
patch
obsolete
>From e0f0210a1d9300fa1c81e8cee3c39486a9d5a634 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 17 Jul 2025 14:48:34 +0200 >Subject: [PATCH] Bug 40430: Fix Toolbar_spec.ts > >See comment 1 on the bug. > >We are adding the capability to insert vendors and baskets. > >Test plan: >Confirm that > yarn cypress run t/cypress/integration/Toolbar_spec.ts >pass, even if you do not have any vendors in DB. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > t/cypress/integration/Toolbar_spec.ts | 81 +++++++++++++++++---------- > t/cypress/plugins/insertData.js | 61 ++++++++++++++++++++ > 2 files changed, 111 insertions(+), 31 deletions(-) > >diff --git a/t/cypress/integration/Toolbar_spec.ts b/t/cypress/integration/Toolbar_spec.ts >index 385634ad52d..029aee98e47 100644 >--- a/t/cypress/integration/Toolbar_spec.ts >+++ b/t/cypress/integration/Toolbar_spec.ts >@@ -1,39 +1,9 @@ >-describe("Sticky toolbar", () => { >+describe("Sticky toolbar - basic behavior", () => { > beforeEach(() => { > cy.login(); > cy.title().should("eq", "Koha staff interface"); > }); > >- it("Should open non-Vue links correctly in the same tab", () => { >- const vendor = cy.getVendor(); >- vendor.baskets_count = 1; >- // Click the "name" link from the list >- cy.intercept("GET", "/api/v1/acquisitions/vendors\?*", { >- statusCode: 200, >- body: [vendor], >- headers: { >- "X-Base-Total-Count": "1", >- "X-Total-Count": "1", >- }, >- }).as("get-vendors"); >- cy.intercept( >- "GET", >- new RegExp("/api/v1/acquisitions/vendors/(?!config$).+"), >- vendor >- ).as("get-vendor"); >- >- cy.visit("/cgi-bin/koha/acquisition/vendors"); >- cy.wait("@get-vendors"); >- >- const name_link = cy.get( >- "#vendors_list table tbody tr:first td:first a" >- ); >- name_link.click(); >- cy.wait("@get-vendor"); >- cy.get("#toolbar a").contains("Receive shipments").click(); >- cy.get("h1").contains("Receive shipment from vendor " + vendor.name); >- }); >- > it("Should stick on scroll", () => { > cy.visit("/cgi-bin/koha/acqui/acqui-home.pl"); > >@@ -46,3 +16,52 @@ describe("Sticky toolbar", () => { > cy.get("#toolbar").should("not.have.class", "floating"); > }); > }); >+ >+describe("Sticky toolbar - vendors", () => { >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ >+ cy.task("buildSampleObject", { >+ object: "vendor", >+ values: { active: 1 }, >+ }) >+ .then(generatedVendor => { >+ delete generatedVendor.list_currency; >+ delete generatedVendor.invoice_currency; >+ return cy.task("insertObject", { >+ type: "vendor", >+ object: generatedVendor, >+ }); >+ }) >+ .then(vendor => { >+ cy.wrap(vendor).as("vendor"); >+ return cy.task("buildSampleObject", { >+ object: "basket", >+ values: { vendor_id: vendor.id }, >+ }); >+ }) >+ .then(generatedBasket => { >+ return cy.task("insertObject", { >+ type: "basket", >+ object: generatedBasket, >+ }); >+ }) >+ .then(basket => { >+ cy.wrap(basket).as("basket"); >+ }); >+ }); >+ afterEach(function () { >+ cy.task("deleteSampleObjects", [ >+ { vendor: this.vendor, basket: this.basket }, >+ ]); >+ }); >+ it("Should open non-Vue links correctly in the same tab", function () { >+ cy.visit(`/cgi-bin/koha/acquisition/vendors/${this.vendor.id}`); >+ >+ cy.get("#toolbar a").contains("Receive shipments").click(); >+ cy.get("h1").contains( >+ `Receive shipment from vendor ${this.vendor.name}` >+ ); >+ }); >+}); >diff --git a/t/cypress/plugins/insertData.js b/t/cypress/plugins/insertData.js >index 85915306098..4b522b2dc9a 100644 >--- a/t/cypress/plugins/insertData.js >+++ b/t/cypress/plugins/insertData.js >@@ -333,6 +333,8 @@ const deleteSampleObjects = async allObjects => { > hold: "holds", > checkout: "checkouts", > old_checkout: "old_checkouts", >+ basket: "baskets", >+ vendor: "vendors", > patron: "patrons", > item: "items", > biblio: "biblios", >@@ -360,6 +362,8 @@ const deleteSampleObjects = async allObjects => { > "holds", > "checkouts", > "old_checkouts", >+ "baskets", >+ "vendors", > "patrons", > "items", > "biblios", >@@ -431,6 +435,20 @@ const deleteSampleObjects = async allObjects => { > values: ids, > }); > break; >+ case "baskets": >+ ids = objects.map(i => i.basket_id); >+ await query({ >+ sql: `DELETE FROM aqbasket WHERE basketno IN (${ids.map(() => "?").join(",")})`, >+ values: ids, >+ }); >+ break; >+ case "vendors": >+ ids = objects.map(i => i.id); >+ await query({ >+ sql: `DELETE FROM aqbooksellers WHERE id IN (${ids.map(() => "?").join(",")})`, >+ values: ids, >+ }); >+ break; > default: > throw Error( > `Not implemented yet: cannot deleted object '${type}'` >@@ -544,6 +562,49 @@ const insertObject = async ({ type, object, baseUrl, authHeader }) => { > baseUrl, > authHeader, > }); >+ } else if (type == "vendor") { >+ const { >+ id, >+ baskets_count, >+ invoices_count, >+ subscriptions_count, >+ external_id, >+ aliases, >+ baskets, >+ contacts, >+ contracts, >+ interfaces, >+ invoices, >+ ...vendor >+ } = object; >+ >+ let endpoint = "/api/v1/acquisitions/vendors"; >+ >+ return apiPost({ >+ endpoint, >+ body: vendor, >+ baseUrl, >+ authHeader, >+ }); >+ } else if (type == "basket") { >+ const keysToKeep = ["name", "vendor_id", "close_date"]; >+ const basket = Object.fromEntries( >+ Object.entries(object).filter(([key]) => keysToKeep.includes(key)) >+ ); >+ return query({ >+ sql: "INSERT INTO aqbasket(basketname, booksellerid, closedate) VALUES (?, ?, ?)", >+ values: [basket.name, basket.vendor_id, basket.close_date], >+ }) >+ .then(result => { >+ const basket_id = result.insertId; >+ // FIXME We need /acquisitions/baskets/:basket_id >+ return apiGet({ >+ endpoint: `/api/v1/acquisitions/baskets?q={"basket_id":"${basket_id}"}`, >+ baseUrl, >+ authHeader, >+ }); >+ }) >+ .then(baskets => baskets[0]); > } else { > throw Error(`Unsupported object type '${type}' to insert`); > } >-- >2.39.5
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 40430
:
184196
|
184197
|
184198
| 184238