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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js (-10 / +11 lines)
Lines 24-36 class HttpClient { Link Here
24
            .then(response => {
24
            .then(response => {
25
                if (!response.ok) {
25
                if (!response.ok) {
26
                    return response.text().then(text => {
26
                    return response.text().then(text => {
27
                        let json = JSON.parse(text);
27
                        let message;
28
                        let message =
28
                        if (text) {
29
                            json.error ||
29
                            let json = JSON.parse(text);
30
                            json.errors.map(e => e.message).join("\n") ||
30
                            message =
31
                            json;
31
                                json.error ||
32
                        console.log("Server returned an error:");
32
                                json.errors.map(e => e.message).join("\n") ||
33
                        console.log(response);
33
                                json;
34
                        } else {
35
                            message = response.statusText;
36
                        }
34
                        throw new Error(message);
37
                        throw new Error(message);
35
                    });
38
                    });
36
                }
39
                }
Lines 134-142 class HttpClient { Link Here
134
                    return response.headers.get("X-Total-Count");
137
                    return response.headers.get("X-Total-Count");
135
                }
138
                }
136
            },
139
            },
137
            error => {
140
            error => {}
138
                setError(error.toString());
139
            }
140
        );
141
        );
141
    }
142
    }
142
143
(-)a/t/cypress/integration/ERM/Agreements_spec.ts (-8 / +4 lines)
Lines 132-143 describe("Agreement CRUD operations", () => { Link Here
132
        // GET agreements returns 500
132
        // GET agreements returns 500
133
        cy.intercept("GET", "/api/v1/erm/agreements*", {
133
        cy.intercept("GET", "/api/v1/erm/agreements*", {
134
            statusCode: 500,
134
            statusCode: 500,
135
            error: "Something went wrong",
136
        });
135
        });
137
        cy.visit("/cgi-bin/koha/erm/erm.pl");
136
        cy.visit("/cgi-bin/koha/erm/erm.pl");
138
        cy.get("#navmenulist").contains("Agreements").click();
137
        cy.get("#navmenulist").contains("Agreements").click();
139
        cy.get("main div[class='dialog alert']").contains(
138
        cy.get("main div[class='dialog alert']").contains(
140
            /Something went wrong/
139
            "Something went wrong: Error: Internal Server Error"
141
        );
140
        );
142
141
143
        // GET agreements returns empty list
142
        // GET agreements returns empty list
Lines 386-396 describe("Agreement CRUD operations", () => { Link Here
386
        // Submit the form, get 500
385
        // Submit the form, get 500
387
        cy.intercept("POST", "/api/v1/erm/agreements", {
386
        cy.intercept("POST", "/api/v1/erm/agreements", {
388
            statusCode: 500,
387
            statusCode: 500,
389
            error: "Something went wrong",
390
        });
388
        });
391
        cy.get("#agreements_add").contains("Submit").click();
389
        cy.get("#agreements_add").contains("Submit").click();
392
        cy.get("main div[class='dialog alert']").contains(
390
        cy.get("main div[class='dialog alert']").contains(
393
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
391
            "Something went wrong: Error: Internal Server Error"
394
        );
392
        );
395
393
396
        // Submit the form, success!
394
        // Submit the form, success!
Lines 577-583 describe("Agreement CRUD operations", () => { Link Here
577
        cy.intercept("PUT", "/api/v1/erm/agreements/*", req => {
575
        cy.intercept("PUT", "/api/v1/erm/agreements/*", req => {
578
            req.reply({
576
            req.reply({
579
                statusCode: 500,
577
                statusCode: 500,
580
                error: "Something went wrong",
581
                delay: 1000,
578
                delay: 1000,
582
            });
579
            });
583
        });
580
        });
Lines 585-591 describe("Agreement CRUD operations", () => { Link Here
585
        cy.get("main div[class='modal_centered']").contains("Submitting...");
582
        cy.get("main div[class='modal_centered']").contains("Submitting...");
586
        cy.wait(1000);
583
        cy.wait(1000);
587
        cy.get("main div[class='dialog alert']").contains(
584
        cy.get("main div[class='dialog alert']").contains(
588
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
585
            "Something went wrong: Error: Internal Server Error"
589
        );
586
        );
590
587
591
        // Submit the form, success!
588
        // Submit the form, success!
Lines 664-674 describe("Agreement CRUD operations", () => { Link Here
664
        // Accept the confirmation dialog, get 500
661
        // Accept the confirmation dialog, get 500
665
        cy.intercept("DELETE", "/api/v1/erm/agreements/*", {
662
        cy.intercept("DELETE", "/api/v1/erm/agreements/*", {
666
            statusCode: 500,
663
            statusCode: 500,
667
            error: "Something went wrong",
668
        });
664
        });
669
        cy.contains("Yes, delete").click();
665
        cy.contains("Yes, delete").click();
670
        cy.get("main div[class='dialog alert']").contains(
666
        cy.get("main div[class='dialog alert']").contains(
671
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
667
            "Something went wrong: Error: Internal Server Error"
672
        );
668
        );
673
669
674
        // Accept the confirmation dialog, success!
670
        // Accept the confirmation dialog, success!
(-)a/t/cypress/integration/ERM/Dialog_spec.ts (-2 / +13 lines)
Lines 50-61 describe("Dialog operations", () => { Link Here
50
        // GET package returns 500
50
        // GET package returns 500
51
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
51
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
52
            statusCode: 500,
52
            statusCode: 500,
53
            error: "Something went wrong",
53
            body: {
54
                error: "This is a specific error message",
55
            },
56
        });
57
        cy.visit("/cgi-bin/koha/erm/erm.pl");
58
        cy.get("#navmenulist").contains("Packages").click();
59
        cy.get("main div[class='dialog alert']").contains(
60
            "Something went wrong: Error: This is a specific error message"
61
        );
62
63
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
64
            statusCode: 500, // No body, in case of Internal Server Error, we get statusText
54
        });
65
        });
55
        cy.visit("/cgi-bin/koha/erm/erm.pl");
66
        cy.visit("/cgi-bin/koha/erm/erm.pl");
56
        cy.get("#navmenulist").contains("Packages").click();
67
        cy.get("#navmenulist").contains("Packages").click();
57
        cy.get("main div[class='dialog alert']").contains(
68
        cy.get("main div[class='dialog alert']").contains(
58
            /Something went wrong/
69
            "Something went wrong: Error: Internal Server Error"
59
        );
70
        );
60
71
61
        cy.intercept("GET", "/api/v1/erm/agreements*", []);
72
        cy.intercept("GET", "/api/v1/erm/agreements*", []);
(-)a/t/cypress/integration/ERM/Licenses_spec.ts (-8 / +4 lines)
Lines 49-60 describe("License CRUD operations", () => { Link Here
49
        // GET license returns 500
49
        // GET license returns 500
50
        cy.intercept("GET", "/api/v1/erm/licenses*", {
50
        cy.intercept("GET", "/api/v1/erm/licenses*", {
51
            statusCode: 500,
51
            statusCode: 500,
52
            error: "Something went wrong",
53
        });
52
        });
54
        cy.visit("/cgi-bin/koha/erm/erm.pl");
53
        cy.visit("/cgi-bin/koha/erm/erm.pl");
55
        cy.get("#navmenulist").contains("Licenses").click();
54
        cy.get("#navmenulist").contains("Licenses").click();
56
        cy.get("main div[class='dialog alert']").contains(
55
        cy.get("main div[class='dialog alert']").contains(
57
            /Something went wrong/
56
            "Something went wrong: Error: Internal Server Error"
58
        );
57
        );
59
58
60
        // GET licenses returns empty list
59
        // GET licenses returns empty list
Lines 157-167 describe("License CRUD operations", () => { Link Here
157
        // Submit the form, get 500
156
        // Submit the form, get 500
158
        cy.intercept("POST", "/api/v1/erm/licenses", {
157
        cy.intercept("POST", "/api/v1/erm/licenses", {
159
            statusCode: 500,
158
            statusCode: 500,
160
            error: "Something went wrong",
161
        });
159
        });
162
        cy.get("#licenses_add").contains("Submit").click();
160
        cy.get("#licenses_add").contains("Submit").click();
163
        cy.get("main div[class='dialog alert']").contains(
161
        cy.get("main div[class='dialog alert']").contains(
164
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
162
            "Something went wrong: Error: Internal Server Error"
165
        );
163
        );
166
164
167
        // Submit the form, success!
165
        // Submit the form, success!
Lines 238-248 describe("License CRUD operations", () => { Link Here
238
        // Submit the form, get 500
236
        // Submit the form, get 500
239
        cy.intercept("PUT", "/api/v1/erm/licenses/*", {
237
        cy.intercept("PUT", "/api/v1/erm/licenses/*", {
240
            statusCode: 500,
238
            statusCode: 500,
241
            error: "Something went wrong",
242
        });
239
        });
243
        cy.get("#licenses_add").contains("Submit").click();
240
        cy.get("#licenses_add").contains("Submit").click();
244
        cy.get("main div[class='dialog alert']").contains(
241
        cy.get("main div[class='dialog alert']").contains(
245
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
242
            "Something went wrong: Error: Internal Server Error"
246
        );
243
        );
247
244
248
        // Submit the form, success!
245
        // Submit the form, success!
Lines 309-319 describe("License CRUD operations", () => { Link Here
309
        // Accept the confirmation dialog, get 500
306
        // Accept the confirmation dialog, get 500
310
        cy.intercept("DELETE", "/api/v1/erm/licenses/*", {
307
        cy.intercept("DELETE", "/api/v1/erm/licenses/*", {
311
            statusCode: 500,
308
            statusCode: 500,
312
            error: "Something went wrong",
313
        });
309
        });
314
        cy.contains("Yes, delete").click();
310
        cy.contains("Yes, delete").click();
315
        cy.get("main div[class='dialog alert']").contains(
311
        cy.get("main div[class='dialog alert']").contains(
316
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
312
            "Something went wrong: Error: Internal Server Error"
317
        );
313
        );
318
314
319
        // Accept the confirmation dialog, success!
315
        // Accept the confirmation dialog, success!
(-)a/t/cypress/integration/ERM/Packages_spec.ts (-8 / +4 lines)
Lines 38-49 describe("Package CRUD operations", () => { Link Here
38
        // GET package returns 500
38
        // GET package returns 500
39
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
39
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
40
            statusCode: 500,
40
            statusCode: 500,
41
            error: "Something went wrong",
42
        });
41
        });
43
        cy.visit("/cgi-bin/koha/erm/erm.pl");
42
        cy.visit("/cgi-bin/koha/erm/erm.pl");
44
        cy.get("#navmenulist").contains("Packages").click();
43
        cy.get("#navmenulist").contains("Packages").click();
45
        cy.get("main div[class='dialog alert']").contains(
44
        cy.get("main div[class='dialog alert']").contains(
46
            /Something went wrong/
45
            "Something went wrong: Error: Internal Server Error"
47
        );
46
        );
48
47
49
        // GET packages returns empty list
48
        // GET packages returns empty list
Lines 113-123 describe("Package CRUD operations", () => { Link Here
113
        // Submit the form, get 500
112
        // Submit the form, get 500
114
        cy.intercept("POST", "/api/v1/erm/eholdings/local/packages", {
113
        cy.intercept("POST", "/api/v1/erm/eholdings/local/packages", {
115
            statusCode: 500,
114
            statusCode: 500,
116
            error: "Something went wrong",
117
        });
115
        });
118
        cy.get("#packages_add").contains("Submit").click();
116
        cy.get("#packages_add").contains("Submit").click();
119
        cy.get("main div[class='dialog alert']").contains(
117
        cy.get("main div[class='dialog alert']").contains(
120
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
118
            "Something went wrong: Error: Internal Server Error"
121
        );
119
        );
122
120
123
        // Submit the form, success!
121
        // Submit the form, success!
Lines 187-197 describe("Package CRUD operations", () => { Link Here
187
        // Submit the form, get 500
185
        // Submit the form, get 500
188
        cy.intercept("PUT", "/api/v1/erm/eholdings/local/packages/*", {
186
        cy.intercept("PUT", "/api/v1/erm/eholdings/local/packages/*", {
189
            statusCode: 500,
187
            statusCode: 500,
190
            error: "Something went wrong",
191
        });
188
        });
192
        cy.get("#packages_add").contains("Submit").click();
189
        cy.get("#packages_add").contains("Submit").click();
193
        cy.get("main div[class='dialog alert']").contains(
190
        cy.get("main div[class='dialog alert']").contains(
194
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
191
            "Something went wrong: Error: Internal Server Error"
195
        );
192
        );
196
193
197
        // Submit the form, success!
194
        // Submit the form, success!
Lines 304-314 describe("Package CRUD operations", () => { Link Here
304
        // Accept the confirmation dialog, get 500
301
        // Accept the confirmation dialog, get 500
305
        cy.intercept("DELETE", "/api/v1/erm/eholdings/local/packages/*", {
302
        cy.intercept("DELETE", "/api/v1/erm/eholdings/local/packages/*", {
306
            statusCode: 500,
303
            statusCode: 500,
307
            error: "Something went wrong",
308
        });
304
        });
309
        cy.contains("Yes, delete").click();
305
        cy.contains("Yes, delete").click();
310
        cy.get("main div[class='dialog alert']").contains(
306
        cy.get("main div[class='dialog alert']").contains(
311
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
307
            "Something went wrong: Error: Internal Server Error"
312
        );
308
        );
313
309
314
        // Accept the confirmation dialog, success!
310
        // Accept the confirmation dialog, success!
(-)a/t/cypress/integration/ERM/Titles_spec.ts (-6 / +3 lines)
Lines 195-201 describe("Title CRUD operations", () => { Link Here
195
        });
195
        });
196
        cy.get("#titles_add").contains("Submit").click();
196
        cy.get("#titles_add").contains("Submit").click();
197
        cy.get("main div[class='dialog alert']").contains(
197
        cy.get("main div[class='dialog alert']").contains(
198
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
198
            "Something went wrong: Error: Internal Server Error"
199
        );
199
        );
200
200
201
        // Submit the form, success!
201
        // Submit the form, success!
Lines 350-360 describe("Title CRUD operations", () => { Link Here
350
        // Submit the form, get 500
350
        // Submit the form, get 500
351
        cy.intercept("PUT", "/api/v1/erm/eholdings/local/titles/*", {
351
        cy.intercept("PUT", "/api/v1/erm/eholdings/local/titles/*", {
352
            statusCode: 500,
352
            statusCode: 500,
353
            error: "Something went wrong",
354
        });
353
        });
355
        cy.get("#titles_add").contains("Submit").click();
354
        cy.get("#titles_add").contains("Submit").click();
356
        cy.get("main div[class='dialog alert']").contains(
355
        cy.get("main div[class='dialog alert']").contains(
357
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
356
            "Something went wrong: Error: Internal Server Error"
358
        );
357
        );
359
358
360
        // Submit the form, success!
359
        // Submit the form, success!
Lines 459-469 describe("Title CRUD operations", () => { Link Here
459
        // Accept the confirmation dialog, get 500
458
        // Accept the confirmation dialog, get 500
460
        cy.intercept("DELETE", "/api/v1/erm/eholdings/local/titles/*", {
459
        cy.intercept("DELETE", "/api/v1/erm/eholdings/local/titles/*", {
461
            statusCode: 500,
460
            statusCode: 500,
462
            error: "Something went wrong",
463
        });
461
        });
464
        cy.contains("Yes, delete").click();
462
        cy.contains("Yes, delete").click();
465
        cy.get("main div[class='dialog alert']").contains(
463
        cy.get("main div[class='dialog alert']").contains(
466
            "Something went wrong: SyntaxError: Unexpected end of JSON input"
464
            "Something went wrong: Error: Internal Server Error"
467
        );
465
        );
468
466
469
        // Accept the confirmation dialog, success!
467
        // Accept the confirmation dialog, success!
470
- 

Return to bug 35199