Bug 34691: Add cypress tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Pedro Amorim 2023-09-01 13:31:23 +00:00 committed by Tomas Cohen Arazi
parent 8c63a4bb04
commit 6b74b5df5a
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
5 changed files with 18 additions and 0 deletions

View File

@ -255,6 +255,7 @@ describe("Agreement CRUD operations", () => {
cy.visit("/cgi-bin/koha/erm/agreements");
cy.contains("New agreement").click();
cy.get("#agreements_add h2").contains("New agreement");
cy.left_menu_active_item_is("Agreements");
// Fill in the form for normal attributes
let agreement = get_agreement();
@ -492,6 +493,7 @@ describe("Agreement CRUD operations", () => {
cy.wait("@get-agreement");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#agreements_add h2").contains("Edit agreement");
cy.left_menu_active_item_is("Agreements");
// Form has been correctly filled in
cy.get("#agreement_name").should("have.value", agreements[0].name);
@ -579,6 +581,7 @@ describe("Agreement CRUD operations", () => {
cy.get("#agreements_show h2").contains(
"Agreement #" + agreement.agreement_id
);
cy.left_menu_active_item_is("Agreements");
// TODO There are more to test here:
// Dates correctly formatted

View File

@ -82,6 +82,7 @@ describe("License CRUD operations", () => {
cy.visit("/cgi-bin/koha/erm/licenses");
cy.contains("New license").click();
cy.get("#licenses_add h2").contains("New license");
cy.left_menu_active_item_is("Licenses");
// Fill in the form for normal attributes
let license = get_license();
@ -169,6 +170,7 @@ describe("License CRUD operations", () => {
cy.wait("@get-license");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#licenses_add h2").contains("Edit license");
cy.left_menu_active_item_is("Licenses");
// Form has been correctly filled in
cy.get("#license_name").should("have.value", license.name);
@ -230,6 +232,7 @@ describe("License CRUD operations", () => {
cy.wait("@get-license");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#licenses_show h2").contains("License #" + license.license_id);
cy.left_menu_active_item_is("Licenses");
});
it("Delete license", () => {

View File

@ -86,6 +86,7 @@ describe("Package CRUD operations", () => {
cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
cy.contains("New package").click();
cy.get("#packages_add h2").contains("New package");
cy.left_menu_active_item_is("Packages");
// Fill in the form for normal attributes
let erm_package = get_package();
@ -171,6 +172,7 @@ describe("Package CRUD operations", () => {
cy.wait("@get-package");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#packages_add h2").contains("Edit package");
cy.left_menu_active_item_is("Packages");
// Form has been correctly filled in
cy.get("#package_name").should("have.value", erm_package.name);
@ -232,6 +234,8 @@ describe("Package CRUD operations", () => {
cy.get("#packages_show h2").contains(
"Package #" + erm_package.package_id
);
cy.left_menu_active_item_is("Packages");
// There are no resources, the table should not be displayed
cy.contains("Titles (0)");
cy.get("#title_list_result table").should("not.exist");

View File

@ -47,6 +47,7 @@ describe("Title CRUD operations", () => {
cy.wait(500);
cy.get("#toolbar a").contains("Import from list").click();
cy.get("h2").contains("Import from a list");
cy.left_menu_active_item_is("Titles");
cy.get("#package_list .vs__selected").should("not.exist");
// Make sure packages are returned
@ -127,6 +128,7 @@ describe("Title CRUD operations", () => {
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.contains("New title").click();
cy.get("#titles_add h2").contains("New title");
cy.left_menu_active_item_is("Titles");
// Fill in the form for normal attributes
let erm_title = cy.get_title();
@ -249,6 +251,7 @@ describe("Title CRUD operations", () => {
cy.wait("@get-title");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#titles_add h2").contains("Edit title");
cy.left_menu_active_item_is("Titles");
// Form has been correctly filled in
cy.get("#title_publication_title").should(
@ -402,6 +405,7 @@ describe("Title CRUD operations", () => {
cy.get("#eholdings_title_show h2").contains(
"Title #" + erm_title.title_id
);
cy.left_menu_active_item_is("Titles");
// There are no packages, the table should not be displayed
cy.contains("Packages (0)");
cy.get("#table#package_list").should("not.exist");

View File

@ -19,6 +19,10 @@ import './commands';
// Alternatively you can use CommonJS syntax:
// require('./commands')
Cypress.Commands.add('left_menu_active_item_is', (label) => {
cy.get("#navmenulist a.current:not(.disabled)").should('have.length',1).contains(label);
})
cy.get_title = () => {
return {
access_type: "access type",