From bfe198d3d1ce48e0271d3027d4d1503599cfabd8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 11 Jul 2025 07:28:18 +0200 Subject: [PATCH] Bug 40345: Add tests for bug 38102 Test plan: yarn cypress run --spec t/cypress/integration/KohaTable/OPACCirculationHistory_spec.ts must return green Revert commits from bug 38102 Run again the Cypress tests => They fail --- .../KohaTable/OPACCirculationHistory_spec.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 t/cypress/integration/KohaTable/OPACCirculationHistory_spec.ts diff --git a/t/cypress/integration/KohaTable/OPACCirculationHistory_spec.ts b/t/cypress/integration/KohaTable/OPACCirculationHistory_spec.ts new file mode 100644 index 00000000000..04c0a7bd603 --- /dev/null +++ b/t/cypress/integration/KohaTable/OPACCirculationHistory_spec.ts @@ -0,0 +1,43 @@ +describe("opac-readingrecord", () => { + beforeEach(() => { + let objects_to_cleanup = []; + cy.task("apiGet", { + endpoint: "/api/v1/patrons/51", + }).then(patron => { + [...Array(51)].forEach(() => { + cy.task("insertSampleCheckout", { + patron: patron, + }).then(objects_checkout => { + objects_to_cleanup.push(objects_checkout); + cy.task("query", { + sql: "INSERT INTO old_issues SELECT * FROM issues WHERE issue_id=?", + values: [objects_checkout.checkout.checkout_id], + }); + cy.task("query", { + sql: "DELETE FROM issues WHERE issue_id=?", + values: [objects_checkout.checkout.checkout_id], + }); + }); + }); + + cy.wrap(objects_to_cleanup).as("objects_to_cleanup"); + }); + + cy.loginOpac(); + }); + + afterEach(function () { + cy.task("deleteSampleObjects", [this.objects_to_cleanup]); + }); + + it("50 items should be displayed by default", function () { + cy.visitOpac("/cgi-bin/koha/opac-readingrecord.pl"); + + cy.contains("Showing 1 to 50 of 50 entries"); + cy.get("table#readingrec tbody tr").should("have.length", 50); + + cy.contains("Show all items").click(); + cy.contains("Showing 1 to 51 of 51 entries"); + cy.get("table#readingrec tbody tr").should("have.length", 51); + }); +}); -- 2.34.1