|
Line 0
Link Here
|
| 0 |
- |
1 |
import { mount } from "@cypress/vue"; |
|
|
2 |
const dayjs = require("dayjs"); /* Cannot use our calendar JS code, it's in an include file (!) |
| 3 |
Also note that moment.js is deprecated */ |
| 4 |
|
| 5 |
describe("Breadcrumbs tests", () => { |
| 6 |
|
| 7 |
beforeEach(() => { |
| 8 |
cy.login(); |
| 9 |
cy.title().should("eq", "Koha staff interface"); |
| 10 |
}); |
| 11 |
|
| 12 |
it("Breadcrumbs", () => { |
| 13 |
|
| 14 |
cy.visit("/cgi-bin/koha/admin/admin-home.pl"); |
| 15 |
cy.contains("Record sources").click(); |
| 16 |
cy.get("#breadcrumbs").contains("Administration"); |
| 17 |
cy.get(".item-last").contains("Record sources"); |
| 18 |
// use the 'New' button |
| 19 |
cy.contains("New record source").click(); |
| 20 |
cy.wait(500); |
| 21 |
cy.get(".item-last").contains("Add record source"); |
| 22 |
cy.get("#breadcrumbs").contains("Record sources") |
| 23 |
.should("have.attr","href") |
| 24 |
.and("equal", "/cgi-bin/koha/admin/record-sources"); |
| 25 |
}); |
| 26 |
}); |
| 27 |
|
| 28 |
describe("Record sources CRUD tests", () => { |
| 29 |
|
| 30 |
beforeEach(() => { |
| 31 |
cy.login(); |
| 32 |
cy.title().should("eq", "Koha staff interface"); |
| 33 |
}); |
| 34 |
|
| 35 |
it("Add", () => { |
| 36 |
|
| 37 |
cy.visit("/cgi-bin/koha/admin/admin-home.pl"); |
| 38 |
cy.contains("Record sources").click(); |
| 39 |
// use the 'New' button |
| 40 |
cy.contains("New record source").click(); |
| 41 |
// fill the form |
| 42 |
cy.get("#name").type("Poop"); |
| 43 |
// there's no (and there will be no) way to interact with the pop-up window |
| 44 |
// FIXME: Is this a good reason to move this to a modal? |
| 45 |
// https://docs.cypress.io/guides/references/trade-offs#Permanent-trade-offs |
| 46 |
cy.get("#selected_patron_id").type("1", { force: true }); |
| 47 |
|
| 48 |
// Submit the form, get 500 |
| 49 |
cy.intercept("POST", "/api/v1/record_sources", { |
| 50 |
statusCode: 500, |
| 51 |
error: "Something went wrong", |
| 52 |
}); |
| 53 |
cy.get("#record_source_edit").contains("Submit").click(); |
| 54 |
cy.get("main div[class='dialog alert']").contains( |
| 55 |
"Something went wrong: SyntaxError: Unexpected end of JSON input" |
| 56 |
); |
| 57 |
}); |
| 58 |
|
| 59 |
it("Edit", () => { |
| 60 |
|
| 61 |
cy.visit("/cgi-bin/koha/admin/admin-home.pl"); |
| 62 |
cy.contains("Record sources").click(); |
| 63 |
cy.get("#breadcrumbs").contains("Administration"); |
| 64 |
cy.get(".item-last").contains("Record sources"); |
| 65 |
}); |
| 66 |
|
| 67 |
it("List", () => { |
| 68 |
|
| 69 |
cy.visit("/cgi-bin/koha/admin/admin-home.pl"); |
| 70 |
cy.contains("Record sources").click(); |
| 71 |
cy.get("#breadcrumbs").contains("Administration"); |
| 72 |
cy.get(".item-last").contains("Record sources"); |
| 73 |
}); |
| 74 |
|
| 75 |
it("Delete", () => { |
| 76 |
|
| 77 |
cy.visit("/cgi-bin/koha/admin/admin-home.pl"); |
| 78 |
cy.contains("Record sources").click(); |
| 79 |
cy.get("#breadcrumbs").contains("Administration"); |
| 80 |
cy.get(".item-last").contains("Record sources"); |
| 81 |
}); |
| 82 |
}); |