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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js (-1 / +1 lines)
Lines 46-52 export const useReportsStore = defineStore("reports", { Link Here
46
                id: 3,
46
                id: 3,
47
                name: "Platform",
47
                name: "Platform",
48
                active: false,
48
                active: false,
49
                used_by: ["item", "database", "platforms"],
49
                used_by: ["item", "database", "platform"],
50
                column: {
50
                column: {
51
                    title: __("Platform"),
51
                    title: __("Platform"),
52
                    data: "platform",
52
                    data: "platform",
(-)a/t/cypress/integration/ERM/UsageReports_spec.ts (-27 / +138 lines)
Lines 6-18 describe("Reports home tabs", () => { Link Here
6
        cy.title().should("eq", "Koha staff interface");
6
        cy.title().should("eq", "Koha staff interface");
7
        cy.intercept(
7
        cy.intercept(
8
            "GET",
8
            "GET",
9
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
9
            "/api/v1/erm/config",
10
            '{"value":"1"}'
10
            '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
11
        );
12
        cy.intercept(
13
            "GET",
14
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
15
            '{"value":"local"}'
16
        );
11
        );
17
12
18
        const dataProvider = cy.get_usage_data_provider();
13
        const dataProvider = cy.get_usage_data_provider();
Lines 63-75 describe("Saved reports", () => { Link Here
63
        cy.title().should("eq", "Koha staff interface");
58
        cy.title().should("eq", "Koha staff interface");
64
        cy.intercept(
59
        cy.intercept(
65
            "GET",
60
            "GET",
66
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
61
            "/api/v1/erm/config",
67
            '{"value":"1"}'
62
            '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
68
        );
69
        cy.intercept(
70
            "GET",
71
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
72
            '{"value":"local"}'
73
        );
63
        );
74
64
75
        const dataProvider = cy.get_usage_data_provider();
65
        const dataProvider = cy.get_usage_data_provider();
Lines 132-144 describe("Custom reports", () => { Link Here
132
        cy.title().should("eq", "Koha staff interface");
122
        cy.title().should("eq", "Koha staff interface");
133
        cy.intercept(
123
        cy.intercept(
134
            "GET",
124
            "GET",
135
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
125
            "/api/v1/erm/config",
136
            '{"value":"1"}'
126
            '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
137
        );
138
        cy.intercept(
139
            "GET",
140
            "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
141
            '{"value":"local"}'
142
        );
127
        );
143
128
144
        const dataProviders = cy.get_multiple_providers();
129
        const dataProviders = cy.get_multiple_providers();
Lines 210-232 describe("Custom reports", () => { Link Here
210
    });
195
    });
211
196
212
    it("Should limit metric types based on the report type(s) selected", () => {
197
    it("Should limit metric types based on the report type(s) selected", () => {
213
        cy.get("#metric_type .vs__search").should("be.disabled");
198
        cy.get("#metric_types .vs__search").should("be.disabled");
214
199
215
        cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", {
200
        cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", {
216
            force: true,
201
            force: true,
217
        });
202
        });
218
        cy.get("#metric_type").find(".vs__actions").click();
203
        cy.get("#metric_types").find(".vs__actions").click();
219
        cy.get("#metric_type").find("li").as("options");
204
        cy.get("#metric_types").find("li").as("options");
220
        cy.get("@options").should("have.length", 2);
205
        cy.get("@options").should("have.length", 2);
221
206
222
        cy.get("#report_type .vs__search").type("PR" + "{enter}", {
207
        cy.get("#report_type .vs__search").type("PR" + "{enter}", {
223
            force: true,
208
            force: true,
224
        });
209
        });
225
        cy.get("#metric_type").find(".vs__actions").click();
210
        cy.get("#metric_types").find(".vs__actions").click();
226
        cy.get("#metric_type").find("li").as("options");
211
        cy.get("#metric_types").find("li").as("options");
227
        cy.get("@options").should("have.length", 7);
212
        cy.get("@options").should("have.length", 7);
228
    });
213
    });
229
214
215
    it("Should allow access_type for certain report types", () => {
216
        cy.get("#access_types .vs__search").should("be.disabled");
217
218
        cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", {
219
            force: true,
220
        });
221
        cy.get("#access_types").find(".vs__actions").click();
222
        cy.get("#access_types .vs__search").should("be.disabled");
223
224
        cy.get("#report_type .vs__search").type("TR_J3" + "{enter}", {
225
            force: true,
226
        });
227
        cy.get("#access_types").find(".vs__actions").click();
228
        cy.get("#access_types").find("li").as("options");
229
        cy.get("@options").should("have.length", 2);
230
    });
231
230
    it("Should disable the month selectors when a yearly report is selected", () => {
232
    it("Should disable the month selectors when a yearly report is selected", () => {
231
        cy.get("#interval .vs__search").type("By year" + "{enter}", {
233
        cy.get("#interval .vs__search").type("By year" + "{enter}", {
232
            force: true,
234
            force: true,
Lines 235-238 describe("Custom reports", () => { Link Here
235
        cy.get("#start-month .vs__search").should("be.disabled");
237
        cy.get("#start-month .vs__search").should("be.disabled");
236
        cy.get("#end_month .vs__search").should("be.disabled");
238
        cy.get("#end_month .vs__search").should("be.disabled");
237
    });
239
    });
240
241
    it("Should correctly allow columns to be selected depending on the report type", () => {
242
        // Only the Platform columns should be disabled for TR reports
243
        cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", {
244
            force: true,
245
        });
246
        cy.get(".checkbox_options input:disabled").should("have.length", 1);
247
248
        // Only the Provider name and Platform columns should be enabled for PR reports
249
        cy.get("#report_type .vs__search").type("PR" + "{enter}", {
250
            force: true,
251
        });
252
        cy.get(".checkbox_options input:disabled").should("have.length", 6);
253
254
        // Only the Provider name, Publisher, Platform, Publisher ID columns should be enabled for DR reports
255
        cy.get("#report_type .vs__search").type("DR" + "{enter}", {
256
            force: true,
257
        });
258
        cy.get(".checkbox_options input:disabled").should("have.length", 4);
259
260
        // Only the Provider name, Publisher, Platform columns should be enabled for DR reports
261
        cy.get("#report_type .vs__search").type("IR" + "{enter}", {
262
            force: true,
263
        });
264
        cy.get(".checkbox_options input:disabled").should("have.length", 5);
265
    });
266
267
    it("Should correctly identify the months selected", () => {
268
        cy.get("#start_year").type("2022");
269
        cy.get("#start-month .vs__search").type("June" + "{enter}", {
270
            force: true,
271
        });
272
        cy.get("#end_year").type("2023");
273
        cy.get("#end_month .vs__search").type("April" + "{enter}", {
274
            force: true,
275
        });
276
        cy.get("#yearly_filter_required_no").click();
277
        cy.get(".month_labels").should("have.length", 11);
278
        cy.get("#yearly_filter_required_yes").click();
279
        cy.get(".month_labels").should("have.length", 0);
280
    });
281
282
    it("Should correctly produce URL parameters based on selected inputs", () => {
283
        cy.get("#start_year").type("2022");
284
        cy.get("#start-month .vs__search").type("June" + "{enter}", {
285
            force: true,
286
        });
287
        cy.get("#end_year").type("2023");
288
        cy.get("#end_month .vs__search").type("April" + "{enter}", {
289
            force: true,
290
        });
291
292
        cy.get("#report_type .vs__search").type("PR" + "{enter}", {
293
            force: true,
294
        });
295
        cy.get("#report_builder").contains("Submit").click();
296
        cy.url().should(
297
            "include",
298
            "data={%22url%22:%22/api/v1/erm/eUsage/monthly_report/platform?q=[{%5C%22erm_usage_muses.year%5C%22:2022,%5C%22erm_usage_muses.report_type%5C%22:%5C%22PR%5C%22,%5C%22erm_usage_muses.month%5C%22:[6,7,8,9,10,11,12],%5C%22erm_usage_muses.metric_type%5C%22:[%5C%22Searches_Platform%5C%22,%5C%22Total_Item_Investigations%5C%22,%5C%22Total_Item_Requests%5C%22,%5C%22Unique_Item_Investigations%5C%22,%5C%22Unique_Item_Requests%5C%22,%5C%22Unique_Title_Investigations%5C%22,%5C%22Unique_Title_Requests%5C%22]},{%5C%22erm_usage_muses.year%5C%22:2023,%5C%22erm_usage_muses.report_type%5C%22:%5C%22PR%5C%22,%5C%22erm_usage_muses.month%5C%22:[1,2,3,4],%5C%22erm_usage_muses.metric_type%5C%22:[%5C%22Searches_Platform%5C%22,%5C%22Total_Item_Investigations%5C%22,%5C%22Total_Item_Requests%5C%22,%5C%22Unique_Item_Investigations%5C%22,%5C%22Unique_Item_Requests%5C%22,%5C%22Unique_Title_Investigations%5C%22,%5C%22Unique_Title_Requests%5C%22]}]%22,%22columns%22:[1],%22queryObject%22:{%22data_display%22:%22monthly%22,%22report_type%22:%22PR%22,%22metric_types%22:[%22Searches_Platform%22,%22Total_Item_Investigations%22,%22Total_Item_Requests%22,%22Unique_Item_Investigations%22,%22Unique_Item_Requests%22,%22Unique_Title_Investigations%22,%22Unique_Title_Requests%22],%22access_types%22:null,%22usage_data_providers%22:null,%22keywords%22:null,%22start_month%22:6,%22start_year%22:%222022%22,%22end_month%22:4,%22end_year%22:%222023%22},%22yearly_filter%22:true,%22type%22:%22monthly%22,%22tp_columns%22:{%222022%22:[{%22short%22:%22Jun%22,%22description%22:%22June%22,%22value%22:6,%22active%22:true},{%22short%22:%22Jul%22,%22description%22:%22July%22,%22value%22:7,%22active%22:true},{%22short%22:%22Aug%22,%22description%22:%22August%22,%22value%22:8,%22active%22:true},{%22short%22:%22Sep%22,%22description%22:%22September%22,%22value%22:9,%22active%22:true},{%22short%22:%22Oct%22,%22description%22:%22October%22,%22value%22:10,%22active%22:true},{%22short%22:%22Nov%22,%22description%22:%22November%22,%22value%22:11,%22active%22:true},{%22short%22:%22Dec%22,%22description%22:%22December%22,%22value%22:12,%22active%22:true}],%222023%22:[{%22short%22:%22Jan%22,%22description%22:%22January%22,%22value%22:1,%22active%22:true},{%22short%22:%22Feb%22,%22description%22:%22February%22,%22value%22:2,%22active%22:true},{%22short%22:%22Mar%22,%22description%22:%22March%22,%22value%22:3,%22active%22:true},{%22short%22:%22Apr%22,%22description%22:%22April%22,%22value%22:4,%22active%22:true}]}}"
299
        );
300
    });
301
302
    it("Should show the Display by year filter when filter is required", () => {
303
        cy.get("#start_year").type("2022");
304
        cy.get("#start-month .vs__search").type("June" + "{enter}", {
305
            force: true,
306
        });
307
        cy.get("#end_year").type("2023");
308
        cy.get("#end_month .vs__search").type("April" + "{enter}", {
309
            force: true,
310
        });
311
312
        cy.get("#report_type .vs__search").type("PR" + "{enter}", {
313
            force: true,
314
        });
315
        cy.get("#report_builder").contains("Submit").click();
316
        cy.intercept("GET", "/api/v1/erm/eUsage/monthly_report/*").as(
317
            "reportRequest"
318
        );
319
        cy.wait("@reportRequest");
320
321
        cy.get(".yearly_filter label").contains("Display by year");
322
        // There should be two years - 2022 and 2023 as per the inputs above
323
        cy.get("#year_select").find(".vs__actions").click();
324
        cy.get("#year_select").find("li").as("options");
325
        cy.get("@options").should("have.length", 2);
326
327
        // Changing the year should re-trigger the AJAX request for that year
328
        cy.intercept("GET", "/api/v1/erm/eUsage/monthly_report/*").as(
329
            "filterRequest2022"
330
        );
331
        cy.get("#year_select .vs__search").type("2022" + "{enter}", {
332
            force: true,
333
        });
334
        cy.get("#filter_table").click();
335
        cy.wait("@filterRequest2022")
336
            .its("request.query.q")
337
            .should("include", "2022");
338
339
        cy.intercept("GET", "/api/v1/erm/eUsage/monthly_report/*").as(
340
            "filterRequest2023"
341
        );
342
        cy.get("#year_select .vs__search").type("2023" + "{enter}", {
343
            force: true,
344
        });
345
        cy.get("#filter_table").click();
346
        cy.wait("@filterRequest2023")
347
            .its("request.query.q")
348
            .should("include", "2023");
349
    });
238
});
350
});
239
- 

Return to bug 35229