From 957563c612e09172294ca1e487a8210267b08487 Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Thu, 14 Nov 2024 14:34:48 +0000 Subject: [PATCH] Bug 37576: (follow-up) fix broken cypress tests This patch is intended to fix failing Cypress tests by including the correct payload in get_agreement() found in e2e.js, and by moving get_package to the e2e.js with corrected payload also --- t/cypress/integration/ERM/Packages_spec.ts | 31 +---- t/cypress/support/e2e.js | 141 +++++++++++++++++++++ 2 files changed, 146 insertions(+), 26 deletions(-) diff --git a/t/cypress/integration/ERM/Packages_spec.ts b/t/cypress/integration/ERM/Packages_spec.ts index 746b5b3bd11..fe8e9d1d232 100644 --- a/t/cypress/integration/ERM/Packages_spec.ts +++ b/t/cypress/integration/ERM/Packages_spec.ts @@ -2,27 +2,6 @@ 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 */ -function get_package() { - return { - package_id: 1, - name: "package 1", - package_type: "complete", - content_type: "Print", - package_agreements: [ - { - agreement: { - agreement_id: 2, - description: "agreement description", - name: "agreement name", - }, - agreement_id: 2, - package_id: 1, - }, - ], - resources_count: 0, - }; -} - describe("Package CRUD operations", () => { beforeEach(() => { cy.login(); @@ -58,7 +37,7 @@ describe("Package CRUD operations", () => { cy.get("#packages_list").contains("There are no packages defined"); // GET packages returns something - let erm_package = get_package(); + let erm_package = cy.get_package(); let packages = [erm_package]; cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { @@ -88,7 +67,7 @@ describe("Package CRUD operations", () => { cy.left_menu_active_item_is("Packages"); // Fill in the form for normal attributes - let erm_package = get_package(); + let erm_package = cy.get_package(); cy.get("#packages_add").contains("Submit").click(); cy.get("input:invalid,textarea:invalid,select:invalid").should( @@ -146,7 +125,7 @@ describe("Package CRUD operations", () => { }); it("Edit package", () => { - let erm_package = get_package(); + let erm_package = cy.get_package(); let packages = [erm_package]; // Click the 'Edit' button from the list cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { @@ -205,7 +184,7 @@ describe("Package CRUD operations", () => { }); it("Show package", () => { - let erm_package = get_package(); + let erm_package = cy.get_package(); let packages = [erm_package]; // Click the "name" link from the list cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { @@ -277,7 +256,7 @@ describe("Package CRUD operations", () => { }); it("Delete package", () => { - let erm_package = get_package(); + let erm_package = cy.get_package(); let packages = [erm_package]; // Click the 'Delete' button from the list diff --git a/t/cypress/support/e2e.js b/t/cypress/support/e2e.js index 27d79e47c60..1f16b449779 100644 --- a/t/cypress/support/e2e.js +++ b/t/cypress/support/e2e.js @@ -214,6 +214,147 @@ cy.get_agreement = () => { uploaded_on: "2022-10-27T11:57:02+00:00", }, ], + extended_attributes: [ + { + field_id: 1, + id: "1", + record_id: "1", + value: "REF", + }, + { + field_id: 1, + id: "2", + record_id: "1", + value: "NFIC", + }, + { + field_id: 2, + id: "3", + record_id: "1", + value: "some text", + }, + { + field_id: 3, + id: "4", + record_id: "1", + value: "some repeatable text", + }, + { + field_id: 4, + id: "5", + record_id: "1", + value: "AF", + }, + ], + _strings: { + additional_field_values: [ + { + field_id: 1, + field_label: "AV Repeatable", + type: "av", + value_str: "Reference, Non-fiction", + }, + { + field_id: 2, + field_label: "Text non-repeatable", + type: "text", + value_str: "some text", + }, + { + field_id: 3, + field_label: "Text repeatable", + type: "text", + value_str: "some repeatable text", + }, + { + field_id: 4, + field_label: "AV Searchable", + type: "av", + value_str: "Afghanistan", + }, + ], + } + }; +} + +cy.get_package = () => { + return { + package_id: 1, + name: "package 1", + package_type: "complete", + content_type: "Print", + package_agreements: [ + { + agreement: { + agreement_id: 2, + description: "agreement description", + name: "agreement name", + }, + agreement_id: 2, + package_id: 1, + }, + ], + extended_attributes: [ + { + field_id: 1, + id: "1", + record_id: "1", + value: "REF", + }, + { + field_id: 1, + id: "2", + record_id: "1", + value: "NFIC", + }, + { + field_id: 2, + id: "3", + record_id: "1", + value: "some text", + }, + { + field_id: 3, + id: "4", + record_id: "1", + value: "some repeatable text", + }, + { + field_id: 4, + id: "5", + record_id: "1", + value: "AF", + }, + ], + _strings: { + additional_field_values: [ + { + field_id: 1, + field_label: "AV Repeatable", + type: "av", + value_str: "Reference, Non-fiction", + }, + { + field_id: 2, + field_label: "Text non-repeatable", + type: "text", + value_str: "some text", + }, + { + field_id: 3, + field_label: "Text repeatable", + type: "text", + value_str: "some repeatable text", + }, + { + field_id: 4, + field_label: "AV Searchable", + type: "av", + value_str: "Afghanistan", + }, + ], + }, + resources_count: 0, }; } -- 2.43.0