Bug 40170 - Replace cypress-mysql with mysql2
Summary: Replace cypress-mysql with mysql2
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Pedro Amorim
URL:
Keywords:
Depends on: 40168
Blocks: 40174 40446
  Show dependency treegraph
 
Reported: 2025-06-18 20:25 UTC by Jonathan Druart
Modified: 2025-07-31 08:44 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.11.00,25.05.02
Circulation function:


Attachments
Bug 40170: Replace cypress-mysql with mysql2 - Cypress tests (17.73 KB, patch)
2025-06-18 20:43 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40170: Replace cypress-mysql with mysql2 - Cypress tests (17.76 KB, patch)
2025-06-18 22:37 UTC, David Nind
Details | Diff | Splinter Review
Bug 40170: Replace cypress-mysql with mysql2 - Cypress tests (17.84 KB, patch)
2025-07-08 14:52 UTC, Pedro Amorim
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2025-06-18 20:25:19 UTC

    
Comment 1 Jonathan Druart 2025-06-18 20:43:16 UTC
Created attachment 183352 [details] [review]
Bug 40170: Replace cypress-mysql with mysql2 - Cypress tests

This patch suggests to replace cypress-mysql with mysql2

cypress-mysql provides a custom Cypress command (cy.query) that run within the browser context.
This approach mixes test-side and server-side and is limited in flexibility and error handling.

mysql2 runs inside Cypress plugins (Node process) via cy.task calls, which are executed server-side (outside the browser)

This is needed for the follow-up bug reports where we need to request
the DB from other plugins

Test plan:
Run `yarn install` to install the mysql2
All the Cypress tests modified by this patch must still pass
The new test t/cypress/integration/t/db.ts must also pass
Comment 2 David Nind 2025-06-18 22:37:57 UTC
Created attachment 183359 [details] [review]
Bug 40170: Replace cypress-mysql with mysql2 - Cypress tests

This patch suggests to replace cypress-mysql with mysql2

cypress-mysql provides a custom Cypress command (cy.query) that run within the browser context.
This approach mixes test-side and server-side and is limited in flexibility and error handling.

mysql2 runs inside Cypress plugins (Node process) via cy.task calls, which are executed server-side (outside the browser)

This is needed for the follow-up bug reports where we need to request
the DB from other plugins

Test plan:
Run `yarn install` to install the mysql2
All the Cypress tests modified by this patch must still pass
The new test t/cypress/integration/t/db.ts must also pass

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2025-06-18 22:38:55 UTC
Testing notes (using KTD):
1. New or changed tests:
   yarn cypress run --spec t/cypress/integration/Auth/csrf.ts
   yarn cypress run --spec t/cypress/integration/Islands/AcquisitionsMenu_spec.ts
   yarn cypress run --spec t/cypress/integration/KohaTable/Holdings_spec.ts 
   yarn cypress run --spec t/cypress/integration/KohaTable/PatronSearch_spec.ts
   yarn cypress run --spec t/cypress/integration/t/db.ts
Comment 4 Pedro Amorim 2025-07-08 14:52:52 UTC
Created attachment 183867 [details] [review]
Bug 40170: Replace cypress-mysql with mysql2 - Cypress tests

This patch suggests to replace cypress-mysql with mysql2

cypress-mysql provides a custom Cypress command (cy.query) that run within the browser context.
This approach mixes test-side and server-side and is limited in flexibility and error handling.

mysql2 runs inside Cypress plugins (Node process) via cy.task calls, which are executed server-side (outside the browser)

This is needed for the follow-up bug reports where we need to request
the DB from other plugins

Test plan:
Run `yarn install` to install the mysql2
All the Cypress tests modified by this patch must still pass
The new test t/cypress/integration/t/db.ts must also pass

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
Comment 5 Lucas Gass (lukeg) 2025-07-08 21:44:55 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 6 Paul Derscheid 2025-07-10 20:50:46 UTC
Nice work everyone!

Pushed to 25.05.x
Comment 7 Fridolin Somers 2025-07-31 08:44:31 UTC
Enhancement not pushed to 24.11.x