View | Details | Raw Unified | Return to bug 32131
Collapse All | Expand All

(-)a/t/cypress/integration/Agreements_spec.ts (+9 lines)
Lines 117-125 function get_licenses_to_relate() { Link Here
117
}
117
}
118
118
119
describe("Agreement CRUD operations", () => {
119
describe("Agreement CRUD operations", () => {
120
    before(() => {
121
        cy.fetch_initial_ERM_sys_pref_value();
122
    });
123
120
    beforeEach(() => {
124
    beforeEach(() => {
121
        cy.login("koha", "koha");
125
        cy.login("koha", "koha");
122
        cy.title().should("eq", "Koha staff interface");
126
        cy.title().should("eq", "Koha staff interface");
127
        cy.set_ERM_sys_pref_value(true);
128
    });
129
130
    after(() => {
131
        cy.reset_initial_ERM_sys_pref_value();
123
    });
132
    });
124
133
125
    it("List agreements", () => {
134
    it("List agreements", () => {
(-)a/t/cypress/integration/Licenses_spec.ts (+9 lines)
Lines 33-41 function get_license() { Link Here
33
}
33
}
34
34
35
describe("License CRUD operations", () => {
35
describe("License CRUD operations", () => {
36
    before(() => {
37
        cy.fetch_initial_ERM_sys_pref_value();
38
    });
39
36
    beforeEach(() => {
40
    beforeEach(() => {
37
        cy.login("koha", "koha");
41
        cy.login("koha", "koha");
38
        cy.title().should("eq", "Koha staff interface");
42
        cy.title().should("eq", "Koha staff interface");
43
        cy.set_ERM_sys_pref_value(true);
44
    });
45
46
    after(() => {
47
        cy.reset_initial_ERM_sys_pref_value();
39
    });
48
    });
40
49
41
    it("List license", () => {
50
    it("List license", () => {
(-)a/t/cypress/integration/Packages_spec.ts (+9 lines)
Lines 24-32 function get_package() { Link Here
24
}
24
}
25
25
26
describe("Package CRUD operations", () => {
26
describe("Package CRUD operations", () => {
27
    before(() => {
28
        cy.fetch_initial_ERM_sys_pref_value();
29
    });
30
27
    beforeEach(() => {
31
    beforeEach(() => {
28
        cy.login("koha", "koha");
32
        cy.login("koha", "koha");
29
        cy.title().should("eq", "Koha staff interface");
33
        cy.title().should("eq", "Koha staff interface");
34
        cy.set_ERM_sys_pref_value(true);
35
    });
36
37
    after(() => {
38
        cy.reset_initial_ERM_sys_pref_value();
30
    });
39
    });
31
40
32
    it("List package", () => {
41
    it("List package", () => {
(-)a/t/cypress/integration/Titles_spec.ts (+9 lines)
Lines 67-75 function get_packages_to_relate() { Link Here
67
}
67
}
68
68
69
describe("Title CRUD operations", () => {
69
describe("Title CRUD operations", () => {
70
    before(() => {
71
        cy.fetch_initial_ERM_sys_pref_value();
72
    });
73
70
    beforeEach(() => {
74
    beforeEach(() => {
71
        cy.login("koha", "koha");
75
        cy.login("koha", "koha");
72
        cy.title().should("eq", "Koha staff interface");
76
        cy.title().should("eq", "Koha staff interface");
77
        cy.set_ERM_sys_pref_value(true);
78
    });
79
80
    after(() => {
81
        cy.reset_initial_ERM_sys_pref_value();
73
    });
82
    });
74
83
75
    it("Import titles", () => {
84
    it("Import titles", () => {
(-)a/t/cypress/support/commands.js (-1 / +30 lines)
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
- 

Return to bug 32131