From 9d60d2346d3cc5119fc20e1d5275be8c40a6ec03 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 14 Sep 2023 12:27:20 +0000 Subject: [PATCH] Bug 34789: Update unit tests Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 4ec7c6a62ec12abe1ea092e0fbbdcc6e7ecee110) Signed-off-by: Fridolin Somers (cherry picked from commit bac14ffe0876f077e04ab825df56143db3af121d) Signed-off-by: Matt Blenkinsop --- t/cypress/integration/ERM/Titles_spec.ts | 265 ++++++++++++------- t/cypress/support/index.js | 2 +- t/db_dependent/api/v1/erm_eholdings_titles.t | 4 +- 3 files changed, 177 insertions(+), 94 deletions(-) diff --git a/t/cypress/integration/ERM/Titles_spec.ts b/t/cypress/integration/ERM/Titles_spec.ts index 942150d0f3..413ba60520 100644 --- a/t/cypress/integration/ERM/Titles_spec.ts +++ b/t/cypress/integration/ERM/Titles_spec.ts @@ -7,22 +7,30 @@ function get_packages_to_relate() { { package_id: 1, description: "a package", - name: "first package name" + name: "first package name", }, { package_id: 2, description: "a second package", - name: "second package name" - } - ] + name: "second package name", + }, + ]; } describe("Title CRUD operations", () => { beforeEach(() => { cy.login(); cy.title().should("eq", "Koha staff interface"); - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); + cy.intercept( + "GET", + "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", + '{"value":"1"}' + ); + cy.intercept( + "GET", + "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", + '{"value":"local"}' + ); }); it("Import titles", () => { @@ -32,19 +40,19 @@ describe("Title CRUD operations", () => { // Create a list in case none exists cy.visit("/cgi-bin/koha/virtualshelves/shelves.pl"); cy.contains("New list").click(); - cy.get("#shelfname").type('list name'); + cy.get("#shelfname").type("list name"); cy.contains("Save").click(); // First attempt to import list has no packages cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { statusCode: 200, - body: [] + body: [], }).as("get-empty-packages"); cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); cy.wait(500); cy.get("#toolbar a").contains("Import from list").click(); cy.get("h2").contains("Import from a list"); - cy.get("#package_list .vs__selected").should('not.exist'); + cy.get("#package_list .vs__selected").should("not.exist"); // Make sure packages are returned cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { @@ -59,10 +67,12 @@ describe("Title CRUD operations", () => { // Prepare background job response to the POST cy.intercept("POST", "/api/v1/erm/eholdings/local/titles/import", { statusCode: 200, - body: {job_id: 1}, + body: { job_id: 1 }, }).as("get-job-response"); cy.get("#list_list tbody tr:first td a").contains("Import").click(); - cy.get("main div[class='dialog message']").contains("Import in progress, see job #1"); + cy.get("main div[class='dialog message']").contains( + "Import in progress, see job #1" + ); }); it("List title", () => { @@ -106,15 +116,16 @@ describe("Title CRUD operations", () => { }); it("Add title", () => { - - cy.intercept({ - method: "GET", - url: "/api/v1/erm/eholdings/local/packages*", - times: 1 - }, - { - body: [], - }); + cy.intercept( + { + method: "GET", + url: "/api/v1/erm/eholdings/local/packages*", + times: 1, + }, + { + body: [], + } + ); // Click the button in the toolbar cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); @@ -133,12 +144,24 @@ describe("Title CRUD operations", () => { cy.get("#title_publication_title").type(erm_title.publication_title); cy.get("#title_print_identifier").type(erm_title.print_identifier); cy.get("#title_online_identifier").type(erm_title.online_identifier); - cy.get("#title_date_first_issue_online").type(erm_title.date_first_issue_online); - cy.get("#title_num_first_vol_online").type(erm_title.num_first_vol_online); - cy.get("#title_num_first_issue_online").type(erm_title.num_first_issue_online); - cy.get("#title_date_last_issue_online").type(erm_title.date_last_issue_online); - cy.get("#title_num_last_vol_online").type(erm_title.num_last_vol_online); - cy.get("#title_num_last_issue_online").type(erm_title.num_last_issue_online); + cy.get("#title_date_first_issue_online").type( + erm_title.date_first_issue_online + ); + cy.get("#title_num_first_vol_online").type( + erm_title.num_first_vol_online + ); + cy.get("#title_num_first_issue_online").type( + erm_title.num_first_issue_online + ); + cy.get("#title_date_last_issue_online").type( + erm_title.date_last_issue_online + ); + cy.get("#title_num_last_vol_online").type( + erm_title.num_last_vol_online + ); + cy.get("#title_num_last_issue_online").type( + erm_title.num_last_issue_online + ); cy.get("#title_title_url").type(erm_title.title_url); cy.get("#title_first_author").type(erm_title.first_author); cy.get("#title_embargo_info").type(erm_title.embargo_info); @@ -149,18 +172,24 @@ describe("Title CRUD operations", () => { erm_title.publication_type + "{enter}", { force: true } ); - cy.get("#title_date_monograph_published_print").type(erm_title.date_monograph_published_print); - cy.get("#title_date_monograph_published_online").type(erm_title.date_monograph_published_online); + cy.get("#title_date_monograph_published_print").type( + erm_title.date_monograph_published_print + ); + cy.get("#title_date_monograph_published_online").type( + erm_title.date_monograph_published_online + ); cy.get("#title_monograph_volume").type(erm_title.monograph_volume); cy.get("#title_monograph_edition").type(erm_title.monograph_edition); cy.get("#title_first_editor").type(erm_title.first_editor); - cy.get("#title_parent_publication_title_id").type(erm_title.parent_publication_title_id); - cy.get("#title_preceeding_publication_title_id").type(erm_title.preceeding_publication_title_id); + cy.get("#title_parent_publication_title_id").type( + erm_title.parent_publication_title_id + ); + cy.get("#title_preceding_publication_title_id").type( + erm_title.preceding_publication_title_id + ); cy.get("#title_access_type").type(erm_title.access_type); - cy.get("#resources").contains( - "There are no packages created yet" - ); + cy.get("#resources").contains("There are no packages created yet"); // Submit the form, get 500 cy.intercept("POST", "/api/v1/erm/eholdings/local/titles", { @@ -185,14 +214,16 @@ describe("Title CRUD operations", () => { cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { statusCode: 200, body: get_packages_to_relate(), - }).as('get-related-packages'); + }).as("get-related-packages"); cy.visit("/cgi-bin/koha/erm/eholdings/local/titles/add"); cy.get("#resources").contains("Add to another package").click(); cy.get("#resources").contains("Package 1"); cy.get("#resources #resource_package_id_0 .vs__search").type( related_package.package.name ); - cy.get("#resources #resource_package_id_0 .vs__dropdown-menu li").eq(0).click( { force: true } ); //click first package suggestion + cy.get("#resources #resource_package_id_0 .vs__dropdown-menu li") + .eq(0) + .click({ force: true }); //click first package suggestion }); it("Edit title", () => { @@ -217,7 +248,7 @@ describe("Title CRUD operations", () => { cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { statusCode: 200, body: get_packages_to_relate(), - }).as('get-related-packages'); + }).as("get-related-packages"); cy.get("#titles_list table tbody tr:first").contains("Edit").click(); cy.wait("@get-title"); @@ -225,33 +256,98 @@ describe("Title CRUD operations", () => { cy.get("#titles_add h2").contains("Edit title"); // Form has been correctly filled in - cy.get("#title_publication_title").should("have.value", erm_title.publication_title); - cy.get("#title_print_identifier").should("have.value", erm_title.print_identifier); - cy.get("#title_online_identifier").should("have.value", erm_title.online_identifier); - cy.get("#title_date_first_issue_online").should("have.value", erm_title.date_first_issue_online); - cy.get("#title_num_first_vol_online").should("have.value", erm_title.num_first_vol_online); - cy.get("#title_num_first_issue_online").should("have.value", erm_title.num_first_issue_online); - cy.get("#title_date_last_issue_online").should("have.value", erm_title.date_last_issue_online); - cy.get("#title_num_last_vol_online").should("have.value", erm_title.num_last_vol_online); - cy.get("#title_num_last_issue_online").should("have.value", erm_title.num_last_issue_online); + cy.get("#title_publication_title").should( + "have.value", + erm_title.publication_title + ); + cy.get("#title_print_identifier").should( + "have.value", + erm_title.print_identifier + ); + cy.get("#title_online_identifier").should( + "have.value", + erm_title.online_identifier + ); + cy.get("#title_date_first_issue_online").should( + "have.value", + erm_title.date_first_issue_online + ); + cy.get("#title_num_first_vol_online").should( + "have.value", + erm_title.num_first_vol_online + ); + cy.get("#title_num_first_issue_online").should( + "have.value", + erm_title.num_first_issue_online + ); + cy.get("#title_date_last_issue_online").should( + "have.value", + erm_title.date_last_issue_online + ); + cy.get("#title_num_last_vol_online").should( + "have.value", + erm_title.num_last_vol_online + ); + cy.get("#title_num_last_issue_online").should( + "have.value", + erm_title.num_last_issue_online + ); cy.get("#title_title_url").should("have.value", erm_title.title_url); - cy.get("#title_first_author").should("have.value", erm_title.first_author); - cy.get("#title_embargo_info").should("have.value", erm_title.embargo_info); - cy.get("#title_coverage_depth").should("have.value", erm_title.coverage_depth); + cy.get("#title_first_author").should( + "have.value", + erm_title.first_author + ); + cy.get("#title_embargo_info").should( + "have.value", + erm_title.embargo_info + ); + cy.get("#title_coverage_depth").should( + "have.value", + erm_title.coverage_depth + ); cy.get("#title_notes").should("have.value", erm_title.notes); - cy.get("#title_publisher_name").should("have.value", erm_title.publisher_name); - cy.get("#title_publication_type .vs__selected").contains('Journal'); - cy.get("#title_date_monograph_published_print").should("have.value", erm_title.date_monograph_published_print); - cy.get("#title_date_monograph_published_online").should("have.value", erm_title.date_monograph_published_online); - cy.get("#title_monograph_volume").should("have.value", erm_title.monograph_volume); - cy.get("#title_monograph_edition").should("have.value", erm_title.monograph_edition); - cy.get("#title_first_editor").should("have.value", erm_title.first_editor); - cy.get("#title_parent_publication_title_id").should("have.value", erm_title.parent_publication_title_id); - cy.get("#title_preceeding_publication_title_id").should("have.value", erm_title.preceeding_publication_title_id); - cy.get("#title_access_type").should("have.value", erm_title.access_type); + cy.get("#title_publisher_name").should( + "have.value", + erm_title.publisher_name + ); + cy.get("#title_publication_type .vs__selected").contains("Journal"); + cy.get("#title_date_monograph_published_print").should( + "have.value", + erm_title.date_monograph_published_print + ); + cy.get("#title_date_monograph_published_online").should( + "have.value", + erm_title.date_monograph_published_online + ); + cy.get("#title_monograph_volume").should( + "have.value", + erm_title.monograph_volume + ); + cy.get("#title_monograph_edition").should( + "have.value", + erm_title.monograph_edition + ); + cy.get("#title_first_editor").should( + "have.value", + erm_title.first_editor + ); + cy.get("#title_parent_publication_title_id").should( + "have.value", + erm_title.parent_publication_title_id + ); + cy.get("#title_preceding_publication_title_id").should( + "have.value", + erm_title.preceding_publication_title_id + ); + cy.get("#title_access_type").should( + "have.value", + erm_title.access_type + ); //Test related content - cy.get("#resources #resource_package_id_0 .vs__selected").contains("package name"); + cy.get("#resources #resource_package_id_0 .vs__selected").contains( + "package name" + ); // Submit the form, get 500 cy.intercept("PUT", "/api/v1/erm/eholdings/local/titles/*", { @@ -289,27 +385,23 @@ describe("Title CRUD operations", () => { { method: "GET", url: "/api/v1/erm/eholdings/local/titles/*", - times: 1 + times: 1, }, { body: { publication_title: "publication title", resources: [], title_id: 1, - } + }, } ).as("get-title"); cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); - let title_link = cy.get( - "#titles_list table tbody tr:first td:first a" - ); + let title_link = cy.get("#titles_list table tbody tr:first td:first a"); title_link.should( "have.text", erm_title.publication_title + " (#" + erm_title.title_id + ")" ); - cy.get( - "#titles_list table tbody tr:first td:first a" - ).click(); + cy.get("#titles_list table tbody tr:first td:first a").click(); cy.wait("@get-title"); cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! cy.get("#eholdings_title_show h2").contains( @@ -336,11 +428,12 @@ describe("Title CRUD operations", () => { // cy.get("#package_list tbody tr:first td a").contains("first package name").click(); cy.intercept( "GET", - "/api/v1/erm/eholdings/local/resources/"+related_package.resource_id, + "/api/v1/erm/eholdings/local/resources/" + + related_package.resource_id, related_package ).as("get-related-package"); cy.get("table#package_list").contains("first package name").click(); - cy.contains("Resource #"+related_package.resource_id); + cy.contains("Resource #" + related_package.resource_id); cy.contains(related_package.package.name); }); @@ -357,16 +450,10 @@ describe("Title CRUD operations", () => { "X-Total-Count": "1", }, }); - cy.intercept( - "GET", - "/api/v1/erm/eholdings/local/titles/*", - erm_title - ); + cy.intercept("GET", "/api/v1/erm/eholdings/local/titles/*", erm_title); cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); - cy.get("#titles_list table tbody tr:first") - .contains("Delete") - .click(); + cy.get("#titles_list table tbody tr:first").contains("Delete").click(); cy.get(".dialog.alert.confirmation h1").contains("remove this title"); cy.contains(erm_title.publication_title); @@ -385,12 +472,12 @@ describe("Title CRUD operations", () => { statusCode: 204, body: null, }); - cy.get("#titles_list table tbody tr:first") - .contains("Delete") - .click(); + cy.get("#titles_list table tbody tr:first").contains("Delete").click(); cy.get(".dialog.alert.confirmation h1").contains("remove this title"); cy.contains("Yes, delete").click(); - cy.get("main div[class='dialog message']").contains("Local title").contains("deleted"); + cy.get("main div[class='dialog message']") + .contains("Local title") + .contains("deleted"); // Delete from show // Click the "name" link from the list @@ -407,38 +494,34 @@ describe("Title CRUD operations", () => { { method: "GET", url: "/api/v1/erm/eholdings/local/titles/*", - times: 1 + times: 1, }, { body: { publication_title: "publication title", resources: [], title_id: 1, - } + }, } ).as("get-title"); cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); - let title_link = cy.get( - "#titles_list table tbody tr:first td:first a" - ); + let title_link = cy.get("#titles_list table tbody tr:first td:first a"); title_link.should( "have.text", erm_title.publication_title + " (#" + erm_title.title_id + ")" ); - cy.get( - "#titles_list table tbody tr:first td:first a" - ).click(); + cy.get("#titles_list table tbody tr:first td:first a").click(); cy.wait("@get-title"); cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! cy.get("#eholdings_title_show h2").contains( "Title #" + erm_title.title_id ); - cy.get('#eholdings_title_show .action_links .fa-trash').click(); + cy.get("#eholdings_title_show .action_links .fa-trash").click(); cy.get(".dialog.alert.confirmation h1").contains("remove this title"); cy.contains("Yes, delete").click(); //Make sure we return to list after deleting from show - cy.get("#titles_list table tbody tr:first") + cy.get("#titles_list table tbody tr:first"); }); }); diff --git a/t/cypress/support/index.js b/t/cypress/support/index.js index 5ced7d5f02..744d50cba2 100644 --- a/t/cypress/support/index.js +++ b/t/cypress/support/index.js @@ -41,7 +41,7 @@ cy.get_title = () => { num_last_vol_online: "num last vol", online_identifier: "online identifier", parent_publication_title_id: "parent id", - preceeding_publication_title_id: "preceeding id", + preceding_publication_title_id: "preceeding id", print_identifier: "print identifier", publication_title: "publication title", publication_type: "journal", diff --git a/t/db_dependent/api/v1/erm_eholdings_titles.t b/t/db_dependent/api/v1/erm_eholdings_titles.t index 943e581831..17b5a022f0 100755 --- a/t/db_dependent/api/v1/erm_eholdings_titles.t +++ b/t/db_dependent/api/v1/erm_eholdings_titles.t @@ -241,7 +241,7 @@ subtest 'add() tests' => sub { first_editor => "First editor", parent_publication_title_id => "Title identifier of the parent publication", - preceeding_publication_title_id => + preceding_publication_title_id => "Title identifier of any preceding publication title", access_type => "Access type" }; @@ -415,7 +415,7 @@ subtest 'update() tests' => sub { first_editor => "First editor", parent_publication_title_id => "Title identifier of the parent publication", - preceeding_publication_title_id => + preceding_publication_title_id => "Title identifier of any preceding publication title", access_type => "Access type" }; -- 2.39.5