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 <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2026-05-07 09:47:33 +02:00 committed by Lucas Gass
parent 4a47cc611f
commit 084c07a0fe
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 4 additions and 8 deletions

View File

@ -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=?",