Bugzilla – Attachment 144006 Details for
Bug 32131
Cypress tests are failing if ERMModule is off
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32131: Cypress tests are failing if ERMModule is off
Bug-32131-Cypress-tests-are-failing-if-ERMModule-i.patch (text/plain), 5.74 KB, created by
Martin Renvoize (ashimema)
on 2022-11-17 15:30:21 UTC
(
hide
)
Description:
Bug 32131: Cypress tests are failing if ERMModule is off
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-11-17 15:30:21 UTC
Size:
5.74 KB
patch
obsolete
>From 9aaa03942c7f95e2a1e902ad0f9dfd38a871b60c Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Sat, 12 Nov 2022 19:32:21 -0100 >Subject: [PATCH] Bug 32131: Cypress tests are failing if ERMModule is off > >This patch solves this by enabling the system preference before each test, >right after login. It also sets the system preference back to its original >initial value after the tests finish running. > >To test: >1) Disable ERMModule system preference >2) Run cypess tests: yarn cypress open / yarn cypress run >3) Verify that tests run successfully >(Optional): While tests are running, visit the system preferences panel and verify that the system preference is now "Enable". >4) Wait for the tests to finish and confirm that the system preference is set back to its original "Disable" value. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/cypress/integration/Agreements_spec.ts | 9 +++++++ > t/cypress/integration/Licenses_spec.ts | 9 +++++++ > t/cypress/integration/Packages_spec.ts | 9 +++++++ > t/cypress/integration/Titles_spec.ts | 9 +++++++ > t/cypress/support/commands.js | 30 ++++++++++++++++++++++++ > 5 files changed, 66 insertions(+) > >diff --git a/t/cypress/integration/Agreements_spec.ts b/t/cypress/integration/Agreements_spec.ts >index 5dd3b03846..22835c0bf3 100644 >--- a/t/cypress/integration/Agreements_spec.ts >+++ b/t/cypress/integration/Agreements_spec.ts >@@ -117,9 +117,18 @@ function get_licenses_to_relate() { > } > > describe("Agreement CRUD operations", () => { >+ before(() => { >+ cy.fetch_initial_ERM_sys_pref_value(); >+ }); >+ > beforeEach(() => { > cy.login("koha", "koha"); > cy.title().should("eq", "Koha staff interface"); >+ cy.set_ERM_sys_pref_value(true); >+ }); >+ >+ after(() => { >+ cy.reset_initial_ERM_sys_pref_value(); > }); > > it("List agreements", () => { >diff --git a/t/cypress/integration/Licenses_spec.ts b/t/cypress/integration/Licenses_spec.ts >index ef314bb0db..073a81b838 100644 >--- a/t/cypress/integration/Licenses_spec.ts >+++ b/t/cypress/integration/Licenses_spec.ts >@@ -33,9 +33,18 @@ function get_license() { > } > > describe("License CRUD operations", () => { >+ before(() => { >+ cy.fetch_initial_ERM_sys_pref_value(); >+ }); >+ > beforeEach(() => { > cy.login("koha", "koha"); > cy.title().should("eq", "Koha staff interface"); >+ cy.set_ERM_sys_pref_value(true); >+ }); >+ >+ after(() => { >+ cy.reset_initial_ERM_sys_pref_value(); > }); > > it("List license", () => { >diff --git a/t/cypress/integration/Packages_spec.ts b/t/cypress/integration/Packages_spec.ts >index 718f411d08..fb8cf3fe60 100644 >--- a/t/cypress/integration/Packages_spec.ts >+++ b/t/cypress/integration/Packages_spec.ts >@@ -24,9 +24,18 @@ function get_package() { > } > > describe("Package CRUD operations", () => { >+ before(() => { >+ cy.fetch_initial_ERM_sys_pref_value(); >+ }); >+ > beforeEach(() => { > cy.login("koha", "koha"); > cy.title().should("eq", "Koha staff interface"); >+ cy.set_ERM_sys_pref_value(true); >+ }); >+ >+ after(() => { >+ cy.reset_initial_ERM_sys_pref_value(); > }); > > it("List package", () => { >diff --git a/t/cypress/integration/Titles_spec.ts b/t/cypress/integration/Titles_spec.ts >index 6e46b23a48..14f7a9bc06 100644 >--- a/t/cypress/integration/Titles_spec.ts >+++ b/t/cypress/integration/Titles_spec.ts >@@ -67,9 +67,18 @@ function get_packages_to_relate() { > } > > describe("Title CRUD operations", () => { >+ before(() => { >+ cy.fetch_initial_ERM_sys_pref_value(); >+ }); >+ > beforeEach(() => { > cy.login("koha", "koha"); > cy.title().should("eq", "Koha staff interface"); >+ cy.set_ERM_sys_pref_value(true); >+ }); >+ >+ after(() => { >+ cy.reset_initial_ERM_sys_pref_value(); > }); > > it("Import titles", () => { >diff --git a/t/cypress/support/commands.js b/t/cypress/support/commands.js >index be71149f90..3e8f064514 100644 >--- a/t/cypress/support/commands.js >+++ b/t/cypress/support/commands.js >@@ -30,4 +30,34 @@ Cypress.Commands.add('login', (username, password) => { > cy.get("#userid").type(username) > cy.get("#password").type(password) > cy.get("#submit-button").click() >+}) >+ >+Cypress.Commands.add('set_ERM_sys_pref_value', (enable) => { >+ cy.visit('/cgi-bin/koha/admin/admin-home.pl') >+ cy.get("h4").contains("Global system preferences").click(); >+ cy.get("a[title^=E-Resource]").contains("E-Resource management").click(); >+ cy.get('#pref_ERMModule').then(($select) => { >+ // Only enable if currently disabled, or only disable if currently enabled >+ let sys_pref_value = $select.find(":selected").text().trim(); >+ if (enable && sys_pref_value == 'Disable' || !enable && sys_pref_value == 'Enable') { >+ cy.get("#pref_ERMModule").select(enable ? 'Enable' : 'Disable'); >+ cy.get(".save-all").first().click(); >+ Cypress.env("current_ERM_Module_sys_pref_value", enable); >+ cy.wait(500); // Cypress is too fast! >+ } >+ }) >+}) >+ >+Cypress.Commands.add('fetch_initial_ERM_sys_pref_value', () => { >+ cy.login("koha", "koha"); >+ cy.visit('/cgi-bin/koha/admin/admin-home.pl') >+ cy.get("h4").contains("Global system preferences").click(); >+ cy.get("a[title^=E-Resource]").contains("E-Resource management").click(); >+ cy.get('#pref_ERMModule').then(($select) => { >+ Cypress.env('initial_ERM_Module_sys_pref_value', $select.find(":selected").text().trim() == 'Enable'); >+ }) >+}) >+ >+Cypress.Commands.add('reset_initial_ERM_sys_pref_value', () => { >+ cy.set_ERM_sys_pref_value(Cypress.env("initial_ERM_Module_sys_pref_value")); > }) >\ No newline at end of file >-- >2.20.1
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 32131
:
143803
|
143938
|
143939
|
143940
|
143941
| 144006 |
144007
|
144008
|
144009