From 084c07a0fe00d22dc20463e78027f7c1e67ccb84 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 7 May 2026 09:47:33 +0200 Subject: [PATCH] Bug 27826: Fix OPAC/SCO_spec.ts 1. The DELETE in afterEach was not needed 2. The test was failing randomly on the UPDATE of the beforeEach `Duplicate entry '+42+' for key 'itembarcodeidx'` I don't explain it, but this patch should fix the failure. Signed-off-by: Lucas Gass --- t/cypress/integration/OPAC/SCO_spec.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/t/cypress/integration/OPAC/SCO_spec.ts b/t/cypress/integration/OPAC/SCO_spec.ts index b97b10a253..16d11d5ab9 100644 --- a/t/cypress/integration/OPAC/SCO_spec.ts +++ b/t/cypress/integration/OPAC/SCO_spec.ts @@ -3,30 +3,26 @@ describe("SCO", () => { cy.task("insertSampleBiblio", { item_count: 1 }).then(objects => { cy.wrap(objects).as("objects"); cy.task("query", { - sql: "UPDATE items SET barcode='+42+' WHERE itemnumber=?", + sql: "UPDATE items SET barcode=CONCAT('+', itemnumber, '+') WHERE itemnumber=?", values: [objects.items[0].item_id], }); }); }); afterEach(function () { - cy.task("query", { - sql: "DELETE FROM issues WHERE itemnumber=?", - values: [this.objects.items[0].item_id], - }); - cy.task("deleteSampleObjects", this.objects); }); it("Should not crash if barcode contains '+'", function () { + const barcode = `+${this.objects.items[0].item_id}+`; cy.visitOpac("/cgi-bin/koha/sco/sco-main.pl?op=logout"); cy.get("#patronlogin").type("kkoha"); // FIXME Why is the first character not displayed?? cy.get("#patronpw").type("koha"); cy.get("#mainform button").click(); - cy.get("#barcode").type("+42+"); + cy.get("#barcode").type(barcode); cy.get("#scan_form button[type='submit']").click(); cy.get("div.alert-info") - .contains("Item checked out (+42+)") + .contains(`Item checked out (${barcode})`) .should("be.visible"); cy.task("query", { sql: "DELETE FROM issues WHERE itemnumber=?",