From 7048a657e7b1380307ddbb94961be04568741525 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 21 May 2026 17:29:45 +0100 Subject: [PATCH] Bug 40383: (follow-up) Fix failing EdifactModal Cypress tests Three issues caused the EdifactModal_spec.ts test suite to fail: 1. insertSampleEdifactMessages inserted a vendor with listprice='USD' and invoiceprice='USD', but those columns have FK constraints against the currency table and USD is not pre-populated in KTD's default install. Drop the currency columns from the INSERT so they default to NULL. 2. Koha::Edifact::File::vendor() and basket() called Koha::Acquisition::Bookseller and Koha::Acquisition::Basket without use-ing them. The edifactmsgs.pl table embeds both on every API call, so a missing module caused a 500 and an empty table. 3. showMessage() already appended &format=json before delegating to showMessageFromUrl(), which then appended it a second time. Remove the redundant copy from showMessage(). Signed-off-by: Lucas Gass --- Koha/Edifact/File.pm | 2 ++ koha-tmpl/intranet-tmpl/prog/js/modals/edifact_interchange.js | 2 +- t/cypress/plugins/insertData.js | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Koha/Edifact/File.pm b/Koha/Edifact/File.pm index a6754f4b7f..9ce7f395f8 100644 --- a/Koha/Edifact/File.pm +++ b/Koha/Edifact/File.pm @@ -19,6 +19,8 @@ use Modern::Perl; use base qw(Koha::Object); +use Koha::Acquisition::Basket; +use Koha::Acquisition::Bookseller; use Koha::Edifact::File::Errors; =encoding utf8 diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/edifact_interchange.js b/koha-tmpl/intranet-tmpl/prog/js/modals/edifact_interchange.js index 154022f9d6..acc8a43a46 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/edifact_interchange.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/edifact_interchange.js @@ -56,7 +56,7 @@ const EdifactDisplay = (() => { }; const showMessage = (messageId, settings, focusOptions) => { - const url = `${settings.jsonEndpoint}?id=${encodeURIComponent(messageId)}&format=json`; + const url = `${settings.jsonEndpoint}?id=${encodeURIComponent(messageId)}`; showMessageFromUrl(url, settings, focusOptions); }; diff --git a/t/cypress/plugins/insertData.js b/t/cypress/plugins/insertData.js index 1ee5a2ece9..329d78f6d3 100644 --- a/t/cypress/plugins/insertData.js +++ b/t/cypress/plugins/insertData.js @@ -932,8 +932,8 @@ const insertObject = async ({ type, object, baseUrl, authHeader }) => { const insertSampleEdifactMessages = async () => { // First, create a test vendor const vendorResult = await query({ - sql: `INSERT INTO aqbooksellers (name, address1, address2, address3, phone, fax, url, active, listprice, invoiceprice, gstreg, listincgst, invoiceincgst, tax_rate, discount, notes) - VALUES ('Test EDI Vendor', '123 Test Street', 'Test City', 'Test Country', '555-1234', '555-5678', 'http://testvendor.com', 1, 'USD', 'USD', 0, 1, 1, 0.10, 0.05, 'Test vendor for EDIFACT testing')`, + sql: `INSERT INTO aqbooksellers (name, address1, address2, address3, phone, fax, url, active, gstreg, listincgst, invoiceincgst, tax_rate, discount, notes) + VALUES ('Test EDI Vendor', '123 Test Street', 'Test City', 'Test Country', '555-1234', '555-5678', 'http://testvendor.com', 1, 0, 1, 1, 0.10, 0.05, 'Test vendor for EDIFACT testing')`, values: [], }); const vendor_id = vendorResult.insertId;