From 7161a79effb3a6ebf346c2329766b04bfff13027 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 24 Oct 2023 16:47:47 -0300 Subject: [PATCH] Bug 32607: Add cypress tests --- t/cypress/integration/RecordSources_spec.ts | 82 +++++++++++++++++++++ 1 file changed, 82 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..4acd0687aab --- /dev/null +++ b/t/cypress/integration/RecordSources_spec.ts @@ -0,0 +1,82 @@ +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"); + // there's no (and there will be no) way to interact with the pop-up window + // FIXME: Is this a good reason to move this to a modal? + // https://docs.cypress.io/guides/references/trade-offs#Permanent-trade-offs + cy.get("#selected_patron_id").type("1", { force: true }); + + // Submit the form, get 500 + cy.intercept("POST", "/api/v1/record_sources", { + statusCode: 500, + error: "Something went wrong", + }); + cy.get("#record_source_edit").contains("Submit").click(); + cy.get("main div[class='dialog alert']").contains( + "Something went wrong: SyntaxError: Unexpected end of JSON input" + ); + }); + + 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.42.0