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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/composables/datatables.js (-1 / +1 lines)
Lines 13-19 export function useDataTable(table_id) { Link Here
13
export function build_url_params(filters) {
13
export function build_url_params(filters) {
14
    return Object.entries(filters)
14
    return Object.entries(filters)
15
        .map(([k, v]) => (v ? k + "=" + v : undefined))
15
        .map(([k, v]) => (v ? k + "=" + v : undefined))
16
        .filter((e) => e !== undefined)
16
        .filter(e => e !== undefined)
17
        .join("&");
17
        .join("&");
18
}
18
}
19
export function build_url(base_url, filters) {
19
export function build_url(base_url, filters) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js (-1 / +1 lines)
Lines 9-15 export class AcquisitionAPIClient extends HttpClient { Link Here
9
9
10
    get vendors() {
10
    get vendors() {
11
        return {
11
        return {
12
            getAll: (query) =>
12
            getAll: query =>
13
                this.get({
13
                this.get({
14
                    endpoint: "vendors?" + (query || "_per_page=-1"),
14
                    endpoint: "vendors?" + (query || "_per_page=-1"),
15
                    headers: {
15
                    headers: {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/authorised-values.js (-6 / +8 lines)
Lines 9-24 export class AVAPIClient extends HttpClient { Link Here
9
9
10
    get values() {
10
    get values() {
11
        return {
11
        return {
12
            getCategoriesWithValues: (cat_array) =>
12
            getCategoriesWithValues: cat_array =>
13
                this.get({
13
                this.get({
14
                    endpoint: "?q={\"me.category_name\":["+(cat_array.join(", "))+"]}",
14
                    endpoint:
15
                        '?q={"me.category_name":[' +
16
                        cat_array.join(", ") +
17
                        "]}",
15
                    headers: {
18
                    headers: {
16
                        "x-koha-embed":
19
                        "x-koha-embed": "authorised_values",
17
                            "authorised_values",
18
                    },
20
                    },
19
            }),
21
                }),
20
        };
22
        };
21
    }
23
    }
22
}
24
}
23
25
24
export default AVAPIClient;
26
export default AVAPIClient;
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js (-26 / +28 lines)
Lines 9-15 export class ERMAPIClient extends HttpClient { Link Here
9
9
10
    get agreements() {
10
    get agreements() {
11
        return {
11
        return {
12
            get: (id) =>
12
            get: id =>
13
                this.get({
13
                this.get({
14
                    endpoint: "agreements/" + id,
14
                    endpoint: "agreements/" + id,
15
                    headers: {
15
                    headers: {
Lines 17-31 export class ERMAPIClient extends HttpClient { Link Here
17
                            "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor",
17
                            "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor",
18
                    },
18
                    },
19
                }),
19
                }),
20
            getAll: (query) =>
20
            getAll: query =>
21
                this.get({
21
                this.get({
22
                    endpoint: "agreements?" + (query || "_per_page=-1"),
22
                    endpoint: "agreements?" + (query || "_per_page=-1"),
23
                }),
23
                }),
24
            delete: (id) =>
24
            delete: id =>
25
                this.delete({
25
                this.delete({
26
                    endpoint: "agreements/" + id,
26
                    endpoint: "agreements/" + id,
27
                }),
27
                }),
28
            create: (agreement) =>
28
            create: agreement =>
29
                this.post({
29
                this.post({
30
                    endpoint: "agreements",
30
                    endpoint: "agreements",
31
                    body: agreement,
31
                    body: agreement,
Lines 50-56 export class ERMAPIClient extends HttpClient { Link Here
50
50
51
    get licenses() {
51
    get licenses() {
52
        return {
52
        return {
53
            get: (id) =>
53
            get: id =>
54
                this.get({
54
                this.get({
55
                    endpoint: "licenses/" + id,
55
                    endpoint: "licenses/" + id,
56
                    headers: {
56
                    headers: {
Lines 58-75 export class ERMAPIClient extends HttpClient { Link Here
58
                            "user_roles,user_roles.patron,vendor,documents",
58
                            "user_roles,user_roles.patron,vendor,documents",
59
                    },
59
                    },
60
                }),
60
                }),
61
            getAll: (query) =>
61
            getAll: query =>
62
                this.get({
62
                this.get({
63
                    endpoint: "licenses?" + (query || "_per_page=-1"),
63
                    endpoint: "licenses?" + (query || "_per_page=-1"),
64
                    headers: {
64
                    headers: {
65
                        "x-koha-embed": "vendor",
65
                        "x-koha-embed": "vendor",
66
                    },
66
                    },
67
                }),
67
                }),
68
            delete: (id) =>
68
            delete: id =>
69
                this.delete({
69
                this.delete({
70
                    endpoint: "licenses/" + id,
70
                    endpoint: "licenses/" + id,
71
                }),
71
                }),
72
            create: (license) =>
72
            create: license =>
73
                this.post({
73
                this.post({
74
                    endpoint: "licenses",
74
                    endpoint: "licenses",
75
                    body: license,
75
                    body: license,
Lines 79-85 export class ERMAPIClient extends HttpClient { Link Here
79
                    endpoint: "licenses/" + id,
79
                    endpoint: "licenses/" + id,
80
                    body: license,
80
                    body: license,
81
                }),
81
                }),
82
                count: (query = {}) =>
82
            count: (query = {}) =>
83
                this.count({
83
                this.count({
84
                    endpoint:
84
                    endpoint:
85
                        "licenses?" +
85
                        "licenses?" +
Lines 94-100 export class ERMAPIClient extends HttpClient { Link Here
94
94
95
    get localPackages() {
95
    get localPackages() {
96
        return {
96
        return {
97
            get: (id) =>
97
            get: id =>
98
                this.get({
98
                this.get({
99
                    endpoint: "eholdings/local/packages/" + id,
99
                    endpoint: "eholdings/local/packages/" + id,
100
                    headers: {
100
                    headers: {
Lines 102-108 export class ERMAPIClient extends HttpClient { Link Here
102
                            "package_agreements,package_agreements.agreement,resources+count,vendor",
102
                            "package_agreements,package_agreements.agreement,resources+count,vendor",
103
                    },
103
                    },
104
                }),
104
                }),
105
            getAll: (query) =>
105
            getAll: query =>
106
                this.get({
106
                this.get({
107
                    endpoint:
107
                    endpoint:
108
                        "eholdings/local/packages?" + (query || "_per_page=-1"),
108
                        "eholdings/local/packages?" + (query || "_per_page=-1"),
Lines 110-120 export class ERMAPIClient extends HttpClient { Link Here
110
                        "x-koha-embed": "resources+count,vendor.name",
110
                        "x-koha-embed": "resources+count,vendor.name",
111
                    },
111
                    },
112
                }),
112
                }),
113
            delete: (id) =>
113
            delete: id =>
114
                this.delete({
114
                this.delete({
115
                    endpoint: "eholdings/local/packages/" + id,
115
                    endpoint: "eholdings/local/packages/" + id,
116
                }),
116
                }),
117
            create: (local_package) =>
117
            create: local_package =>
118
                this.post({
118
                this.post({
119
                    endpoint: "eholdings/local/packages",
119
                    endpoint: "eholdings/local/packages",
120
                    body: local_package,
120
                    body: local_package,
Lines 139-160 export class ERMAPIClient extends HttpClient { Link Here
139
139
140
    get localTitles() {
140
    get localTitles() {
141
        return {
141
        return {
142
            get: (id) =>
142
            get: id =>
143
                this.get({
143
                this.get({
144
                    endpoint: "eholdings/local/titles/" + id,
144
                    endpoint: "eholdings/local/titles/" + id,
145
                    headers: {
145
                    headers: {
146
                        "x-koha-embed": "resources,resources.package",
146
                        "x-koha-embed": "resources,resources.package",
147
                    },
147
                    },
148
                }),
148
                }),
149
            getAll: (query) =>
149
            getAll: query =>
150
                this.get({
150
                this.get({
151
                    endpoint: "eholdings/local/titles?" + (query || "_per_page=-1"),
151
                    endpoint:
152
                        "eholdings/local/titles?" + (query || "_per_page=-1"),
152
                }),
153
                }),
153
            delete: (id) =>
154
            delete: id =>
154
                this.delete({
155
                this.delete({
155
                    endpoint: "eholdings/local/titles/" + id,
156
                    endpoint: "eholdings/local/titles/" + id,
156
                }),
157
                }),
157
            create: (local_package) =>
158
            create: local_package =>
158
                this.post({
159
                this.post({
159
                    endpoint: "eholdings/local/titles",
160
                    endpoint: "eholdings/local/titles",
160
                    body: local_package,
161
                    body: local_package,
Lines 174-180 export class ERMAPIClient extends HttpClient { Link Here
174
                            ...(query && { q: JSON.stringify(query) }),
175
                            ...(query && { q: JSON.stringify(query) }),
175
                        }),
176
                        }),
176
                }),
177
                }),
177
            import: (body) =>
178
            import: body =>
178
                this.post({
179
                this.post({
179
                    endpoint: "eholdings/local/titles/import",
180
                    endpoint: "eholdings/local/titles/import",
180
                    body,
181
                    body,
Lines 184-190 export class ERMAPIClient extends HttpClient { Link Here
184
185
185
    get localResources() {
186
    get localResources() {
186
        return {
187
        return {
187
            get: (id) =>
188
            get: id =>
188
                this.get({
189
                this.get({
189
                    endpoint: "eholdings/local/resources/" + id,
190
                    endpoint: "eholdings/local/resources/" + id,
190
                    headers: {
191
                    headers: {
Lines 196-202 export class ERMAPIClient extends HttpClient { Link Here
196
197
197
    get EBSCOPackages() {
198
    get EBSCOPackages() {
198
        return {
199
        return {
199
            get: (id) =>
200
            get: id =>
200
                this.get({
201
                this.get({
201
                    endpoint: "eholdings/ebsco/packages/" + id,
202
                    endpoint: "eholdings/ebsco/packages/" + id,
202
                    headers: {
203
                    headers: {
Lines 204-210 export class ERMAPIClient extends HttpClient { Link Here
204
                            "package_agreements,package_agreements.agreement,resources+count,vendor",
205
                            "package_agreements,package_agreements.agreement,resources+count,vendor",
205
                    },
206
                    },
206
                }),
207
                }),
207
            getAll: (query) =>
208
            getAll: query =>
208
                this.get({
209
                this.get({
209
                    endpoint:
210
                    endpoint:
210
                        "eholdings/ebsco/packages/" +
211
                        "eholdings/ebsco/packages/" +
Lines 224-247 export class ERMAPIClient extends HttpClient { Link Here
224
225
225
    get EBSCOTitles() {
226
    get EBSCOTitles() {
226
        return {
227
        return {
227
            get: (id) =>
228
            get: id =>
228
                this.get({
229
                this.get({
229
                    endpoint: "eholdings/ebsco/titles/" + id,
230
                    endpoint: "eholdings/ebsco/titles/" + id,
230
                    headers: {
231
                    headers: {
231
                        "x-koha-embed": "resources,resources.package",
232
                        "x-koha-embed": "resources,resources.package",
232
                    },
233
                    },
233
                }),
234
                }),
234
            getAll: (query) =>
235
            getAll: query =>
235
                this.get({
236
                this.get({
236
                    endpoint:
237
                    endpoint:
237
                        "eholdings/local/ebsco/titles" + (query || "_per_page=-1"),
238
                        "eholdings/local/ebsco/titles" +
239
                        (query || "_per_page=-1"),
238
                }),
240
                }),
239
        };
241
        };
240
    }
242
    }
241
243
242
    get EBSCOResources() {
244
    get EBSCOResources() {
243
        return {
245
        return {
244
            get: (id) =>
246
            get: id =>
245
                this.get({
247
                this.get({
246
                    endpoint: "eholdings/ebsco/resources/" + id,
248
                    endpoint: "eholdings/ebsco/resources/" + id,
247
                    headers: {
249
                    headers: {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js (-22 / +36 lines)
Lines 13-42 class HttpClient { Link Here
13
        headers = {},
13
        headers = {},
14
        options = {},
14
        options = {},
15
        return_response = false,
15
        return_response = false,
16
        mark_submitting = false,
16
        mark_submitting = false
17
    ) {
17
    ) {
18
        let res, error;
18
        let res, error;
19
        if ( mark_submitting) submitting()
19
        if (mark_submitting) submitting();
20
        await fetch(this._baseURL + endpoint, {
20
        await fetch(this._baseURL + endpoint, {
21
            ...options,
21
            ...options,
22
            headers: { ...this._headers, ...headers },
22
            headers: { ...this._headers, ...headers },
23
        })
23
        })
24
            .then((response) => this.checkError(response, return_response))
24
            .then(response => this.checkError(response, return_response))
25
            .then(
25
            .then(
26
                (result) => {
26
                result => {
27
                    res = result;
27
                    res = result;
28
                },
28
                },
29
                (err) => {
29
                err => {
30
                    error = err;
30
                    error = err;
31
                    setError(err.toString());
31
                    setError(err.toString());
32
                }
32
                }
33
            )
33
            )
34
            .catch((err) => {
34
            .catch(err => {
35
                error = err;
35
                error = err;
36
                setError(err);
36
                setError(err);
37
            }).then(() => {
37
            })
38
              if (mark_submitting) submitted()})
38
            .then(() => {
39
            ;
39
                if (mark_submitting) submitted();
40
            });
40
41
41
        if (error) throw Error(error);
42
        if (error) throw Error(error);
42
43
Lines 56-66 class HttpClient { Link Here
56
                ? params.body
57
                ? params.body
57
                : JSON.stringify(params.body)
58
                : JSON.stringify(params.body)
58
            : undefined;
59
            : undefined;
59
        return this._fetchJSON(params.endpoint, params.headers, {
60
        return this._fetchJSON(
60
            ...params.options,
61
            params.endpoint,
61
            body,
62
            params.headers,
62
            method: "POST",
63
            {
63
        }, false, true);
64
                ...params.options,
65
                body,
66
                method: "POST",
67
            },
68
            false,
69
            true
70
        );
64
    }
71
    }
65
72
66
    put(params = {}) {
73
    put(params = {}) {
Lines 69-79 class HttpClient { Link Here
69
                ? params.body
76
                ? params.body
70
                : JSON.stringify(params.body)
77
                : JSON.stringify(params.body)
71
            : undefined;
78
            : undefined;
72
        return this._fetchJSON(params.endpoint, params.headers, {
79
        return this._fetchJSON(
73
            ...params.options,
80
            params.endpoint,
74
            body,
81
            params.headers,
75
            method: "PUT",
82
            {
76
        }, false, true);
83
                ...params.options,
84
                body,
85
                method: "PUT",
86
            },
87
            false,
88
            true
89
        );
77
    }
90
    }
78
91
79
    delete(params = {}) {
92
    delete(params = {}) {
Lines 85-103 class HttpClient { Link Here
85
                ...params.options,
98
                ...params.options,
86
                method: "DELETE",
99
                method: "DELETE",
87
            },
100
            },
88
            true, true
101
            true,
102
            true
89
        );
103
        );
90
    }
104
    }
91
105
92
    count(params = {}) {
106
    count(params = {}) {
93
        let res;
107
        let res;
94
        return this._fetchJSON(params.endpoint, params.headers, {}, 1).then(
108
        return this._fetchJSON(params.endpoint, params.headers, {}, 1).then(
95
            (response) => {
109
            response => {
96
                if (response) {
110
                if (response) {
97
                    return response.headers.get("X-Total-Count");
111
                    return response.headers.get("X-Total-Count");
98
                }
112
                }
99
            },
113
            },
100
            (error) => {
114
            error => {
101
                setError(error.toString());
115
                setError(error.toString());
102
            }
116
            }
103
        );
117
        );
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/patron-api-client.js (-1 / +1 lines)
Lines 9-15 export class PatronAPIClient extends HttpClient { Link Here
9
9
10
    get patrons() {
10
    get patrons() {
11
        return {
11
        return {
12
            get: (id) =>
12
            get: id =>
13
                this.get({
13
                this.get({
14
                    endpoint: "patrons/" + id,
14
                    endpoint: "patrons/" + id,
15
                }),
15
                }),
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js (-1 / +1 lines)
Lines 9-15 export class SysprefAPIClient extends HttpClient { Link Here
9
9
10
    get sysprefs() {
10
    get sysprefs() {
11
        return {
11
        return {
12
            get: (variable) =>
12
            get: variable =>
13
                this.get({
13
                this.get({
14
                    endpoint: "/?pref=" + variable,
14
                    endpoint: "/?pref=" + variable,
15
                }),
15
                }),
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/messages.js (-1 / +1 lines)
Lines 41-44 export const loaded = function () { Link Here
41
    const mainStore = useMainStore();
41
    const mainStore = useMainStore();
42
    const { loaded } = mainStore;
42
    const { loaded } = mainStore;
43
    loaded();
43
    loaded();
44
};
44
};
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/authorised-values.js (-2 / +2 lines)
Lines 47-57 export const useAVStore = defineStore("authorised_values", { Link Here
47
                );
47
                );
48
                return;
48
                return;
49
            }
49
            }
50
            let o = this[arr_name].find((e) => e.value == av);
50
            let o = this[arr_name].find(e => e.value == av);
51
            return o ? o.description : av;
51
            return o ? o.description : av;
52
        },
52
        },
53
        map_av_dt_filter(arr_name) {
53
        map_av_dt_filter(arr_name) {
54
            return this[arr_name].map((e) => {
54
            return this[arr_name].map(e => {
55
                e["_id"] = e["value"];
55
                e["_id"] = e["value"];
56
                e["_str"] = e["description"];
56
                e["_str"] = e["description"];
57
                return e;
57
                return e;
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/main.js (-23 / +27 lines)
Lines 19-49 export const useMainStore = defineStore("main", { Link Here
19
            this._warning = null;
19
            this._warning = null;
20
            this._message = message;
20
            this._message = message;
21
            this._confirmation = null;
21
            this._confirmation = null;
22
            this.displayed_already = displayed; /* Will be displayed on the next view */
22
            this.displayed_already =
23
                displayed; /* Will be displayed on the next view */
23
        },
24
        },
24
        setError(error, displayed = true) {
25
        setError(error, displayed = true) {
25
            this._error = error;
26
            this._error = error;
26
            this._warning = null;
27
            this._warning = null;
27
            this._message = null;
28
            this._message = null;
28
            this._confirmation = null;
29
            this._confirmation = null;
29
            this.displayed_already = displayed; /* Is displayed on the current view */
30
            this.displayed_already =
31
                displayed; /* Is displayed on the current view */
30
        },
32
        },
31
        setWarning(warning, displayed = true) {
33
        setWarning(warning, displayed = true) {
32
            this._error = null;
34
            this._error = null;
33
            this._warning = warning;
35
            this._warning = warning;
34
            this._message = null;
36
            this._message = null;
35
            this._confirmation = null;
37
            this._confirmation = null;
36
            this.displayed_already = displayed; /* Is displayed on the current view */
38
            this.displayed_already =
39
                displayed; /* Is displayed on the current view */
37
        },
40
        },
38
        setConfirmationDialog(confirmation, accept_callback, displayed = true){
41
        setConfirmationDialog(confirmation, accept_callback, displayed = true) {
39
            if(accept_callback) {
42
            if (accept_callback) {
40
                this._accept_callback = async () => {
43
                this._accept_callback = async () => {
41
                    await accept_callback()
44
                    await accept_callback();
42
                    this.removeConfirmationMessages()
45
                    this.removeConfirmationMessages();
43
                }
46
                };
44
            }
47
            }
45
            this._confirmation = confirmation;
48
            this._confirmation = confirmation;
46
            this.displayed_already = displayed; /* Is displayed on the current view */
49
            this.displayed_already =
50
                displayed; /* Is displayed on the current view */
47
        },
51
        },
48
        removeMessages() {
52
        removeMessages() {
49
            if (this.displayed_already) {
53
            if (this.displayed_already) {
Lines 55-98 export const useMainStore = defineStore("main", { Link Here
55
            }
59
            }
56
            this.displayed_already = true;
60
            this.displayed_already = true;
57
        },
61
        },
58
        removeConfirmationMessages(){
62
        removeConfirmationMessages() {
59
            this._confirmation = null;
63
            this._confirmation = null;
60
            this._accept_callback = null;
64
            this._accept_callback = null;
61
        },
65
        },
62
        submitting(){
66
        submitting() {
63
            this._is_submitting = true;
67
            this._is_submitting = true;
64
        },
68
        },
65
        submitted(){
69
        submitted() {
66
            this._is_submitting = false;
70
            this._is_submitting = false;
67
        },
71
        },
68
        loading(){
72
        loading() {
69
            this._is_loading = true;
73
            this._is_loading = true;
70
        },
74
        },
71
        loaded(){
75
        loaded() {
72
            this._is_loading = false;
76
            this._is_loading = false;
73
        },
77
        },
74
    },
78
    },
75
    getters: {
79
    getters: {
76
        error() {
80
        error() {
77
            return this._error
81
            return this._error;
78
        },
82
        },
79
        warning() {
83
        warning() {
80
            return this._warning
84
            return this._warning;
81
        },
85
        },
82
        message() {
86
        message() {
83
            return this._message
87
            return this._message;
84
        },
88
        },
85
        confirmation() {
89
        confirmation() {
86
            return this._confirmation
90
            return this._confirmation;
87
        },
91
        },
88
        accept_callback() {
92
        accept_callback() {
89
            return this._accept_callback
93
            return this._accept_callback;
90
        },
94
        },
91
        is_submitting(){
95
        is_submitting() {
92
            return this._is_submitting
96
            return this._is_submitting;
93
        },
97
        },
94
        is_loading(){
98
        is_loading() {
95
            return this._is_loading
99
            return this._is_loading;
96
        },
100
        },
97
    },
101
    },
98
});
102
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/vendors.js (-6 / +6 lines)
Lines 1-7 Link Here
1
import { defineStore } from 'pinia'
1
import { defineStore } from "pinia";
2
2
3
export const useVendorStore = defineStore('vendors', {
3
export const useVendorStore = defineStore("vendors", {
4
  state: () => ({
4
    state: () => ({
5
    vendors: [],
5
        vendors: [],
6
  }),
6
    }),
7
})
7
});
(-)a/t/cypress/integration/ERM/Agreements_spec.ts (-46 / +85 lines)
Lines 43-55 function get_agreement() { Link Here
43
                    license_id: 1,
43
                    license_id: 1,
44
                    name: "license name",
44
                    name: "license name",
45
                    status: "expired",
45
                    status: "expired",
46
                    type: "alliance"
46
                    type: "alliance",
47
                },
47
                },
48
                license_id:1,
48
                license_id: 1,
49
                notes: "license notes",
49
                notes: "license notes",
50
                physical_location: "cupboard",
50
                physical_location: "cupboard",
51
                status: "controlling",
51
                status: "controlling",
52
                uri: "license uri"
52
                uri: "license uri",
53
            },
53
            },
54
            {
54
            {
55
                agreement_id: 1,
55
                agreement_id: 1,
Lines 59-97 function get_agreement() { Link Here
59
                    license_id: 2,
59
                    license_id: 2,
60
                    name: "second license name",
60
                    name: "second license name",
61
                    status: "expired",
61
                    status: "expired",
62
                    type: "alliance"
62
                    type: "alliance",
63
                },
63
                },
64
                license_id:2,
64
                license_id: 2,
65
                notes: "second license notes",
65
                notes: "second license notes",
66
                physical_location: "cupboard",
66
                physical_location: "cupboard",
67
                status: "future",
67
                status: "future",
68
                uri: "license uri"
68
                uri: "license uri",
69
            }
69
            },
70
        ],
70
        ],
71
        agreement_relationships: [
71
        agreement_relationships: [
72
            {
72
            {
73
                agreement_id: 1,
73
                agreement_id: 1,
74
                notes: 'related agreement notes',
74
                notes: "related agreement notes",
75
                related_agreement: {
75
                related_agreement: {
76
                    agreement_id: 2,
76
                    agreement_id: 2,
77
                    description: "agreement description",
77
                    description: "agreement description",
78
                    name: "agreement name"
78
                    name: "agreement name",
79
                },
79
                },
80
                related_agreement_id: 2,
80
                related_agreement_id: 2,
81
                relationship: "supersedes"
81
                relationship: "supersedes",
82
            }
82
            },
83
        ],
83
        ],
84
        agreement_packages: [],
84
        agreement_packages: [],
85
        documents: [
85
        documents: [
86
            {
86
            {
87
                agreement_id:1,
87
                agreement_id: 1,
88
                file_description: "file description",
88
                file_description: "file description",
89
                file_name: "file.json",
89
                file_name: "file.json",
90
                notes: "file notes",
90
                notes: "file notes",
91
                physical_location: "file physical location",
91
                physical_location: "file physical location",
92
                uri: "file uri",
92
                uri: "file uri",
93
                uploaded_on: "2022-10-27T11:57:02+00:00"
93
                uploaded_on: "2022-10-27T11:57:02+00:00",
94
            }
94
            },
95
        ],
95
        ],
96
    };
96
    };
97
}
97
}
Lines 101-127 function get_licenses_to_relate() { Link Here
101
        {
101
        {
102
            license_id: 1,
102
            license_id: 1,
103
            description: "a license",
103
            description: "a license",
104
            name: "first license name"
104
            name: "first license name",
105
        },
105
        },
106
        {
106
        {
107
            license_id: 2,
107
            license_id: 2,
108
            description: "a second license",
108
            description: "a second license",
109
            name: "second license name"
109
            name: "second license name",
110
        },
110
        },
111
        {
111
        {
112
            license_id: 3,
112
            license_id: 3,
113
            description: "a third license",
113
            description: "a third license",
114
            name: "third license name"
114
            name: "third license name",
115
        },
115
        },
116
    ]
116
    ];
117
}
117
}
118
118
119
describe("Agreement CRUD operations", () => {
119
describe("Agreement CRUD operations", () => {
120
    beforeEach(() => {
120
    beforeEach(() => {
121
        cy.login();
121
        cy.login();
122
        cy.title().should("eq", "Koha staff interface");
122
        cy.title().should("eq", "Koha staff interface");
123
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
123
        cy.intercept(
124
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
124
            "GET",
125
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
126
            '{"value":"1"}'
127
        );
128
        cy.intercept(
129
            "GET",
130
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
131
            '{"value":"local"}'
132
        );
125
    });
133
    });
126
134
127
    it("List agreements", () => {
135
    it("List agreements", () => {
Lines 265-276 describe("Agreement CRUD operations", () => { Link Here
265
        // Add new document
273
        // Add new document
266
        cy.get("#documents").contains("Add new document").click();
274
        cy.get("#documents").contains("Add new document").click();
267
        cy.get("#document_0 input[id=file_0]").click();
275
        cy.get("#document_0 input[id=file_0]").click();
268
        cy.get('#document_0 input[id=file_0]').selectFile('t/cypress/fixtures/file.json');
276
        cy.get("#document_0 input[id=file_0]").selectFile(
277
            "t/cypress/fixtures/file.json"
278
        );
269
        cy.get("#document_0 .file_information span").contains("file.json");
279
        cy.get("#document_0 .file_information span").contains("file.json");
270
        cy.get('#document_0 input[id=file_description_0]').type('file description');
280
        cy.get("#document_0 input[id=file_description_0]").type(
271
        cy.get('#document_0 input[id=physical_location_0]').type('file physical location');
281
            "file description"
272
        cy.get('#document_0 input[id=uri_0]').type('file URI');
282
        );
273
        cy.get('#document_0 input[id=notes_0]').type('file notes');
283
        cy.get("#document_0 input[id=physical_location_0]").type(
284
            "file physical location"
285
        );
286
        cy.get("#document_0 input[id=uri_0]").type("file URI");
287
        cy.get("#document_0 input[id=notes_0]").type("file notes");
274
288
275
        // Submit the form, get 500
289
        // Submit the form, get 500
276
        cy.intercept("POST", "/api/v1/erm/agreements", {
290
        cy.intercept("POST", "/api/v1/erm/agreements", {
Lines 310-316 describe("Agreement CRUD operations", () => { Link Here
310
        cy.get("#agreement_license_0 #license_id_0 .vs__search").type(
324
        cy.get("#agreement_license_0 #license_id_0 .vs__search").type(
311
            related_license.license.name
325
            related_license.license.name
312
        );
326
        );
313
        cy.get("#agreement_license_0 #license_id_0 .vs__dropdown-menu li").eq(0).click( { force: true } ); //click first license suggestion
327
        cy.get("#agreement_license_0 #license_id_0 .vs__dropdown-menu li")
328
            .eq(0)
329
            .click({ force: true }); //click first license suggestion
314
        cy.get("#agreement_license_0 #license_status_0 .vs__search").type(
330
        cy.get("#agreement_license_0 #license_status_0 .vs__search").type(
315
            related_license.status + "{enter}",
331
            related_license.status + "{enter}",
316
            { force: true }
332
            { force: true }
Lines 319-325 describe("Agreement CRUD operations", () => { Link Here
319
            related_license.physical_location + "{enter}",
335
            related_license.physical_location + "{enter}",
320
            { force: true }
336
            { force: true }
321
        );
337
        );
322
        cy.get("#agreement_license_0 #license_notes_0").type(related_license.notes);
338
        cy.get("#agreement_license_0 #license_notes_0").type(
339
            related_license.notes
340
        );
323
        cy.get("#agreement_license_0 #license_uri_0").type(related_license.uri);
341
        cy.get("#agreement_license_0 #license_uri_0").type(related_license.uri);
324
342
325
        // Add new related agreement
343
        // Add new related agreement
Lines 329-345 describe("Agreement CRUD operations", () => { Link Here
329
            body: cy.get_agreements_to_relate(),
347
            body: cy.get_agreements_to_relate(),
330
        });
348
        });
331
        cy.visit("/cgi-bin/koha/erm/agreements/add");
349
        cy.visit("/cgi-bin/koha/erm/agreements/add");
332
        cy.get("#agreement_relationships").contains("Add new related agreement").click();
350
        cy.get("#agreement_relationships")
351
            .contains("Add new related agreement")
352
            .click();
333
        cy.get("#related_agreement_0").contains("Related agreement 1");
353
        cy.get("#related_agreement_0").contains("Related agreement 1");
334
        cy.get("#related_agreement_0 #related_agreement_id_0 .vs__search").type(
354
        cy.get("#related_agreement_0 #related_agreement_id_0 .vs__search").type(
335
            related_agreement.related_agreement.name
355
            related_agreement.related_agreement.name
336
        );
356
        );
337
        cy.get("#related_agreement_0 #related_agreement_id_0 .vs__dropdown-menu li").eq(0).click( { force: true } ); //click first agreement suggestion
357
        cy.get(
338
        cy.get("#related_agreement_0 #related_agreement_notes_0").type(related_agreement.notes);
358
            "#related_agreement_0 #related_agreement_id_0 .vs__dropdown-menu li"
339
        cy.get("#related_agreement_0 #related_agreement_relationship_0 .vs__search").type(
359
        )
340
            related_agreement.relationship + "{enter}",
360
            .eq(0)
341
            { force: true }
361
            .click({ force: true }); //click first agreement suggestion
362
        cy.get("#related_agreement_0 #related_agreement_notes_0").type(
363
            related_agreement.notes
342
        );
364
        );
365
        cy.get(
366
            "#related_agreement_0 #related_agreement_relationship_0 .vs__search"
367
        ).type(related_agreement.relationship + "{enter}", { force: true });
343
    });
368
    });
344
369
345
    it("Edit agreement", () => {
370
    it("Edit agreement", () => {
Lines 352-361 describe("Agreement CRUD operations", () => { Link Here
352
            {
377
            {
353
                method: "GET",
378
                method: "GET",
354
                url: "/api/v1/erm/agreements*",
379
                url: "/api/v1/erm/agreements*",
355
                times: 1
380
                times: 1,
356
            },
381
            },
357
            {
382
            {
358
                body: agreements
383
                body: agreements,
359
            }
384
            }
360
        );
385
        );
361
386
Lines 414-426 describe("Agreement CRUD operations", () => { Link Here
414
        cy.get("#notes_1").should("have.value", "this is a note");
439
        cy.get("#notes_1").should("have.value", "this is a note");
415
440
416
        //Test related content
441
        //Test related content
417
        cy.get("#agreement_license_0 #license_id_0 .vs__selected").contains("first license name");
442
        cy.get("#agreement_license_0 #license_id_0 .vs__selected").contains(
418
        cy.get("#agreement_license_1 #license_id_1 .vs__selected").contains("second license name");
443
            "first license name"
419
        cy.get("#document_0 .file_information span").contains("file.json" );
444
        );
420
        cy.get("#related_agreement_0 #related_agreement_id_0 .vs__selected").contains("agreement name");
445
        cy.get("#agreement_license_1 #license_id_1 .vs__selected").contains(
446
            "second license name"
447
        );
448
        cy.get("#document_0 .file_information span").contains("file.json");
449
        cy.get(
450
            "#related_agreement_0 #related_agreement_id_0 .vs__selected"
451
        ).contains("agreement name");
421
452
422
        // Submit the form, get 500
453
        // Submit the form, get 500
423
        cy.intercept("PUT", "/api/v1/erm/agreements/*", (req) => {
454
        cy.intercept("PUT", "/api/v1/erm/agreements/*", req => {
424
            req.reply({
455
            req.reply({
425
                statusCode: 500,
456
                statusCode: 500,
426
                error: "Something went wrong",
457
                error: "Something went wrong",
Lines 501-507 describe("Agreement CRUD operations", () => { Link Here
501
        cy.get("#agreements_list table tbody tr:first")
532
        cy.get("#agreements_list table tbody tr:first")
502
            .contains("Delete")
533
            .contains("Delete")
503
            .click();
534
            .click();
504
        cy.get(".dialog.alert.confirmation h1").contains("remove this agreement");
535
        cy.get(".dialog.alert.confirmation h1").contains(
536
            "remove this agreement"
537
        );
505
        cy.contains(agreement.name);
538
        cy.contains(agreement.name);
506
539
507
        // Accept the confirmation dialog, get 500
540
        // Accept the confirmation dialog, get 500
Lines 522-530 describe("Agreement CRUD operations", () => { Link Here
522
        cy.get("#agreements_list table tbody tr:first")
555
        cy.get("#agreements_list table tbody tr:first")
523
            .contains("Delete")
556
            .contains("Delete")
524
            .click();
557
            .click();
525
        cy.get(".dialog.alert.confirmation h1").contains("remove this agreement");
558
        cy.get(".dialog.alert.confirmation h1").contains(
559
            "remove this agreement"
560
        );
526
        cy.contains("Yes, delete").click();
561
        cy.contains("Yes, delete").click();
527
        cy.get("main div[class='dialog message']").contains("Agreement").contains("deleted");
562
        cy.get("main div[class='dialog message']")
563
            .contains("Agreement")
564
            .contains("deleted");
528
565
529
        // Delete from show
566
        // Delete from show
530
        // Click the "name" link from the list
567
        // Click the "name" link from the list
Lines 554-564 describe("Agreement CRUD operations", () => { Link Here
554
            "Agreement #" + agreement.agreement_id
591
            "Agreement #" + agreement.agreement_id
555
        );
592
        );
556
593
557
        cy.get('#agreements_show .action_links .fa-trash').click();
594
        cy.get("#agreements_show .action_links .fa-trash").click();
558
        cy.get(".dialog.alert.confirmation h1").contains("remove this agreement");
595
        cy.get(".dialog.alert.confirmation h1").contains(
596
            "remove this agreement"
597
        );
559
        cy.contains("Yes, delete").click();
598
        cy.contains("Yes, delete").click();
560
599
561
        //Make sure we return to list after deleting from show
600
        //Make sure we return to list after deleting from show
562
        cy.get("#agreements_list table tbody tr:first")
601
        cy.get("#agreements_list table tbody tr:first");
563
    });
602
    });
564
});
603
});
(-)a/t/cypress/integration/ERM/Dialog_spec.ts (-3 / +13 lines)
Lines 25-32 describe("Dialog operations", () => { Link Here
25
    beforeEach(() => {
25
    beforeEach(() => {
26
        cy.login();
26
        cy.login();
27
        cy.title().should("eq", "Koha staff interface");
27
        cy.title().should("eq", "Koha staff interface");
28
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
28
        cy.intercept(
29
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
29
            "GET",
30
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
31
            '{"value":"1"}'
32
        );
33
        cy.intercept(
34
            "GET",
35
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
36
            '{"value":"local"}'
37
        );
30
    });
38
    });
31
39
32
    it("There are no ... defined", () => {
40
    it("There are no ... defined", () => {
Lines 58-64 describe("Dialog operations", () => { Link Here
58
        cy.intercept("GET", "/api/v1/erm/agreements*", []);
66
        cy.intercept("GET", "/api/v1/erm/agreements*", []);
59
        cy.get("#navmenulist").contains("Agreements").click();
67
        cy.get("#navmenulist").contains("Agreements").click();
60
        // Info messages should be cleared when view is changed
68
        // Info messages should be cleared when view is changed
61
        cy.get("main div[class='dialog message']").contains("There are no agreements defined");
69
        cy.get("main div[class='dialog message']").contains(
70
            "There are no agreements defined"
71
        );
62
        cy.get("main div[class='dialog message']").should("have.length", 1);
72
        cy.get("main div[class='dialog message']").should("have.length", 1);
63
    });
73
    });
64
74
(-)a/t/cypress/integration/ERM/Licenses_spec.ts (-31 / +41 lines)
Lines 20-33 function get_license() { Link Here
20
        user_roles: [],
20
        user_roles: [],
21
        documents: [
21
        documents: [
22
            {
22
            {
23
                license_id:1,
23
                license_id: 1,
24
                file_description: "file description",
24
                file_description: "file description",
25
                file_name: "file.json",
25
                file_name: "file.json",
26
                notes: "file notes",
26
                notes: "file notes",
27
                physical_location: "file physical location",
27
                physical_location: "file physical location",
28
                uri: "file uri",
28
                uri: "file uri",
29
                uploaded_on: "2022-10-27T11:57:02+00:00"
29
                uploaded_on: "2022-10-27T11:57:02+00:00",
30
            }
30
            },
31
        ],
31
        ],
32
    };
32
    };
33
}
33
}
Lines 36-43 describe("License CRUD operations", () => { Link Here
36
    beforeEach(() => {
36
    beforeEach(() => {
37
        cy.login();
37
        cy.login();
38
        cy.title().should("eq", "Koha staff interface");
38
        cy.title().should("eq", "Koha staff interface");
39
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
39
        cy.intercept(
40
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
40
            "GET",
41
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
42
            '{"value":"1"}'
43
        );
44
        cy.intercept(
45
            "GET",
46
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
47
            '{"value":"local"}'
48
        );
41
    });
49
    });
42
50
43
    it("List license", () => {
51
    it("List license", () => {
Lines 91-98 describe("License CRUD operations", () => { Link Here
91
        cy.get("#license_name").type(license.name);
99
        cy.get("#license_name").type(license.name);
92
        cy.get("#license_description").type(license.description);
100
        cy.get("#license_description").type(license.description);
93
        cy.get("#licenses_add").contains("Submit").click();
101
        cy.get("#licenses_add").contains("Submit").click();
94
        cy.get("#license_type .vs__search").type(license.type + '{enter}',{force:true});
102
        cy.get("#license_type .vs__search").type(license.type + "{enter}", {
95
        cy.get("#license_status .vs__search").type(license.status + '{enter}',{force:true});
103
            force: true,
104
        });
105
        cy.get("#license_status .vs__search").type(license.status + "{enter}", {
106
            force: true,
107
        });
96
108
97
        cy.get("#started_on+input").click();
109
        cy.get("#started_on+input").click();
98
        cy.get(".flatpickr-calendar")
110
        cy.get(".flatpickr-calendar")
Lines 110-121 describe("License CRUD operations", () => { Link Here
110
        // Add new document
122
        // Add new document
111
        cy.get("#documents").contains("Add new document").click();
123
        cy.get("#documents").contains("Add new document").click();
112
        cy.get("#document_0 input[id=file_0]").click();
124
        cy.get("#document_0 input[id=file_0]").click();
113
        cy.get('#document_0 input[id=file_0]').selectFile('t/cypress/fixtures/file.json');
125
        cy.get("#document_0 input[id=file_0]").selectFile(
126
            "t/cypress/fixtures/file.json"
127
        );
114
        cy.get("#document_0 .file_information span").contains("file.json");
128
        cy.get("#document_0 .file_information span").contains("file.json");
115
        cy.get('#document_0 input[id=file_description_0]').type('file description');
129
        cy.get("#document_0 input[id=file_description_0]").type(
116
        cy.get('#document_0 input[id=physical_location_0]').type('file physical location');
130
            "file description"
117
        cy.get('#document_0 input[id=uri_0]').type('file URI');
131
        );
118
        cy.get('#document_0 input[id=notes_0]').type('file notes');
132
        cy.get("#document_0 input[id=physical_location_0]").type(
133
            "file physical location"
134
        );
135
        cy.get("#document_0 input[id=uri_0]").type("file URI");
136
        cy.get("#document_0 input[id=notes_0]").type("file notes");
119
137
120
        // Submit the form, get 500
138
        // Submit the form, get 500
121
        cy.intercept("POST", "/api/v1/erm/licenses", {
139
        cy.intercept("POST", "/api/v1/erm/licenses", {
Lines 133-141 describe("License CRUD operations", () => { Link Here
133
            body: license,
151
            body: license,
134
        });
152
        });
135
        cy.get("#licenses_add").contains("Submit").click();
153
        cy.get("#licenses_add").contains("Submit").click();
136
        cy.get("main div[class='dialog message']").contains(
154
        cy.get("main div[class='dialog message']").contains("License created");
137
            "License created"
138
        );
139
    });
155
    });
140
156
141
    it("Edit license", () => {
157
    it("Edit license", () => {
Lines 154-162 describe("License CRUD operations", () => { Link Here
154
            "get-license"
170
            "get-license"
155
        );
171
        );
156
        cy.visit("/cgi-bin/koha/erm/licenses");
172
        cy.visit("/cgi-bin/koha/erm/licenses");
157
        cy.get("#licenses_list table tbody tr:first")
173
        cy.get("#licenses_list table tbody tr:first").contains("Edit").click();
158
            .contains("Edit")
159
            .click();
160
        cy.wait("@get-license");
174
        cy.wait("@get-license");
161
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
175
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
162
        cy.get("#licenses_add h2").contains("Edit license");
176
        cy.get("#licenses_add h2").contains("Edit license");
Lines 173-179 describe("License CRUD operations", () => { Link Here
173
        cy.get("#ended_on").invoke("val").should("eq", dates["tomorrow_iso"]);
187
        cy.get("#ended_on").invoke("val").should("eq", dates["tomorrow_iso"]);
174
188
175
        // Test related document
189
        // Test related document
176
        cy.get("#document_0 .file_information span").contains("file.json" );
190
        cy.get("#document_0 .file_information span").contains("file.json");
177
191
178
        // Submit the form, get 500
192
        // Submit the form, get 500
179
        cy.intercept("PUT", "/api/v1/erm/licenses/*", {
193
        cy.intercept("PUT", "/api/v1/erm/licenses/*", {
Lines 191-199 describe("License CRUD operations", () => { Link Here
191
            body: license,
205
            body: license,
192
        });
206
        });
193
        cy.get("#licenses_add").contains("Submit").click();
207
        cy.get("#licenses_add").contains("Submit").click();
194
        cy.get("main div[class='dialog message']").contains(
208
        cy.get("main div[class='dialog message']").contains("License updated");
195
            "License updated"
196
        );
197
    });
209
    });
198
210
199
    it("Show license", () => {
211
    it("Show license", () => {
Lines 222-230 describe("License CRUD operations", () => { Link Here
222
        name_link.click();
234
        name_link.click();
223
        cy.wait("@get-license");
235
        cy.wait("@get-license");
224
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
236
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
225
        cy.get("#licenses_show h2").contains(
237
        cy.get("#licenses_show h2").contains("License #" + license.license_id);
226
            "License #" + license.license_id
227
        );
228
    });
238
    });
229
239
230
    it("Delete license", () => {
240
    it("Delete license", () => {
Lines 269-275 describe("License CRUD operations", () => { Link Here
269
            .click();
279
            .click();
270
        cy.get(".dialog.alert.confirmation h1").contains("remove this license");
280
        cy.get(".dialog.alert.confirmation h1").contains("remove this license");
271
        cy.contains("Yes, delete").click();
281
        cy.contains("Yes, delete").click();
272
        cy.get("main div[class='dialog message']").contains("License").contains("deleted");
282
        cy.get("main div[class='dialog message']")
283
            .contains("License")
284
            .contains("deleted");
273
285
274
        // Delete from show
286
        // Delete from show
275
        // Click the "name" link from the list
287
        // Click the "name" link from the list
Lines 295-309 describe("License CRUD operations", () => { Link Here
295
        name_link.click();
307
        name_link.click();
296
        cy.wait("@get-license");
308
        cy.wait("@get-license");
297
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
309
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
298
        cy.get("#licenses_show h2").contains(
310
        cy.get("#licenses_show h2").contains("License #" + license.license_id);
299
            "License #" + license.license_id
300
        );
301
311
302
        cy.get('#licenses_show .action_links .fa-trash').click();
312
        cy.get("#licenses_show .action_links .fa-trash").click();
303
        cy.get(".dialog.alert.confirmation h1").contains("remove this license");
313
        cy.get(".dialog.alert.confirmation h1").contains("remove this license");
304
        cy.contains("Yes, delete").click();
314
        cy.contains("Yes, delete").click();
305
315
306
        //Make sure we return to list after deleting from show
316
        //Make sure we return to list after deleting from show
307
        cy.get("#licenses_list table tbody tr:first")
317
        cy.get("#licenses_list table tbody tr:first");
308
    });
318
    });
309
});
319
});
(-)a/t/cypress/integration/ERM/Packages_spec.ts (-11 / +24 lines)
Lines 13-23 function get_package() { Link Here
13
                agreement: {
13
                agreement: {
14
                    agreement_id: 2,
14
                    agreement_id: 2,
15
                    description: "agreement description",
15
                    description: "agreement description",
16
                    name: "agreement name"
16
                    name: "agreement name",
17
                },
17
                },
18
                agreement_id: 2,
18
                agreement_id: 2,
19
                package_id: 1
19
                package_id: 1,
20
            }
20
            },
21
        ],
21
        ],
22
        resources_count: 0,
22
        resources_count: 0,
23
    };
23
    };
Lines 27-34 describe("Package CRUD operations", () => { Link Here
27
    beforeEach(() => {
27
    beforeEach(() => {
28
        cy.login();
28
        cy.login();
29
        cy.title().should("eq", "Koha staff interface");
29
        cy.title().should("eq", "Koha staff interface");
30
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
30
        cy.intercept(
31
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
31
            "GET",
32
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
33
            '{"value":"1"}'
34
        );
35
        cy.intercept(
36
            "GET",
37
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
38
            '{"value":"local"}'
39
        );
32
    });
40
    });
33
41
34
    it("List package", () => {
42
    it("List package", () => {
Lines 77-83 describe("Package CRUD operations", () => { Link Here
77
    });
85
    });
78
86
79
    it("Add package", () => {
87
    it("Add package", () => {
80
81
        cy.intercept("GET", "/api/v1/erm/agreements*", []);
88
        cy.intercept("GET", "/api/v1/erm/agreements*", []);
82
89
83
        // Click the button in the toolbar
90
        // Click the button in the toolbar
Lines 137-143 describe("Package CRUD operations", () => { Link Here
137
        cy.get("#agreement_id_0 .vs__search").type(
144
        cy.get("#agreement_id_0 .vs__search").type(
138
            related_agreement.agreement.name
145
            related_agreement.agreement.name
139
        );
146
        );
140
        cy.get("#agreement_id_0 .vs__dropdown-menu li").eq(0).click( { force: true } ); //click first agreement suggestion
147
        cy.get("#agreement_id_0 .vs__dropdown-menu li")
148
            .eq(0)
149
            .click({ force: true }); //click first agreement suggestion
141
    });
150
    });
142
151
143
    it("Edit package", () => {
152
    it("Edit package", () => {
Lines 174-180 describe("Package CRUD operations", () => { Link Here
174
        cy.get("#package_content_type .vs__selected").contains("Print");
183
        cy.get("#package_content_type .vs__selected").contains("Print");
175
184
176
        //Test related content
185
        //Test related content
177
        cy.get("#package_agreement_0 #agreement_id_0 .vs__selected").contains("second agreement name");
186
        cy.get("#package_agreement_0 #agreement_id_0 .vs__selected").contains(
187
            "second agreement name"
188
        );
178
189
179
        // Submit the form, get 500
190
        // Submit the form, get 500
180
        cy.intercept("PUT", "/api/v1/erm/eholdings/local/packages/*", {
191
        cy.intercept("PUT", "/api/v1/erm/eholdings/local/packages/*", {
Lines 311-317 describe("Package CRUD operations", () => { Link Here
311
            .click();
322
            .click();
312
        cy.get(".dialog.alert.confirmation h1").contains("remove this package");
323
        cy.get(".dialog.alert.confirmation h1").contains("remove this package");
313
        cy.contains("Yes, delete").click();
324
        cy.contains("Yes, delete").click();
314
        cy.get("main div[class='dialog message']").contains("Local package").contains("deleted");
325
        cy.get("main div[class='dialog message']")
326
            .contains("Local package")
327
            .contains("deleted");
315
328
316
        // Delete from show
329
        // Delete from show
317
        // Click the "name" link from the list
330
        // Click the "name" link from the list
Lines 343-353 describe("Package CRUD operations", () => { Link Here
343
            "Package #" + erm_package.package_id
356
            "Package #" + erm_package.package_id
344
        );
357
        );
345
358
346
        cy.get('#packages_show .action_links .fa-trash').click();
359
        cy.get("#packages_show .action_links .fa-trash").click();
347
        cy.get(".dialog.alert.confirmation h1").contains("remove this package");
360
        cy.get(".dialog.alert.confirmation h1").contains("remove this package");
348
        cy.contains("Yes, delete").click();
361
        cy.contains("Yes, delete").click();
349
362
350
        //Make sure we return to list after deleting from show
363
        //Make sure we return to list after deleting from show
351
        cy.get("#packages_list table tbody tr:first")
364
        cy.get("#packages_list table tbody tr:first");
352
    });
365
    });
353
});
366
});
(-)a/t/cypress/integration/ERM/Searchbar_spec.ts (-13 / +20 lines)
Lines 1-32 Link Here
1
describe("Searchbar header changes", () => {
1
describe("Searchbar header changes", () => {
2
3
    beforeEach(() => {
2
    beforeEach(() => {
4
        cy.login();
3
        cy.login();
5
        cy.title().should("eq", "Koha staff interface");
4
        cy.title().should("eq", "Koha staff interface");
6
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
5
        cy.intercept(
7
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
6
            "GET",
7
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
8
            '{"value":"1"}'
9
        );
10
        cy.intercept(
11
            "GET",
12
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
13
            '{"value":"local"}'
14
        );
8
    });
15
    });
9
16
10
    it("Default option is agreements", () => {
17
    it("Default option is agreements", () => {
11
        cy.visit("/cgi-bin/koha/erm/erm.pl");
18
        cy.visit("/cgi-bin/koha/erm/erm.pl");
12
        cy.get("#agreement_search_tab").parent().should("have.class", "active")
19
        cy.get("#agreement_search_tab").parent().should("have.class", "active");
13
20
14
        cy.visit("/cgi-bin/koha/erm/agreements");
21
        cy.visit("/cgi-bin/koha/erm/agreements");
15
        cy.get("#agreement_search_tab").parent().should("have.class", "active")
22
        cy.get("#agreement_search_tab").parent().should("have.class", "active");
16
    })
23
    });
17
24
18
    it("Default option also applies to licenses", () => {
25
    it("Default option also applies to licenses", () => {
19
        cy.visit("/cgi-bin/koha/erm/license");
26
        cy.visit("/cgi-bin/koha/erm/license");
20
        cy.get("#agreement_search_tab").parent().should("have.class", "active")
27
        cy.get("#agreement_search_tab").parent().should("have.class", "active");
21
    })
28
    });
22
29
23
    it("Should change to packages when in local packages", () => {
30
    it("Should change to packages when in local packages", () => {
24
        cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
31
        cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
25
        cy.get("#package_search_tab").parent().should("have.class", "active")
32
        cy.get("#package_search_tab").parent().should("have.class", "active");
26
    })
33
    });
27
34
28
    it("Should change to titles when in local titles", () => {
35
    it("Should change to titles when in local titles", () => {
29
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
36
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
30
        cy.get("#title_search_tab").parent().should("have.class", "active")
37
        cy.get("#title_search_tab").parent().should("have.class", "active");
31
    })
38
    });
32
})
39
});
(-)a/t/cypress/integration/ERM/Titles_spec.ts (-92 / +174 lines)
Lines 7-28 function get_packages_to_relate() { Link Here
7
        {
7
        {
8
            package_id: 1,
8
            package_id: 1,
9
            description: "a package",
9
            description: "a package",
10
            name: "first package name"
10
            name: "first package name",
11
        },
11
        },
12
        {
12
        {
13
            package_id: 2,
13
            package_id: 2,
14
            description: "a second package",
14
            description: "a second package",
15
            name: "second package name"
15
            name: "second package name",
16
        }
16
        },
17
    ]
17
    ];
18
}
18
}
19
19
20
describe("Title CRUD operations", () => {
20
describe("Title CRUD operations", () => {
21
    beforeEach(() => {
21
    beforeEach(() => {
22
        cy.login();
22
        cy.login();
23
        cy.title().should("eq", "Koha staff interface");
23
        cy.title().should("eq", "Koha staff interface");
24
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
24
        cy.intercept(
25
        cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
25
            "GET",
26
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
27
            '{"value":"1"}'
28
        );
29
        cy.intercept(
30
            "GET",
31
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
32
            '{"value":"local"}'
33
        );
26
    });
34
    });
27
35
28
    it("Import titles", () => {
36
    it("Import titles", () => {
Lines 32-50 describe("Title CRUD operations", () => { Link Here
32
        // Create a list in case none exists
40
        // Create a list in case none exists
33
        cy.visit("/cgi-bin/koha/virtualshelves/shelves.pl");
41
        cy.visit("/cgi-bin/koha/virtualshelves/shelves.pl");
34
        cy.contains("New list").click();
42
        cy.contains("New list").click();
35
        cy.get("#shelfname").type('list name');
43
        cy.get("#shelfname").type("list name");
36
        cy.contains("Save").click();
44
        cy.contains("Save").click();
37
45
38
        // First attempt to import list has no packages
46
        // First attempt to import list has no packages
39
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
47
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
40
            statusCode: 200,
48
            statusCode: 200,
41
            body: []
49
            body: [],
42
        }).as("get-empty-packages");
50
        }).as("get-empty-packages");
43
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
51
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
44
        cy.wait(500);
52
        cy.wait(500);
45
        cy.get("#toolbar a").contains("Import from list").click();
53
        cy.get("#toolbar a").contains("Import from list").click();
46
        cy.get("h2").contains("Import from a list");
54
        cy.get("h2").contains("Import from a list");
47
        cy.get("#package_list .vs__selected").should('not.exist');
55
        cy.get("#package_list .vs__selected").should("not.exist");
48
56
49
        // Make sure packages are returned
57
        // Make sure packages are returned
50
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
58
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
Lines 59-68 describe("Title CRUD operations", () => { Link Here
59
        // Prepare background job response to the POST
67
        // Prepare background job response to the POST
60
        cy.intercept("POST", "/api/v1/erm/eholdings/local/titles/import", {
68
        cy.intercept("POST", "/api/v1/erm/eholdings/local/titles/import", {
61
            statusCode: 200,
69
            statusCode: 200,
62
            body: {job_id: 1},
70
            body: { job_id: 1 },
63
        }).as("get-job-response");
71
        }).as("get-job-response");
64
        cy.get("#list_list tbody tr:first td a").contains("Import").click();
72
        cy.get("#list_list tbody tr:first td a").contains("Import").click();
65
        cy.get("main div[class='dialog message']").contains("Import in progress, see job #1");
73
        cy.get("main div[class='dialog message']").contains(
74
            "Import in progress, see job #1"
75
        );
66
    });
76
    });
67
77
68
    it("List title", () => {
78
    it("List title", () => {
Lines 106-120 describe("Title CRUD operations", () => { Link Here
106
    });
116
    });
107
117
108
    it("Add title", () => {
118
    it("Add title", () => {
109
119
        cy.intercept(
110
        cy.intercept({
120
            {
111
            method: "GET",
121
                method: "GET",
112
            url: "/api/v1/erm/eholdings/local/packages*",
122
                url: "/api/v1/erm/eholdings/local/packages*",
113
            times: 1
123
                times: 1,
114
        },
124
            },
115
        {
125
            {
116
            body: [],
126
                body: [],
117
        });
127
            }
128
        );
118
129
119
        // Click the button in the toolbar
130
        // Click the button in the toolbar
120
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
131
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
Lines 133-144 describe("Title CRUD operations", () => { Link Here
133
        cy.get("#title_publication_title").type(erm_title.publication_title);
144
        cy.get("#title_publication_title").type(erm_title.publication_title);
134
        cy.get("#title_print_identifier").type(erm_title.print_identifier);
145
        cy.get("#title_print_identifier").type(erm_title.print_identifier);
135
        cy.get("#title_online_identifier").type(erm_title.online_identifier);
146
        cy.get("#title_online_identifier").type(erm_title.online_identifier);
136
        cy.get("#title_date_first_issue_online").type(erm_title.date_first_issue_online);
147
        cy.get("#title_date_first_issue_online").type(
137
        cy.get("#title_num_first_vol_online").type(erm_title.num_first_vol_online);
148
            erm_title.date_first_issue_online
138
        cy.get("#title_num_first_issue_online").type(erm_title.num_first_issue_online);
149
        );
139
        cy.get("#title_date_last_issue_online").type(erm_title.date_last_issue_online);
150
        cy.get("#title_num_first_vol_online").type(
140
        cy.get("#title_num_last_vol_online").type(erm_title.num_last_vol_online);
151
            erm_title.num_first_vol_online
141
        cy.get("#title_num_last_issue_online").type(erm_title.num_last_issue_online);
152
        );
153
        cy.get("#title_num_first_issue_online").type(
154
            erm_title.num_first_issue_online
155
        );
156
        cy.get("#title_date_last_issue_online").type(
157
            erm_title.date_last_issue_online
158
        );
159
        cy.get("#title_num_last_vol_online").type(
160
            erm_title.num_last_vol_online
161
        );
162
        cy.get("#title_num_last_issue_online").type(
163
            erm_title.num_last_issue_online
164
        );
142
        cy.get("#title_title_url").type(erm_title.title_url);
165
        cy.get("#title_title_url").type(erm_title.title_url);
143
        cy.get("#title_first_author").type(erm_title.first_author);
166
        cy.get("#title_first_author").type(erm_title.first_author);
144
        cy.get("#title_embargo_info").type(erm_title.embargo_info);
167
        cy.get("#title_embargo_info").type(erm_title.embargo_info);
Lines 149-166 describe("Title CRUD operations", () => { Link Here
149
            erm_title.publication_type + "{enter}",
172
            erm_title.publication_type + "{enter}",
150
            { force: true }
173
            { force: true }
151
        );
174
        );
152
        cy.get("#title_date_monograph_published_print").type(erm_title.date_monograph_published_print);
175
        cy.get("#title_date_monograph_published_print").type(
153
        cy.get("#title_date_monograph_published_online").type(erm_title.date_monograph_published_online);
176
            erm_title.date_monograph_published_print
177
        );
178
        cy.get("#title_date_monograph_published_online").type(
179
            erm_title.date_monograph_published_online
180
        );
154
        cy.get("#title_monograph_volume").type(erm_title.monograph_volume);
181
        cy.get("#title_monograph_volume").type(erm_title.monograph_volume);
155
        cy.get("#title_monograph_edition").type(erm_title.monograph_edition);
182
        cy.get("#title_monograph_edition").type(erm_title.monograph_edition);
156
        cy.get("#title_first_editor").type(erm_title.first_editor);
183
        cy.get("#title_first_editor").type(erm_title.first_editor);
157
        cy.get("#title_parent_publication_title_id").type(erm_title.parent_publication_title_id);
184
        cy.get("#title_parent_publication_title_id").type(
158
        cy.get("#title_preceeding_publication_title_id").type(erm_title.preceeding_publication_title_id);
185
            erm_title.parent_publication_title_id
186
        );
187
        cy.get("#title_preceeding_publication_title_id").type(
188
            erm_title.preceeding_publication_title_id
189
        );
159
        cy.get("#title_access_type").type(erm_title.access_type);
190
        cy.get("#title_access_type").type(erm_title.access_type);
160
191
161
        cy.get("#resources").contains(
192
        cy.get("#resources").contains("There are no packages created yet");
162
            "There are no packages created yet"
163
        );
164
193
165
        // Submit the form, get 500
194
        // Submit the form, get 500
166
        cy.intercept("POST", "/api/v1/erm/eholdings/local/titles", {
195
        cy.intercept("POST", "/api/v1/erm/eholdings/local/titles", {
Lines 185-198 describe("Title CRUD operations", () => { Link Here
185
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
214
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
186
            statusCode: 200,
215
            statusCode: 200,
187
            body: get_packages_to_relate(),
216
            body: get_packages_to_relate(),
188
        }).as('get-related-packages');
217
        }).as("get-related-packages");
189
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles/add");
218
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles/add");
190
        cy.get("#resources").contains("Add to another package").click();
219
        cy.get("#resources").contains("Add to another package").click();
191
        cy.get("#resources").contains("Package 1");
220
        cy.get("#resources").contains("Package 1");
192
        cy.get("#resources #resource_package_id_0 .vs__search").type(
221
        cy.get("#resources #resource_package_id_0 .vs__search").type(
193
            related_package.package.name
222
            related_package.package.name
194
        );
223
        );
195
        cy.get("#resources #resource_package_id_0 .vs__dropdown-menu li").eq(0).click( { force: true } ); //click first package suggestion
224
        cy.get("#resources #resource_package_id_0 .vs__dropdown-menu li")
225
            .eq(0)
226
            .click({ force: true }); //click first package suggestion
196
    });
227
    });
197
228
198
    it("Edit title", () => {
229
    it("Edit title", () => {
Lines 217-223 describe("Title CRUD operations", () => { Link Here
217
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
248
        cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
218
            statusCode: 200,
249
            statusCode: 200,
219
            body: get_packages_to_relate(),
250
            body: get_packages_to_relate(),
220
        }).as('get-related-packages');
251
        }).as("get-related-packages");
221
252
222
        cy.get("#titles_list table tbody tr:first").contains("Edit").click();
253
        cy.get("#titles_list table tbody tr:first").contains("Edit").click();
223
        cy.wait("@get-title");
254
        cy.wait("@get-title");
Lines 225-257 describe("Title CRUD operations", () => { Link Here
225
        cy.get("#titles_add h2").contains("Edit title");
256
        cy.get("#titles_add h2").contains("Edit title");
226
257
227
        // Form has been correctly filled in
258
        // Form has been correctly filled in
228
        cy.get("#title_publication_title").should("have.value", erm_title.publication_title);
259
        cy.get("#title_publication_title").should(
229
        cy.get("#title_print_identifier").should("have.value", erm_title.print_identifier);
260
            "have.value",
230
        cy.get("#title_online_identifier").should("have.value", erm_title.online_identifier);
261
            erm_title.publication_title
231
        cy.get("#title_date_first_issue_online").should("have.value", erm_title.date_first_issue_online);
262
        );
232
        cy.get("#title_num_first_vol_online").should("have.value", erm_title.num_first_vol_online);
263
        cy.get("#title_print_identifier").should(
233
        cy.get("#title_num_first_issue_online").should("have.value", erm_title.num_first_issue_online);
264
            "have.value",
234
        cy.get("#title_date_last_issue_online").should("have.value", erm_title.date_last_issue_online);
265
            erm_title.print_identifier
235
        cy.get("#title_num_last_vol_online").should("have.value", erm_title.num_last_vol_online);
266
        );
236
        cy.get("#title_num_last_issue_online").should("have.value", erm_title.num_last_issue_online);
267
        cy.get("#title_online_identifier").should(
268
            "have.value",
269
            erm_title.online_identifier
270
        );
271
        cy.get("#title_date_first_issue_online").should(
272
            "have.value",
273
            erm_title.date_first_issue_online
274
        );
275
        cy.get("#title_num_first_vol_online").should(
276
            "have.value",
277
            erm_title.num_first_vol_online
278
        );
279
        cy.get("#title_num_first_issue_online").should(
280
            "have.value",
281
            erm_title.num_first_issue_online
282
        );
283
        cy.get("#title_date_last_issue_online").should(
284
            "have.value",
285
            erm_title.date_last_issue_online
286
        );
287
        cy.get("#title_num_last_vol_online").should(
288
            "have.value",
289
            erm_title.num_last_vol_online
290
        );
291
        cy.get("#title_num_last_issue_online").should(
292
            "have.value",
293
            erm_title.num_last_issue_online
294
        );
237
        cy.get("#title_title_url").should("have.value", erm_title.title_url);
295
        cy.get("#title_title_url").should("have.value", erm_title.title_url);
238
        cy.get("#title_first_author").should("have.value", erm_title.first_author);
296
        cy.get("#title_first_author").should(
239
        cy.get("#title_embargo_info").should("have.value", erm_title.embargo_info);
297
            "have.value",
240
        cy.get("#title_coverage_depth").should("have.value", erm_title.coverage_depth);
298
            erm_title.first_author
299
        );
300
        cy.get("#title_embargo_info").should(
301
            "have.value",
302
            erm_title.embargo_info
303
        );
304
        cy.get("#title_coverage_depth").should(
305
            "have.value",
306
            erm_title.coverage_depth
307
        );
241
        cy.get("#title_notes").should("have.value", erm_title.notes);
308
        cy.get("#title_notes").should("have.value", erm_title.notes);
242
        cy.get("#title_publisher_name").should("have.value", erm_title.publisher_name);
309
        cy.get("#title_publisher_name").should(
243
        cy.get("#title_publication_type .vs__selected").contains('Journal');
310
            "have.value",
244
        cy.get("#title_date_monograph_published_print").should("have.value", erm_title.date_monograph_published_print);
311
            erm_title.publisher_name
245
        cy.get("#title_date_monograph_published_online").should("have.value", erm_title.date_monograph_published_online);
312
        );
246
        cy.get("#title_monograph_volume").should("have.value", erm_title.monograph_volume);
313
        cy.get("#title_publication_type .vs__selected").contains("Journal");
247
        cy.get("#title_monograph_edition").should("have.value", erm_title.monograph_edition);
314
        cy.get("#title_date_monograph_published_print").should(
248
        cy.get("#title_first_editor").should("have.value", erm_title.first_editor);
315
            "have.value",
249
        cy.get("#title_parent_publication_title_id").should("have.value", erm_title.parent_publication_title_id);
316
            erm_title.date_monograph_published_print
250
        cy.get("#title_preceeding_publication_title_id").should("have.value", erm_title.preceeding_publication_title_id);
317
        );
251
        cy.get("#title_access_type").should("have.value", erm_title.access_type);
318
        cy.get("#title_date_monograph_published_online").should(
319
            "have.value",
320
            erm_title.date_monograph_published_online
321
        );
322
        cy.get("#title_monograph_volume").should(
323
            "have.value",
324
            erm_title.monograph_volume
325
        );
326
        cy.get("#title_monograph_edition").should(
327
            "have.value",
328
            erm_title.monograph_edition
329
        );
330
        cy.get("#title_first_editor").should(
331
            "have.value",
332
            erm_title.first_editor
333
        );
334
        cy.get("#title_parent_publication_title_id").should(
335
            "have.value",
336
            erm_title.parent_publication_title_id
337
        );
338
        cy.get("#title_preceeding_publication_title_id").should(
339
            "have.value",
340
            erm_title.preceeding_publication_title_id
341
        );
342
        cy.get("#title_access_type").should(
343
            "have.value",
344
            erm_title.access_type
345
        );
252
346
253
        //Test related content
347
        //Test related content
254
        cy.get("#resources #resource_package_id_0 .vs__selected").contains("package name");
348
        cy.get("#resources #resource_package_id_0 .vs__selected").contains(
349
            "package name"
350
        );
255
351
256
        // Submit the form, get 500
352
        // Submit the form, get 500
257
        cy.intercept("PUT", "/api/v1/erm/eholdings/local/titles/*", {
353
        cy.intercept("PUT", "/api/v1/erm/eholdings/local/titles/*", {
Lines 289-315 describe("Title CRUD operations", () => { Link Here
289
            {
385
            {
290
                method: "GET",
386
                method: "GET",
291
                url: "/api/v1/erm/eholdings/local/titles/*",
387
                url: "/api/v1/erm/eholdings/local/titles/*",
292
                times: 1
388
                times: 1,
293
            },
389
            },
294
            {
390
            {
295
                body: {
391
                body: {
296
                    publication_title: "publication title",
392
                    publication_title: "publication title",
297
                    resources: [],
393
                    resources: [],
298
                    title_id: 1,
394
                    title_id: 1,
299
                }
395
                },
300
            }
396
            }
301
        ).as("get-title");
397
        ).as("get-title");
302
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
398
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
303
        let title_link = cy.get(
399
        let title_link = cy.get("#titles_list table tbody tr:first td:first a");
304
            "#titles_list table tbody tr:first td:first a"
305
        );
306
        title_link.should(
400
        title_link.should(
307
            "have.text",
401
            "have.text",
308
            erm_title.publication_title + " (#" + erm_title.title_id + ")"
402
            erm_title.publication_title + " (#" + erm_title.title_id + ")"
309
        );
403
        );
310
        cy.get(
404
        cy.get("#titles_list table tbody tr:first td:first a").click();
311
            "#titles_list table tbody tr:first td:first a"
312
        ).click();
313
        cy.wait("@get-title");
405
        cy.wait("@get-title");
314
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
406
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
315
        cy.get("#eholdings_title_show h2").contains(
407
        cy.get("#eholdings_title_show h2").contains(
Lines 336-346 describe("Title CRUD operations", () => { Link Here
336
        // cy.get("#package_list tbody tr:first td a").contains("first package name").click();
428
        // cy.get("#package_list tbody tr:first td a").contains("first package name").click();
337
        cy.intercept(
429
        cy.intercept(
338
            "GET",
430
            "GET",
339
            "/api/v1/erm/eholdings/local/resources/"+related_package.resource_id,
431
            "/api/v1/erm/eholdings/local/resources/" +
432
                related_package.resource_id,
340
            related_package
433
            related_package
341
        ).as("get-related-package");
434
        ).as("get-related-package");
342
        cy.get("table#package_list").contains("first package name").click();
435
        cy.get("table#package_list").contains("first package name").click();
343
        cy.contains("Resource #"+related_package.resource_id);
436
        cy.contains("Resource #" + related_package.resource_id);
344
        cy.contains(related_package.package.name);
437
        cy.contains(related_package.package.name);
345
    });
438
    });
346
439
Lines 357-372 describe("Title CRUD operations", () => { Link Here
357
                "X-Total-Count": "1",
450
                "X-Total-Count": "1",
358
            },
451
            },
359
        });
452
        });
360
        cy.intercept(
453
        cy.intercept("GET", "/api/v1/erm/eholdings/local/titles/*", erm_title);
361
            "GET",
362
            "/api/v1/erm/eholdings/local/titles/*",
363
            erm_title
364
        );
365
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
454
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
366
455
367
        cy.get("#titles_list table tbody tr:first")
456
        cy.get("#titles_list table tbody tr:first").contains("Delete").click();
368
            .contains("Delete")
369
            .click();
370
        cy.get(".dialog.alert.confirmation h1").contains("remove this title");
457
        cy.get(".dialog.alert.confirmation h1").contains("remove this title");
371
        cy.contains(erm_title.publication_title);
458
        cy.contains(erm_title.publication_title);
372
459
Lines 385-396 describe("Title CRUD operations", () => { Link Here
385
            statusCode: 204,
472
            statusCode: 204,
386
            body: null,
473
            body: null,
387
        });
474
        });
388
        cy.get("#titles_list table tbody tr:first")
475
        cy.get("#titles_list table tbody tr:first").contains("Delete").click();
389
            .contains("Delete")
390
            .click();
391
        cy.get(".dialog.alert.confirmation h1").contains("remove this title");
476
        cy.get(".dialog.alert.confirmation h1").contains("remove this title");
392
        cy.contains("Yes, delete").click();
477
        cy.contains("Yes, delete").click();
393
        cy.get("main div[class='dialog message']").contains("Local title").contains("deleted");
478
        cy.get("main div[class='dialog message']")
479
            .contains("Local title")
480
            .contains("deleted");
394
481
395
        // Delete from show
482
        // Delete from show
396
        // Click the "name" link from the list
483
        // Click the "name" link from the list
Lines 407-444 describe("Title CRUD operations", () => { Link Here
407
            {
494
            {
408
                method: "GET",
495
                method: "GET",
409
                url: "/api/v1/erm/eholdings/local/titles/*",
496
                url: "/api/v1/erm/eholdings/local/titles/*",
410
                times: 1
497
                times: 1,
411
            },
498
            },
412
            {
499
            {
413
                body: {
500
                body: {
414
                    publication_title: "publication title",
501
                    publication_title: "publication title",
415
                    resources: [],
502
                    resources: [],
416
                    title_id: 1,
503
                    title_id: 1,
417
                }
504
                },
418
            }
505
            }
419
        ).as("get-title");
506
        ).as("get-title");
420
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
507
        cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
421
        let title_link = cy.get(
508
        let title_link = cy.get("#titles_list table tbody tr:first td:first a");
422
            "#titles_list table tbody tr:first td:first a"
423
        );
424
        title_link.should(
509
        title_link.should(
425
            "have.text",
510
            "have.text",
426
            erm_title.publication_title + " (#" + erm_title.title_id + ")"
511
            erm_title.publication_title + " (#" + erm_title.title_id + ")"
427
        );
512
        );
428
        cy.get(
513
        cy.get("#titles_list table tbody tr:first td:first a").click();
429
            "#titles_list table tbody tr:first td:first a"
430
        ).click();
431
        cy.wait("@get-title");
514
        cy.wait("@get-title");
432
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
515
        cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
433
        cy.get("#eholdings_title_show h2").contains(
516
        cy.get("#eholdings_title_show h2").contains(
434
            "Title #" + erm_title.title_id
517
            "Title #" + erm_title.title_id
435
        );
518
        );
436
519
437
        cy.get('#eholdings_title_show .action_links .fa-trash').click();
520
        cy.get("#eholdings_title_show .action_links .fa-trash").click();
438
        cy.get(".dialog.alert.confirmation h1").contains("remove this title");
521
        cy.get(".dialog.alert.confirmation h1").contains("remove this title");
439
        cy.contains("Yes, delete").click();
522
        cy.contains("Yes, delete").click();
440
523
441
        //Make sure we return to list after deleting from show
524
        //Make sure we return to list after deleting from show
442
        cy.get("#titles_list table tbody tr:first")
525
        cy.get("#titles_list table tbody tr:first");
443
    });
526
    });
444
});
527
});
445
- 

Return to bug 33625