Bugzilla – Attachment 188837 Details for
Bug 39320
Create a 'landing page' for ERM
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39320: Add Cypress tests
ed582ef.patch (text/plain), 21.26 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-10-31 18:21:44 UTC
(
hide
)
Description:
Bug 39320: Add Cypress tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-10-31 18:21:44 UTC
Size:
21.26 KB
patch
obsolete
>From ed582eff9c7cabd87789e90c17c9d7d742640806 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Wed, 12 Mar 2025 14:11:49 -0100 >Subject: [PATCH] Bug 39320: Add Cypress tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plan: >1) Enable ERMModule >2) Visit ERM: ><staff_url>/cgi-bin/koha/erm/erm.pl >3) Notice you now have a 'dashboard' homepage showing 4 different widgets >4) Click 'Open Widget Picker'. Remove and add different widgets. Close >5) Drag and drop the widgets around the dashboard, from left to right, top to bottom >6) Click the context menu (vertical dots) on each of the widgets. Click 'move to right', 'move to left', 'remove'. >7) On the 'Licenses needing action', notice there is a 'Settings' item option. Click that, test different settings values. Close settings. >8) Using the widget picker or context menu for the respective widgets, remove all widgets except one. Click away i.e. 'Agreements' on the left menu. Go back to home by clicking 'Home'. Notice your dashboard is as you left it. >9) Enable all widgets, rearrange them by dragging and dropping in different places. Repeat the previous exercise. Notice the dashboard keeps the widgets arranged as you left them. >10) Add some test data, on k-t-d run: >bash <(curl -s https://gist.githubusercontent.com/ammopt/8d74feff048b0732ed0362a204c3d8cd/raw/a0347d4199d176dde58ea1d1437d2e903c101132/bug_39320_test_data.sh) >11) Refresh the homepage dashboard, check the 'Counts' are correct and links work, check that the 'Latest SUSHI Counter jobs' table now populates and links to the data provider as well as respective job. >12) For 'Licenses needing action', test different settings values and confirm the table filters the results as expected. >13) As before, click away and comeback to ERM home. Notice your 'Licenses needing actions' settings are kept as you left them. >14) For the 'eUsage report' widget, notice it says 'No saved reports are availble to run'. Create a new usage report at: ><staff_url>/cgi-bin/koha/erm/eusage/reports >15) Click the 'Create report' tab, input the mandatory fields and enter a report name at the bottom of the page. Click 'Save report'. >16) Come back to ERM home. Notice the 'eUsage report' widget now shows a dropdown with a disabled 'Run' button. >Pick the report you just created. Notice the 'Run' button is now enabled. Click 'Run'. Notice you get the report results screen (will show nothing as there is no usage data in this test exercise). >17) k-t-d: Run cypress tests (reset_all beforehand to clear test data): >cypress run --spec t/cypress/integration/ERM/ModuleDashboard_spec.ts > >Sponsored-by: UKHSA (UK Health Security Agency) > >Signed-off-by: Jeremy Evans <Jeremy.Evans@ukhsa.gov.uk> >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >--- > .../integration/ERM/ModuleDashboard_spec.ts | 360 ++++++++++++++++++ > 1 file changed, 360 insertions(+) > create mode 100644 t/cypress/integration/ERM/ModuleDashboard_spec.ts > >diff --git a/t/cypress/integration/ERM/ModuleDashboard_spec.ts b/t/cypress/integration/ERM/ModuleDashboard_spec.ts >new file mode 100644 >index 00000000000..4dd95de3b12 >--- /dev/null >+++ b/t/cypress/integration/ERM/ModuleDashboard_spec.ts >@@ -0,0 +1,360 @@ >+describe("ERM Module Dashboard", () => { >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ cy.intercept( >+ "GET", >+ "/api/v1/erm/config", >+ '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' >+ ); >+ }); >+ >+ it("Counts", () => { >+ cy.intercept("GET", "/api/v1/erm/counts", { >+ counts: { >+ agreements_count: 1, >+ documents_count: 0, >+ eholdings_packages_count: 0, >+ eholdings_titles_count: 0, >+ licenses_count: 5, >+ usage_data_providers_count: 1, >+ }, >+ }).as("getCounts"); >+ cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ >+ //Display >+ cy.get(".widget#ERMCounts .widget-content").should( >+ "contain", >+ "Loading..." >+ ); >+ cy.wait("@getCounts"); >+ cy.get(".widget#ERMCounts .widget-content").contains( >+ "There are 1 agreement, 5 licenses, 0 documents, 0 local packages, 0 local titles, 1 usage data provider." >+ ); >+ >+ //Move >+ cy.get( >+ ".dashboard-left-col .widget#ERMCounts .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".dashboard-left-col .widget#ERMCounts .widget-header .move-right" >+ ).click(); >+ cy.get(".dashboard-left-col .widget#ERMCounts").should("not.exist"); >+ cy.get(".dashboard-right-col .dragArea") >+ .children() >+ .first() >+ .should("have.id", "ERMCounts"); >+ >+ //Remove >+ cy.get( >+ ".dashboard-right-col .widget#ERMCounts .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".dashboard-right-col .widget#ERMCounts .widget-header .remove-widget" >+ ).click(); >+ cy.get(".dashboard-right-col .widget#ERMCounts").should("not.exist"); >+ >+ //Add >+ cy.get("#dashboard-header #open-widget-picker").click(); >+ cy.get(".modal #ERMCounts .add-widget").click(); >+ cy.get(".modal .modal-footer button").contains("Close").click(); >+ cy.get(".dashboard-left-col .dragArea") >+ .children() >+ .first() >+ .should("have.id", "ERMCounts"); >+ }); >+ >+ it("Run eUsage report", () => { >+ cy.intercept("GET", "/api/v1/erm/default_usage_reports", []).as( >+ "getReports" >+ ); >+ cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ >+ //Display >+ cy.get(".widget#ERMRunUsageReport .widget-content").should( >+ "contain", >+ "Loading..." >+ ); >+ cy.wait("@getReports"); >+ cy.get(".widget#ERMRunUsageReport .widget-content").should( >+ "contain", >+ "No saved eUsage reports are available to run." >+ ); >+ cy.get(".widget#ERMRunUsageReport .widget-content") >+ .find("a") >+ .should("have.attr", "href", "/cgi-bin/koha/erm/eusage/reports") >+ .contains("Create a report"); >+ >+ let reports = [ >+ { >+ erm_default_usage_report_id: 3, >+ report_name: "new", >+ report_url_params: >+ '{"url":"/api/v1/erm/eUsage/monthly_report/database?q=[{\\"erm_usage_muses.year\\":2020,\\"erm_usage_muses.report_type\\":\\"DR\\",\\"erm_usage_muses.month\\":[1,2,3,4,5,6,7,8,9,10,11,12],\\"erm_usage_muses.metric_type\\":[\\"Searches_Automated\\",\\"Searches_Federated\\",\\"Searches_Regular\\",\\"Total_Item_Investigations\\",\\"Total_Item_Requests\\",\\"Unique_Item_Investigations\\",\\"Unique_Item_Requests\\",\\"Unique_Title_Investigations\\",\\"Unique_Title_Requests\\",\\"Limit_Exceeded\\",\\"No_License\\"]},{\\"erm_usage_muses.year\\":2021,\\"erm_usage_muses.report_type\\":\\"DR\\",\\"erm_usage_muses.month\\":[1,2,3,4,5,6,7,8,9,10,11,12],\\"erm_usage_muses.metric_type\\":[\\"Searches_Automated\\",\\"Searches_Federated\\",\\"Searches_Regular\\",\\"Total_Item_Investigations\\",\\"Total_Item_Requests\\",\\"Unique_Item_Investigations\\",\\"Unique_Item_Requests\\",\\"Unique_Title_Investigations\\",\\"Unique_Title_Requests\\",\\"Limit_Exceeded\\",\\"No_License\\"]},{\\"erm_usage_muses.year\\":2022,\\"erm_usage_muses.report_type\\":\\"DR\\",\\"erm_usage_muses.month\\":[1,2,3,4,5,6,7,8,9,10,11,12],\\"erm_usage_muses.metric_type\\":[\\"Searches_Automated\\",\\"Searches_Federated\\",\\"Searches_Regular\\",\\"Total_Item_Investigations\\",\\"Total_Item_Requests\\",\\"Unique_Item_Investigations\\",\\"Unique_Item_Requests\\",\\"Unique_Title_Investigations\\",\\"Unique_Title_Requests\\",\\"Limit_Exceeded\\",\\"No_License\\"]},{\\"erm_usage_muses.year\\":2023,\\"erm_usage_muses.report_type\\":\\"DR\\",\\"erm_usage_muses.month\\":[1,2,3,4,5,6,7,8,9,10,11,12],\\"erm_usage_muses.metric_type\\":[\\"Searches_Automated\\",\\"Searches_Federated\\",\\"Searches_Regular\\",\\"Total_Item_Investigations\\",\\"Total_Item_Requests\\",\\"Unique_Item_Investigations\\",\\"Unique_Item_Requests\\",\\"Unique_Title_Investigations\\",\\"Unique_Title_Requests\\",\\"Limit_Exceeded\\",\\"No_License\\"]}]","columns":[1],"queryObject":{"data_display":"monthly","report_type":"DR","metric_types":["Searches_Automated","Searches_Federated","Searches_Regular","Total_Item_Investigations","Total_Item_Requests","Unique_Item_Investigations","Unique_Item_Requests","Unique_Title_Investigations","Unique_Title_Requests","Limit_Exceeded","No_License"],"access_types":null,"usage_data_providers":null,"keywords":null,"start_month":null,"start_year":"2020","end_month":null,"end_year":"2023"},"yearly_filter":true,"type":"monthly","tp_columns":{"2020":[{"short":"Jan","description":"January","value":1,"active":true},{"short":"Feb","description":"February","value":2,"active":true},{"short":"Mar","description":"March","value":3,"active":true},{"short":"Apr","description":"April","value":4,"active":true},{"short":"May","description":"May","value":5,"active":true},{"short":"Jun","description":"June","value":6,"active":true},{"short":"Jul","description":"July","value":7,"active":true},{"short":"Aug","description":"August","value":8,"active":true},{"short":"Sep","description":"September","value":9,"active":true},{"short":"Oct","description":"October","value":10,"active":true},{"short":"Nov","description":"November","value":11,"active":true},{"short":"Dec","description":"December","value":12,"active":true}],"2021":[{"short":"Jan","description":"January","value":1,"active":true},{"short":"Feb","description":"February","value":2,"active":true},{"short":"Mar","description":"March","value":3,"active":true},{"short":"Apr","description":"April","value":4,"active":true},{"short":"May","description":"May","value":5,"active":true},{"short":"Jun","description":"June","value":6,"active":true},{"short":"Jul","description":"July","value":7,"active":true},{"short":"Aug","description":"August","value":8,"active":true},{"short":"Sep","description":"September","value":9,"active":true},{"short":"Oct","description":"October","value":10,"active":true},{"short":"Nov","description":"November","value":11,"active":true},{"short":"Dec","description":"December","value":12,"active":true}],"2022":[{"short":"Jan","description":"January","value":1,"active":true},{"short":"Feb","description":"February","value":2,"active":true},{"short":"Mar","description":"March","value":3,"active":true},{"short":"Apr","description":"April","value":4,"active":true},{"short":"May","description":"May","value":5,"active":true},{"short":"Jun","description":"June","value":6,"active":true},{"short":"Jul","description":"July","value":7,"active":true},{"short":"Aug","description":"August","value":8,"active":true},{"short":"Sep","description":"September","value":9,"active":true},{"short":"Oct","description":"October","value":10,"active":true},{"short":"Nov","description":"November","value":11,"active":true},{"short":"Dec","description":"December","value":12,"active":true}],"2023":[{"short":"Jan","description":"January","value":1,"active":true},{"short":"Feb","description":"February","value":2,"active":true},{"short":"Mar","description":"March","value":3,"active":true},{"short":"Apr","description":"April","value":4,"active":true},{"short":"May","description":"May","value":5,"active":true},{"short":"Jun","description":"June","value":6,"active":true},{"short":"Jul","description":"July","value":7,"active":true},{"short":"Aug","description":"August","value":8,"active":true},{"short":"Sep","description":"September","value":9,"active":true},{"short":"Oct","description":"October","value":10,"active":true},{"short":"Nov","description":"November","value":11,"active":true},{"short":"Dec","description":"December","value":12,"active":true}]}}', >+ }, >+ ]; >+ >+ cy.intercept("GET", "/api/v1/erm/default_usage_reports", reports).as( >+ "getReports" >+ ); >+ cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ >+ cy.get(".widget#ERMRunUsageReport .widget-content") >+ .find(".v-select") >+ .should("exist"); >+ cy.get(".widget#ERMRunUsageReport .widget-content") >+ .find("button") >+ .contains("Run") >+ .should("be.disabled"); >+ cy.get(".widget#ERMRunUsageReport .widget-content .vs__search").type( >+ "new{enter}", >+ { force: true } >+ ); >+ cy.get( >+ ".widget#ERMRunUsageReport .widget-content .vs__selected" >+ ).contains("new"); >+ cy.get(".widget#ERMRunUsageReport .widget-content") >+ .find("button") >+ .contains("Run") >+ .should("not.be.disabled"); >+ cy.get( >+ ".widget#ERMRunUsageReport .widget-content button.btn-primary" >+ ).click(); >+ cy.url().should("match", /erm\/eusage\/reports\/viewer/); >+ >+ cy.intercept("GET", "/api/v1/erm/default_usage_reports", reports); >+ cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ >+ //Move >+ cy.get( >+ ".dashboard-left-col .widget#ERMRunUsageReport .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".dashboard-left-col .widget#ERMRunUsageReport .widget-header .move-right" >+ ).click(); >+ cy.get(".dashboard-left-col .widget#ERMRunUsageReport").should( >+ "not.exist" >+ ); >+ cy.get(".dashboard-right-col .dragArea") >+ .children() >+ .first() >+ .should("have.id", "ERMRunUsageReport"); >+ >+ //Remove >+ cy.get( >+ ".dashboard-right-col .widget#ERMRunUsageReport .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".dashboard-right-col .widget#ERMRunUsageReport .widget-header .remove-widget" >+ ).click(); >+ cy.get(".dashboard-right-col .widget#ERMRunUsageReport").should( >+ "not.exist" >+ ); >+ >+ //Add >+ cy.get("#dashboard-header #open-widget-picker").click(); >+ cy.get(".modal #ERMRunUsageReport .add-widget").click(); >+ cy.get(".modal .modal-footer button").contains("Close").click(); >+ cy.get(".dashboard-left-col .dragArea") >+ .children() >+ .first() >+ .should("have.id", "ERMRunUsageReport"); >+ }); >+ >+ it("Licenses needing action", () => { >+ cy.intercept("GET", "/api/v1/erm/licenses*", [cy.get_license()]).as( >+ "getLicenses" >+ ); >+ cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ >+ //Display >+ cy.get(".widget#ERMLicensesNeedingAction .widget-content").should( >+ "contain", >+ "Loading..." >+ ); >+ cy.wait("@getLicenses"); >+ cy.get( >+ ".widget#ERMLicensesNeedingAction .widget-content table tbody tr:first" >+ ).contains("license 1"); >+ >+ //Settings >+ cy.get(".widget#ERMLicensesNeedingAction .widget-settings").should( >+ "not.exist" >+ ); >+ cy.get( >+ ".widget#ERMLicensesNeedingAction .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".widget#ERMLicensesNeedingAction .widget-header .toggle-settings" >+ ).click(); >+ cy.get(".widget#ERMLicensesNeedingAction .widget-settings").should( >+ "exist" >+ ); >+ cy.get(".widget#ERMLicensesNeedingAction .widget-settings button") >+ .contains("Close settings") >+ .click(); >+ cy.get(".widget#ERMLicensesNeedingAction .widget-settings").should( >+ "not.exist" >+ ); >+ >+ //Move >+ cy.get( >+ ".dashboard-right-col .widget#ERMLicensesNeedingAction .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".dashboard-right-col .widget#ERMLicensesNeedingAction .widget-header .move-left" >+ ).click(); >+ cy.get(".dashboard-right-col .widget#ERMLicensesNeedingAction").should( >+ "not.exist" >+ ); >+ cy.get(".dashboard-left-col .dragArea") >+ .children() >+ .first() >+ .should("have.id", "ERMLicensesNeedingAction"); >+ >+ //Remove >+ cy.get( >+ ".dashboard-left-col .widget#ERMLicensesNeedingAction .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".dashboard-left-col .widget#ERMLicensesNeedingAction .widget-header .remove-widget" >+ ).click(); >+ cy.get(".dashboard-left-col .widget#ERMLicensesNeedingAction").should( >+ "not.exist" >+ ); >+ >+ //Add >+ cy.get("#dashboard-header #open-widget-picker").click(); >+ cy.get(".modal #ERMLicensesNeedingAction .add-widget").click(); >+ cy.get(".modal .modal-footer button").contains("Close").click(); >+ cy.get(".dashboard-right-col .dragArea") >+ .children() >+ .first() >+ .should("have.id", "ERMLicensesNeedingAction"); >+ }); >+ >+ it("Latest SUSHI Counter jobs", () => { >+ cy.intercept("GET", "/api/v1/jobs*", [ >+ { >+ context: { >+ branch: "CPL", >+ branchname: "Centerville", >+ cardnumber: "42", >+ desk_id: null, >+ desk_name: null, >+ emailaddress: null, >+ firstname: null, >+ flags: "1", >+ id: "koha", >+ interface: "api", >+ number: "51", >+ register_id: null, >+ register_name: null, >+ shibboleth: "0", >+ surname: "koha", >+ }, >+ data: { >+ begin_date: "2025-01-01", >+ end_date: "2025-03-12", >+ messages: [ >+ { >+ code: 2010, >+ message: >+ "Error - Requestor is Not Authorized to Access Usage for Institution", >+ type: "error", >+ }, >+ ], >+ report: { >+ report_type: "PR", >+ ud_provider_id: 1, >+ ud_provider_name: "Wiley Online Library", >+ us_report_info: { >+ added_mus: 0, >+ added_usage_objects: 0, >+ added_yus: 0, >+ skipped_mus: 0, >+ skipped_yus: 0, >+ }, >+ }, >+ report_type: "PR", >+ ud_provider_id: 1, >+ ud_provider_name: "Wiley Online Library", >+ }, >+ ended_date: "2025-03-11T16:56:07+00:00", >+ enqueued_date: "2025-03-11T16:56:06+00:00", >+ job_id: 1, >+ patron_id: "51", >+ progress: "0", >+ queue: "long_tasks", >+ size: "1", >+ started_date: "2025-03-11T16:56:06+00:00", >+ status: "finished", >+ type: "erm_sushi_harvester", >+ }, >+ ]).as("getJobs"); >+ cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ >+ //Display >+ cy.get(".widget#ERMLatestSUSHIJobs .widget-content").should( >+ "contain", >+ "Loading..." >+ ); >+ cy.wait("@getJobs"); >+ cy.get( >+ ".widget#ERMLatestSUSHIJobs .widget-content table tbody tr td:first" >+ ).contains("Finished"); >+ >+ cy.get( >+ ".widget#ERMLatestSUSHIJobs .widget-content table tbody tr td:nth-child(2)" >+ ) >+ .contains("Wiley Online Library") >+ .click(); >+ >+ cy.url().should("match", /erm\/eusage\/usage_data_providers/); >+ >+ cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ >+ cy.get( >+ ".widget#ERMLatestSUSHIJobs .widget-content table tbody tr td:nth-child(5)" >+ ) >+ .contains("View") >+ .click(); >+ >+ cy.url().should("match", /erm\/home/); >+ >+ //Move >+ cy.get( >+ ".dashboard-right-col .widget#ERMLatestSUSHIJobs .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".dashboard-right-col .widget#ERMLatestSUSHIJobs .widget-header .move-left" >+ ).click(); >+ cy.get(".dashboard-right-col .widget#ERMLatestSUSHIJobs").should( >+ "not.exist" >+ ); >+ cy.get(".dashboard-left-col .dragArea") >+ .children() >+ .first() >+ .should("have.id", "ERMLatestSUSHIJobs"); >+ >+ //Remove >+ cy.get( >+ ".dashboard-left-col .widget#ERMLatestSUSHIJobs .widget-header #dropdownMenuButton" >+ ).click(); >+ cy.get( >+ ".dashboard-left-col .widget#ERMLatestSUSHIJobs .widget-header .remove-widget" >+ ).click(); >+ cy.get(".dashboard-left-col .widget#ERMLatestSUSHIJobs").should( >+ "not.exist" >+ ); >+ >+ //Add >+ cy.get("#dashboard-header #open-widget-picker").click(); >+ cy.get(".modal #ERMLatestSUSHIJobs .add-widget").click(); >+ cy.get(".modal .modal-footer button").contains("Close").click(); >+ cy.get(".dashboard-right-col .dragArea") >+ .children() >+ .first() >+ .should("have.id", "ERMLatestSUSHIJobs"); >+ }); >+}); >-- >2.51.2
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 39320
:
187513
|
187514
|
187515
|
187516
|
187517
|
187518
|
187519
|
187520
|
187521
|
187522
|
187563
|
187568
|
187635
|
187636
|
187637
|
187638
|
187639
|
187640
|
187641
|
187642
|
187643
|
187644
|
187645
|
188094
|
188095
|
188096
|
188097
|
188098
|
188099
|
188100
|
188101
|
188102
|
188103
|
188104
|
188151
|
188279
|
188280
|
188281
|
188282
|
188283
|
188284
|
188285
|
188312
|
188315
|
188372
|
188375
|
188376
|
188637
|
188638
|
188639
|
188640
|
188641
|
188830
|
188831
|
188832
|
188833
|
188834
|
188835
|
188836
| 188837 |
188838
|
188839
|
188840
|
188841
|
188842
|
188843
|
188844
|
188845
|
188846
|
188847
|
188848
|
188849
|
188850
|
188851
|
188852
|
188853
|
188854
|
188855
|
188856
|
188857
|
188858
|
188859
|
188860
|
188861
|
188862
|
188863
|
188864