Bugzilla – Attachment 155260 Details for
Bug 34217
Add missing cypress tests for vendors in agreements and licenses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34217: Add vendor tests for agreements and licenses
Bug-34217-Add-vendor-tests-for-agreements-and-lice.patch (text/plain), 7.06 KB, created by
Pedro Amorim
on 2023-09-06 09:12:07 UTC
(
hide
)
Description:
Bug 34217: Add vendor tests for agreements and licenses
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-09-06 09:12:07 UTC
Size:
7.06 KB
patch
obsolete
>From e619359fd833c5c092851e9e134947ec39a1c19a Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 6 Jul 2023 10:14:11 +0000 >Subject: [PATCH] Bug 34217: Add vendor tests for agreements and licenses > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../js/vue/components/ERM/LicensesFormAdd.vue | 7 ----- > t/cypress/integration/ERM/Agreements_spec.ts | 29 +++++++++++++++++- > t/cypress/integration/ERM/Licenses_spec.ts | 30 +++++++++++++++++++ > t/cypress/support/e2e.js | 15 ++++++++++ > 4 files changed, 73 insertions(+), 8 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue >index 674ac5cc09..9df7727489 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue >@@ -232,13 +232,6 @@ export default { > return false > } > >- let apiUrl = "/api/v1/erm/licenses" >- >- let method = "POST" >- if (license.license_id) { >- method = "PUT" >- apiUrl += "/" + license.license_id >- } > delete license.license_id > delete license.vendor > >diff --git a/t/cypress/integration/ERM/Agreements_spec.ts b/t/cypress/integration/ERM/Agreements_spec.ts >index 440ed51275..f743d8b193 100644 >--- a/t/cypress/integration/ERM/Agreements_spec.ts >+++ b/t/cypress/integration/ERM/Agreements_spec.ts >@@ -18,7 +18,8 @@ function get_agreement() { > name: "agreement 1", > renewal_priority: "", > status: "active", >- vendor_id: null, >+ vendor_id: 1, >+ vendor: [cy.get_vendors_to_relate()[0]], > periods: [ > { > started_on: dates["today_iso"], >@@ -259,6 +260,7 @@ describe("Agreement CRUD operations", () => { > > // Fill in the form for normal attributes > let agreement = get_agreement(); >+ let vendors = cy.get_vendors_to_relate(); > > cy.get("#agreements_add").contains("Submit").click(); > cy.get("input:invalid,textarea:invalid,select:invalid").should( >@@ -277,6 +279,15 @@ describe("Agreement CRUD operations", () => { > { force: true } > ); > >+ // vendors >+ cy.get("#agreement_vendor_id .vs__selected").should("not.exist"); //no vendor pre-selected for new agreement >+ >+ cy.get("#agreement_vendor_id .vs__search").type( >+ vendors[0].name + "{enter}", >+ { force: true } >+ ); >+ cy.get("#agreement_vendor_id .vs__selected").contains(vendors[0].name); >+ > cy.contains("Add new period").click(); > cy.get("#agreements_add").contains("Submit").click(); > cy.get("input:invalid,textarea:invalid,select:invalid").should( >@@ -446,6 +457,13 @@ describe("Agreement CRUD operations", () => { > let licenses_to_relate = get_licenses_to_relate(); > let agreement = get_agreement(); > let agreements = [agreement]; >+ let vendors = cy.get_vendors_to_relate(); >+ >+ // Intercept vendors request >+ cy.intercept("GET", "/api/v1/acquisitions/vendors?_per_page=-1", { >+ statusCode: 200, >+ body: vendors, >+ }).as("get-vendor-options"); > > // Intercept initial /agreements request once > cy.intercept( >@@ -502,6 +520,15 @@ describe("Agreement CRUD operations", () => { > agreements[0].description > ); > cy.get("#agreement_status .vs__selected").contains("Active"); >+ cy.get("#agreement_vendor_id .vs__selected").contains( >+ agreement.vendor[0].name >+ ); >+ >+ cy.get("#agreement_vendor_id .vs__search").type( >+ vendors[1].name + "{enter}", >+ { force: true } >+ ); >+ > cy.get("#agreement_is_perpetual_no").should("be.checked"); > cy.get("#started_on_0").invoke("val").should("eq", dates["today_iso"]); > cy.get("#ended_on_0").invoke("val").should("eq", dates["tomorrow_iso"]); >diff --git a/t/cypress/integration/ERM/Licenses_spec.ts b/t/cypress/integration/ERM/Licenses_spec.ts >index c3d1649d6a..8b53c13ae4 100644 >--- a/t/cypress/integration/ERM/Licenses_spec.ts >+++ b/t/cypress/integration/ERM/Licenses_spec.ts >@@ -18,6 +18,8 @@ function get_license() { > started_on: dates["today_iso"], > ended_on: dates["tomorrow_iso"], > user_roles: [], >+ vendor_id: 1, >+ vendor: [cy.get_vendors_to_relate()[0]], > documents: [ > { > license_id: 1, >@@ -86,6 +88,7 @@ describe("License CRUD operations", () => { > > // Fill in the form for normal attributes > let license = get_license(); >+ let vendors = cy.get_vendors_to_relate(); > > cy.get("#licenses_add").contains("Submit").click(); > cy.get("input:invalid,textarea:invalid,select:invalid").should( >@@ -102,6 +105,15 @@ describe("License CRUD operations", () => { > force: true, > }); > >+ // vendors >+ cy.get("#license_vendor_id .vs__selected").should("not.exist"); //no vendor pre-selected for new license >+ >+ cy.get("#license_vendor_id .vs__search").type( >+ vendors[0].name + "{enter}", >+ { force: true } >+ ); >+ cy.get("#license_vendor_id .vs__selected").contains(vendors[0].name); >+ > cy.get("#started_on+input").click(); > cy.get(".flatpickr-calendar") > .eq(0) >@@ -153,6 +165,14 @@ describe("License CRUD operations", () => { > it("Edit license", () => { > let license = get_license(); > let licenses = [license]; >+ let vendors = cy.get_vendors_to_relate(); >+ >+ // Intercept vendors request >+ cy.intercept("GET", "/api/v1/acquisitions/vendors?_per_page=-1", { >+ statusCode: 200, >+ body: vendors, >+ }).as("get-vendor-options"); >+ > // Click the 'Edit' button from the list > cy.intercept("GET", "/api/v1/erm/licenses*", { > statusCode: 200, >@@ -174,6 +194,16 @@ describe("License CRUD operations", () => { > > // Form has been correctly filled in > cy.get("#license_name").should("have.value", license.name); >+ >+ cy.get("#license_vendor_id .vs__selected").contains( >+ license.vendor[0].name >+ ); >+ >+ cy.get("#license_vendor_id .vs__search").type( >+ vendors[1].name + "{enter}", >+ { force: true } >+ ); >+ > cy.get("#license_description").should( > "have.value", > license.description >diff --git a/t/cypress/support/e2e.js b/t/cypress/support/e2e.js >index afb2dfd49d..a936f91537 100644 >--- a/t/cypress/support/e2e.js >+++ b/t/cypress/support/e2e.js >@@ -112,3 +112,18 @@ cy.get_agreements_to_relate = () => { > }, > ] > } >+ >+cy.get_vendors_to_relate = () => { >+ return [ >+ { >+ "id": 1, >+ "name": "My Vendor", >+ "aliases": [], >+ }, >+ { >+ "id": 2, >+ "name": "My Vendor 2", >+ "aliases": [], >+ } >+ ] >+} >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34217
:
153088
|
153266
|
153722
|
154794
|
154996
|
154997
|
154998
|
155257
|
155258
|
155259
|
155260