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 <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2026-05-21 17:29:45 +01:00 committed by Lucas Gass
parent b5efda989f
commit 7048a657e7
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
3 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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);
};

View File

@ -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;