Lines 30-33
Cypress.Commands.add('login', (username, password) => {
Link Here
|
30 |
cy.get("#userid").type(username) |
30 |
cy.get("#userid").type(username) |
31 |
cy.get("#password").type(password) |
31 |
cy.get("#password").type(password) |
32 |
cy.get("#submit-button").click() |
32 |
cy.get("#submit-button").click() |
|
|
33 |
}) |
34 |
|
35 |
Cypress.Commands.add('set_ERM_sys_pref_value', (enable) => { |
36 |
cy.visit('/cgi-bin/koha/admin/admin-home.pl') |
37 |
cy.get("h4").contains("Global system preferences").click(); |
38 |
cy.get("a[title^=E-Resource]").contains("E-Resource management").click(); |
39 |
cy.get('#pref_ERMModule').then(($select) => { |
40 |
// Only enable if currently disabled, or only disable if currently enabled |
41 |
let sys_pref_value = $select.find(":selected").text().trim(); |
42 |
if (enable && sys_pref_value == 'Disable' || !enable && sys_pref_value == 'Enable') { |
43 |
cy.get("#pref_ERMModule").select(enable ? 'Enable' : 'Disable'); |
44 |
cy.get(".save-all").first().click(); |
45 |
Cypress.env("current_ERM_Module_sys_pref_value", enable); |
46 |
cy.wait(500); // Cypress is too fast! |
47 |
} |
48 |
}) |
49 |
}) |
50 |
|
51 |
Cypress.Commands.add('fetch_initial_ERM_sys_pref_value', () => { |
52 |
cy.login("koha", "koha"); |
53 |
cy.visit('/cgi-bin/koha/admin/admin-home.pl') |
54 |
cy.get("h4").contains("Global system preferences").click(); |
55 |
cy.get("a[title^=E-Resource]").contains("E-Resource management").click(); |
56 |
cy.get('#pref_ERMModule').then(($select) => { |
57 |
Cypress.env('initial_ERM_Module_sys_pref_value', $select.find(":selected").text().trim() == 'Enable'); |
58 |
}) |
59 |
}) |
60 |
|
61 |
Cypress.Commands.add('reset_initial_ERM_sys_pref_value', () => { |
62 |
cy.set_ERM_sys_pref_value(Cypress.env("initial_ERM_Module_sys_pref_value")); |
33 |
}) |
63 |
}) |
34 |
- |
|
|