Bug 40809

Summary: JS warning should make Cypress tests fail
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to main --- QA Contact: Matt Blenkinsop <matt.blenkinsop>
Severity: enhancement    
Priority: P5 - low CC: lucas, matt.blenkinsop
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Crowdfunding goal: 0
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:
Bug Depends on:    
Bug Blocks: 38201    
Attachments: Bug 40809: Fail Cypress tests on JS warnings
Bug 40809: Fail on DataTables 'warnings'
Bug 40809: Fail Cypress tests on JS warnings
Bug 40809: Fail on DataTables 'warnings'
Bug 40809: Display the whole error
Bug 40809: Display the whole error
Bug 40809: Also logs args in the console

Description Jonathan Druart 2025-09-15 12:22:57 UTC

    
Comment 1 Jonathan Druart 2025-09-15 12:25:42 UTC
Created attachment 186401 [details] [review]
Bug 40809: Fail Cypress tests on JS warnings

Currently JS warnings during Cypress tests are ignored.
This change intercepts console warnings in the browser and if any occurs
the test failed

This helps catch potential issues and ensures that warnings are not
silently ignored during test runs.
Comment 2 Jonathan Druart 2025-09-15 12:50:22 UTC
Test plan:
All Cypress tests should still pass.

QA will take care of adding a JS warning and confirm that the test fails.
Comment 3 Jonathan Druart 2025-09-26 05:03:19 UTC
Created attachment 186951 [details] [review]
Bug 40809: Fail on DataTables 'warnings'

They are not in the warn buffer but log
DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter 'status' for row 0, column 4. For more information about this error, please see https://datatables.net/tn/4
Comment 4 Matt Blenkinsop 2025-09-26 10:37:59 UTC
Created attachment 186966 [details] [review]
Bug 40809: Fail Cypress tests on JS warnings

Currently JS warnings during Cypress tests are ignored.
This change intercepts console warnings in the browser and if any occurs
the test failed

This helps catch potential issues and ensures that warnings are not
silently ignored during test runs.

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Comment 5 Matt Blenkinsop 2025-09-26 10:38:01 UTC
Created attachment 186967 [details] [review]
Bug 40809: Fail on DataTables 'warnings'

They are not in the warn buffer but log
DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter 'status' for row 0, column 4. For more information about this error, please see https://datatables.net/tn/4

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Comment 6 Jonathan Druart 2025-09-26 10:38:24 UTC
Created attachment 186968 [details] [review]
Bug 40809: Display the whole error

Not only the first line
Comment 7 Matt Blenkinsop 2025-09-26 10:45:23 UTC
Created attachment 186969 [details] [review]
Bug 40809: Display the whole error

Not only the first line

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Comment 8 Jonathan Druart 2025-09-26 14:58:31 UTC
Created attachment 186977 [details] [review]
Bug 40809: Also logs args in the console

For an unknown reason there are useful data that are displayed when
using console.log that we don't see when throwing the Error
This was the purpose of the previous patch (to have everything in
Error) but it didn't work. However we can keep it.
Comment 9 Lucas Gass (lukeg) 2025-09-26 16:34:04 UTC
I'm ignoring this QA failure:

Result:
[FAIL] t/cypress/support/e2e.js
   FAIL	  forbidden_patterns
		forbidden pattern: console.log (line 41)
		forbidden pattern: console.log (line 45)
Comment 10 Lucas Gass (lukeg) 2025-09-26 16:41:06 UTC
Nice work everyone!

Pushed to main for 25.11