From 143641ff53ab719e7440e05797053ca5cddea1ce Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Tue, 16 Apr 2024 09:53:18 +0000 Subject: [PATCH] Bug 36607: [DO NOT PUSH] Test for the commands cypress run --spec t/cypress/integration/DataTest_spec.ts --- t/cypress/integration/DataTest_spec.ts | 70 ++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 t/cypress/integration/DataTest_spec.ts diff --git a/t/cypress/integration/DataTest_spec.ts b/t/cypress/integration/DataTest_spec.ts new file mode 100644 index 0000000000..a8b0223dba --- /dev/null +++ b/t/cypress/integration/DataTest_spec.ts @@ -0,0 +1,70 @@ +import { mount } from "@cypress/vue"; + +describe("Test data", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + }); + + it("should create an object based on passed data", () => { + const testPatronData = { + firstname: "Cypress", + surname: "Test", + }; + + cy.buildObject("Koha::Patrons", testPatronData); + cy.query( + "SELECT firstname, surname FROM borrowers WHERE firstname=?", + "Cypress" + ).then(result => { + expect(result[0].surname).to.equal("Test"); + }); + cy.deleteDbRow("Koha::Patrons", testPatronData); + }); + + it("should create an object when no data values are passed", () => { + cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { + expect(result[0].count).to.equal(53); + }); + cy.buildObject("Koha::Patrons"); + cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { + expect(result[0].count).to.equal(54); + }); + cy.deleteDbRow("Koha::Patrons", null, 1); + }); + + it("should cleanup the new database rows when the 'numberofRows' parameter is passed", () => { + cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { + expect(result[0].count).to.equal(53); + }); + cy.buildObject("Koha::Patrons"); + cy.buildObject("Koha::Patrons"); + cy.buildObject("Koha::Patrons"); + cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { + expect(result[0].count).to.equal(56); + }); + cy.deleteDbRow("Koha::Patrons", null, 3); + cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { + expect(result[0].count).to.equal(53); + }); + }); + + it("should cleanup the new database rows when the 'deleteParameters' parameter is passed", () => { + const testPatronData = { + firstname: "Cypress", + surname: "Test", + }; + cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { + expect(result[0].count).to.equal(53); + }); + cy.buildObject("Koha::Patrons", testPatronData); + + cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { + expect(result[0].count).to.equal(54); + }); + cy.deleteDbRow("Koha::Patrons", testPatronData); + cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { + expect(result[0].count).to.equal(53); + }); + }); +}); -- 2.37.1 (Apple Git-137.1)