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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue (-7 lines)
Lines 232-244 export default { Link Here
232
                return false
232
                return false
233
            }
233
            }
234
234
235
            let apiUrl = "/api/v1/erm/licenses"
236
237
            let method = "POST"
238
            if (license.license_id) {
239
                method = "PUT"
240
                apiUrl += "/" + license.license_id
241
            }
242
            delete license.license_id
235
            delete license.license_id
243
            delete license.vendor
236
            delete license.vendor
244
237
(-)a/t/cypress/integration/ERM/Agreements_spec.ts (-1 / +28 lines)
Lines 18-24 function get_agreement() { Link Here
18
        name: "agreement 1",
18
        name: "agreement 1",
19
        renewal_priority: "",
19
        renewal_priority: "",
20
        status: "active",
20
        status: "active",
21
        vendor_id: null,
21
        vendor_id: 1,
22
        vendor: [cy.get_vendors_to_relate()[0]],
22
        periods: [
23
        periods: [
23
            {
24
            {
24
                started_on: dates["today_iso"],
25
                started_on: dates["today_iso"],
Lines 259-264 describe("Agreement CRUD operations", () => { Link Here
259
260
260
        // Fill in the form for normal attributes
261
        // Fill in the form for normal attributes
261
        let agreement = get_agreement();
262
        let agreement = get_agreement();
263
        let vendors = cy.get_vendors_to_relate();
262
264
263
        cy.get("#agreements_add").contains("Submit").click();
265
        cy.get("#agreements_add").contains("Submit").click();
264
        cy.get("input:invalid,textarea:invalid,select:invalid").should(
266
        cy.get("input:invalid,textarea:invalid,select:invalid").should(
Lines 277-282 describe("Agreement CRUD operations", () => { Link Here
277
            { force: true }
279
            { force: true }
278
        );
280
        );
279
281
282
        // vendors
283
        cy.get("#agreement_vendor_id .vs__selected").should("not.exist"); //no vendor pre-selected for new agreement
284
285
        cy.get("#agreement_vendor_id .vs__search").type(
286
            vendors[0].name + "{enter}",
287
            { force: true }
288
        );
289
        cy.get("#agreement_vendor_id .vs__selected").contains(vendors[0].name);
290
280
        cy.contains("Add new period").click();
291
        cy.contains("Add new period").click();
281
        cy.get("#agreements_add").contains("Submit").click();
292
        cy.get("#agreements_add").contains("Submit").click();
282
        cy.get("input:invalid,textarea:invalid,select:invalid").should(
293
        cy.get("input:invalid,textarea:invalid,select:invalid").should(
Lines 446-451 describe("Agreement CRUD operations", () => { Link Here
446
        let licenses_to_relate = get_licenses_to_relate();
457
        let licenses_to_relate = get_licenses_to_relate();
447
        let agreement = get_agreement();
458
        let agreement = get_agreement();
448
        let agreements = [agreement];
459
        let agreements = [agreement];
460
        let vendors = cy.get_vendors_to_relate();
461
462
        // Intercept vendors request
463
        cy.intercept("GET", "/api/v1/acquisitions/vendors?_per_page=-1", {
464
            statusCode: 200,
465
            body: vendors,
466
        }).as("get-vendor-options");
449
467
450
        // Intercept initial /agreements request once
468
        // Intercept initial /agreements request once
451
        cy.intercept(
469
        cy.intercept(
Lines 502-507 describe("Agreement CRUD operations", () => { Link Here
502
            agreements[0].description
520
            agreements[0].description
503
        );
521
        );
504
        cy.get("#agreement_status .vs__selected").contains("Active");
522
        cy.get("#agreement_status .vs__selected").contains("Active");
523
        cy.get("#agreement_vendor_id .vs__selected").contains(
524
            agreement.vendor[0].name
525
        );
526
527
        cy.get("#agreement_vendor_id .vs__search").type(
528
            vendors[1].name + "{enter}",
529
            { force: true }
530
        );
531
505
        cy.get("#agreement_is_perpetual_no").should("be.checked");
532
        cy.get("#agreement_is_perpetual_no").should("be.checked");
506
        cy.get("#started_on_0").invoke("val").should("eq", dates["today_iso"]);
533
        cy.get("#started_on_0").invoke("val").should("eq", dates["today_iso"]);
507
        cy.get("#ended_on_0").invoke("val").should("eq", dates["tomorrow_iso"]);
534
        cy.get("#ended_on_0").invoke("val").should("eq", dates["tomorrow_iso"]);
(-)a/t/cypress/integration/ERM/Licenses_spec.ts (+30 lines)
Lines 18-23 function get_license() { Link Here
18
        started_on: dates["today_iso"],
18
        started_on: dates["today_iso"],
19
        ended_on: dates["tomorrow_iso"],
19
        ended_on: dates["tomorrow_iso"],
20
        user_roles: [],
20
        user_roles: [],
21
        vendor_id: 1,
22
        vendor: [cy.get_vendors_to_relate()[0]],
21
        documents: [
23
        documents: [
22
            {
24
            {
23
                license_id: 1,
25
                license_id: 1,
Lines 86-91 describe("License CRUD operations", () => { Link Here
86
88
87
        // Fill in the form for normal attributes
89
        // Fill in the form for normal attributes
88
        let license = get_license();
90
        let license = get_license();
91
        let vendors = cy.get_vendors_to_relate();
89
92
90
        cy.get("#licenses_add").contains("Submit").click();
93
        cy.get("#licenses_add").contains("Submit").click();
91
        cy.get("input:invalid,textarea:invalid,select:invalid").should(
94
        cy.get("input:invalid,textarea:invalid,select:invalid").should(
Lines 102-107 describe("License CRUD operations", () => { Link Here
102
            force: true,
105
            force: true,
103
        });
106
        });
104
107
108
        // vendors
109
        cy.get("#license_vendor_id .vs__selected").should("not.exist"); //no vendor pre-selected for new license
110
111
        cy.get("#license_vendor_id .vs__search").type(
112
            vendors[0].name + "{enter}",
113
            { force: true }
114
        );
115
        cy.get("#license_vendor_id .vs__selected").contains(vendors[0].name);
116
105
        cy.get("#started_on+input").click();
117
        cy.get("#started_on+input").click();
106
        cy.get(".flatpickr-calendar")
118
        cy.get(".flatpickr-calendar")
107
            .eq(0)
119
            .eq(0)
Lines 153-158 describe("License CRUD operations", () => { Link Here
153
    it("Edit license", () => {
165
    it("Edit license", () => {
154
        let license = get_license();
166
        let license = get_license();
155
        let licenses = [license];
167
        let licenses = [license];
168
        let vendors = cy.get_vendors_to_relate();
169
170
        // Intercept vendors request
171
        cy.intercept("GET", "/api/v1/acquisitions/vendors?_per_page=-1", {
172
            statusCode: 200,
173
            body: vendors,
174
        }).as("get-vendor-options");
175
156
        // Click the 'Edit' button from the list
176
        // Click the 'Edit' button from the list
157
        cy.intercept("GET", "/api/v1/erm/licenses*", {
177
        cy.intercept("GET", "/api/v1/erm/licenses*", {
158
            statusCode: 200,
178
            statusCode: 200,
Lines 174-179 describe("License CRUD operations", () => { Link Here
174
194
175
        // Form has been correctly filled in
195
        // Form has been correctly filled in
176
        cy.get("#license_name").should("have.value", license.name);
196
        cy.get("#license_name").should("have.value", license.name);
197
198
        cy.get("#license_vendor_id .vs__selected").contains(
199
            license.vendor[0].name
200
        );
201
202
        cy.get("#license_vendor_id .vs__search").type(
203
            vendors[1].name + "{enter}",
204
            { force: true }
205
        );
206
177
        cy.get("#license_description").should(
207
        cy.get("#license_description").should(
178
            "have.value",
208
            "have.value",
179
            license.description
209
            license.description
(-)a/t/cypress/support/e2e.js (-1 / +15 lines)
Lines 112-114 cy.get_agreements_to_relate = () => { Link Here
112
        },
112
        },
113
    ]
113
    ]
114
}
114
}
115
- 
115
116
cy.get_vendors_to_relate = () => {
117
    return [
118
        {
119
            "id": 1,
120
            "name": "My Vendor",
121
            "aliases": [],
122
        },
123
        {
124
            "id": 2,
125
            "name": "My Vendor 2",
126
            "aliases": [],
127
        }
128
    ]
129
}

Return to bug 34217