From 1a5920a61d05986d9a3cc6939a47f99fc2c01c80 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 24 Jan 2024 16:18:55 -0300 Subject: [PATCH] Bug 32607: Add cypress tests --- t/cypress/integration/RecordSources_spec.ts | 69 +++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 t/cypress/integration/RecordSources_spec.ts diff --git a/t/cypress/integration/RecordSources_spec.ts b/t/cypress/integration/RecordSources_spec.ts new file mode 100644 index 00000000000..6775083e0dd --- /dev/null +++ b/t/cypress/integration/RecordSources_spec.ts @@ -0,0 +1,69 @@ +import { mount } from "@cypress/vue"; +const dayjs = require("dayjs"); /* Cannot use our calendar JS code, it's in an include file (!) + Also note that moment.js is deprecated */ + +describe("Breadcrumbs tests", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + }); + + it("Breadcrumbs", () => { + cy.visit("/cgi-bin/koha/admin/admin-home.pl"); + cy.contains("Record sources").click(); + cy.get("#breadcrumbs").contains("Administration"); + cy.get(".item-last").contains("Record sources"); + // use the 'New' button + cy.contains("New record source").click(); + cy.wait(500); + cy.get(".item-last").contains("Add record source"); + cy.get("#breadcrumbs") + .contains("Record sources") + .should("have.attr", "href") + .and("equal", "/cgi-bin/koha/admin/record-sources"); + }); +}); + +describe("Record sources CRUD tests", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + }); + + it("Add", () => { + cy.visit("/cgi-bin/koha/admin/admin-home.pl"); + cy.contains("Record sources").click(); + // use the 'New' button + cy.contains("New record source").click(); + // fill the form + cy.get("#name").type("Poop"); + + // Submit the form, get 500 + cy.intercept("POST", "/api/v1/record_sources", { + statusCode: 201, + body: {} + }); + cy.get("#record_source_edit").contains("Submit").click(); + }); + + it("Edit", () => { + cy.visit("/cgi-bin/koha/admin/admin-home.pl"); + cy.contains("Record sources").click(); + cy.get("#breadcrumbs").contains("Administration"); + cy.get(".item-last").contains("Record sources"); + }); + + it("List", () => { + cy.visit("/cgi-bin/koha/admin/admin-home.pl"); + cy.contains("Record sources").click(); + cy.get("#breadcrumbs").contains("Administration"); + cy.get(".item-last").contains("Record sources"); + }); + + it("Delete", () => { + cy.visit("/cgi-bin/koha/admin/admin-home.pl"); + cy.contains("Record sources").click(); + cy.get("#breadcrumbs").contains("Administration"); + cy.get(".item-last").contains("Record sources"); + }); +}); -- 2.43.0