Bugzilla – Attachment 159243 Details for
Bug 35229
Fix and add further cypress tests for Usage reporting
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35229: Update cypress tests for usage reports
Bug-35229-Update-cypress-tests-for-usage-reports.patch (text/plain), 12.34 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-11-24 19:28:00 UTC
(
hide
)
Description:
Bug 35229: Update cypress tests for usage reports
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-11-24 19:28:00 UTC
Size:
12.34 KB
patch
obsolete
>From e56153c510d8eecdce8741137ff05d53a9df2058 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Fri, 27 Oct 2023 16:25:27 +0000 >Subject: [PATCH] Bug 35229: Update cypress tests for usage reports > >This patch adds some additional tests for usage reports to improve test coverage. >It also fixes a small error in the reports store - "platforms" v "platform". This was affecting which columns could be selected for platform reports > >Test plan: >yarn cypress run >All tests should pass > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../prog/js/vue/stores/usage-reports.js | 2 +- > .../integration/ERM/UsageReports_spec.ts | 164 +++++++++++++++--- > 2 files changed, 139 insertions(+), 27 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js >index 96df00f749f..ff3028ec5ff 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js >@@ -46,7 +46,7 @@ export const useReportsStore = defineStore("reports", { > id: 3, > name: "Platform", > active: false, >- used_by: ["item", "database", "platforms"], >+ used_by: ["item", "database", "platform"], > column: { > title: __("Platform"), > data: "platform", >diff --git a/t/cypress/integration/ERM/UsageReports_spec.ts b/t/cypress/integration/ERM/UsageReports_spec.ts >index 4b24dac4224..ddd5402299f 100644 >--- a/t/cypress/integration/ERM/UsageReports_spec.ts >+++ b/t/cypress/integration/ERM/UsageReports_spec.ts >@@ -6,13 +6,8 @@ describe("Reports home tabs", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > > const dataProvider = cy.get_usage_data_provider(); >@@ -63,13 +58,8 @@ describe("Saved reports", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > > const dataProvider = cy.get_usage_data_provider(); >@@ -132,13 +122,8 @@ describe("Custom reports", () => { > cy.title().should("eq", "Koha staff interface"); > cy.intercept( > "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", >- '{"value":"1"}' >- ); >- cy.intercept( >- "GET", >- "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", >- '{"value":"local"}' >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' > ); > > const dataProviders = cy.get_multiple_providers(); >@@ -210,23 +195,40 @@ describe("Custom reports", () => { > }); > > it("Should limit metric types based on the report type(s) selected", () => { >- cy.get("#metric_type .vs__search").should("be.disabled"); >+ cy.get("#metric_types .vs__search").should("be.disabled"); > > cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", { > force: true, > }); >- cy.get("#metric_type").find(".vs__actions").click(); >- cy.get("#metric_type").find("li").as("options"); >+ cy.get("#metric_types").find(".vs__actions").click(); >+ cy.get("#metric_types").find("li").as("options"); > cy.get("@options").should("have.length", 2); > > cy.get("#report_type .vs__search").type("PR" + "{enter}", { > force: true, > }); >- cy.get("#metric_type").find(".vs__actions").click(); >- cy.get("#metric_type").find("li").as("options"); >+ cy.get("#metric_types").find(".vs__actions").click(); >+ cy.get("#metric_types").find("li").as("options"); > cy.get("@options").should("have.length", 7); > }); > >+ it("Should allow access_type for certain report types", () => { >+ cy.get("#access_types .vs__search").should("be.disabled"); >+ >+ cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#access_types").find(".vs__actions").click(); >+ cy.get("#access_types .vs__search").should("be.disabled"); >+ >+ cy.get("#report_type .vs__search").type("TR_J3" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#access_types").find(".vs__actions").click(); >+ cy.get("#access_types").find("li").as("options"); >+ cy.get("@options").should("have.length", 2); >+ }); >+ > it("Should disable the month selectors when a yearly report is selected", () => { > cy.get("#interval .vs__search").type("By year" + "{enter}", { > force: true, >@@ -235,4 +237,114 @@ describe("Custom reports", () => { > cy.get("#start-month .vs__search").should("be.disabled"); > cy.get("#end_month .vs__search").should("be.disabled"); > }); >+ >+ it("Should correctly allow columns to be selected depending on the report type", () => { >+ // Only the Platform columns should be disabled for TR reports >+ cy.get("#report_type .vs__search").type("TR_J1" + "{enter}", { >+ force: true, >+ }); >+ cy.get(".checkbox_options input:disabled").should("have.length", 1); >+ >+ // Only the Provider name and Platform columns should be enabled for PR reports >+ cy.get("#report_type .vs__search").type("PR" + "{enter}", { >+ force: true, >+ }); >+ cy.get(".checkbox_options input:disabled").should("have.length", 6); >+ >+ // Only the Provider name, Publisher, Platform, Publisher ID columns should be enabled for DR reports >+ cy.get("#report_type .vs__search").type("DR" + "{enter}", { >+ force: true, >+ }); >+ cy.get(".checkbox_options input:disabled").should("have.length", 4); >+ >+ // Only the Provider name, Publisher, Platform columns should be enabled for DR reports >+ cy.get("#report_type .vs__search").type("IR" + "{enter}", { >+ force: true, >+ }); >+ cy.get(".checkbox_options input:disabled").should("have.length", 5); >+ }); >+ >+ it("Should correctly identify the months selected", () => { >+ cy.get("#start_year").type("2022"); >+ cy.get("#start-month .vs__search").type("June" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#end_year").type("2023"); >+ cy.get("#end_month .vs__search").type("April" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#yearly_filter_required_no").click(); >+ cy.get(".month_labels").should("have.length", 11); >+ cy.get("#yearly_filter_required_yes").click(); >+ cy.get(".month_labels").should("have.length", 0); >+ }); >+ >+ it("Should correctly produce URL parameters based on selected inputs", () => { >+ cy.get("#start_year").type("2022"); >+ cy.get("#start-month .vs__search").type("June" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#end_year").type("2023"); >+ cy.get("#end_month .vs__search").type("April" + "{enter}", { >+ force: true, >+ }); >+ >+ cy.get("#report_type .vs__search").type("PR" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#report_builder").contains("Submit").click(); >+ cy.url().should( >+ "include", >+ "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}]}}" >+ ); >+ }); >+ >+ it("Should show the Display by year filter when filter is required", () => { >+ cy.get("#start_year").type("2022"); >+ cy.get("#start-month .vs__search").type("June" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#end_year").type("2023"); >+ cy.get("#end_month .vs__search").type("April" + "{enter}", { >+ force: true, >+ }); >+ >+ cy.get("#report_type .vs__search").type("PR" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#report_builder").contains("Submit").click(); >+ cy.intercept("GET", "/api/v1/erm/eUsage/monthly_report/*").as( >+ "reportRequest" >+ ); >+ cy.wait("@reportRequest"); >+ >+ cy.get(".yearly_filter label").contains("Display by year"); >+ // There should be two years - 2022 and 2023 as per the inputs above >+ cy.get("#year_select").find(".vs__actions").click(); >+ cy.get("#year_select").find("li").as("options"); >+ cy.get("@options").should("have.length", 2); >+ >+ // Changing the year should re-trigger the AJAX request for that year >+ cy.intercept("GET", "/api/v1/erm/eUsage/monthly_report/*").as( >+ "filterRequest2022" >+ ); >+ cy.get("#year_select .vs__search").type("2022" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#filter_table").click(); >+ cy.wait("@filterRequest2022") >+ .its("request.query.q") >+ .should("include", "2022"); >+ >+ cy.intercept("GET", "/api/v1/erm/eUsage/monthly_report/*").as( >+ "filterRequest2023" >+ ); >+ cy.get("#year_select .vs__search").type("2023" + "{enter}", { >+ force: true, >+ }); >+ cy.get("#filter_table").click(); >+ cy.wait("@filterRequest2023") >+ .its("request.query.q") >+ .should("include", "2023"); >+ }); > }); >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35229
:
158250
|
158991
|
159003
|
159042
|
159043
| 159243 |
159244