Commit Graph

41 Commits

Author SHA1 Message Date
Matt Blenkinsop 35ce755ed8
Bug 38201: Cypress fixes
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-10-02 09:40:30 -06:00
Matt Blenkinsop 109804e163
Bug 38201: Add VueFramework cypress tests
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-10-02 09:40:16 -06:00
Matt Blenkinsop 3dbd768efd
Bug 38201: DRY out cypress object deletion
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-10-02 09:40:15 -06:00
Jonathan Druart 1516f227f9
Bug 40665: Fix Cypress tests
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2025-09-11 11:35:45 +02:00
David Cook 04c6afaff8
Bug 36135: Fix Cypress test
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-09-05 08:02:25 -06:00
David Cook 890d9069eb
Bug 15516: Fix Cypress test
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-09-05 08:02:15 -06:00
Tomas Cohen Arazi fbbeba87dc
Bug 40542: (40174 follow-up) Skip _strings for object creation
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-08-01 13:22:28 -06:00
Martin Renvoize d9122cd5ac
Bug 40447: Add comprehensive JSDoc documentation to Cypress plugins
This patch adds detailed JSDoc documentation to all Cypress testing
plugin files.

Documentation added to:
- insertData.js: Data insertion utilities with examples
- api-client.js: API wrapper functions with usage patterns
- mockData.js: Schema-based mock data generation
- auth.js: Authentication helper functions
- db.js: Database query utilities
- readYamlFile.js: YAML file reading utilities
- index.js: Main plugin configuration

Each function now includes:
- Complete parameter descriptions with types
- Return value documentation
- Practical usage examples
- Error conditions and handling
- Module-level overviews

This addresses the documentation gap identified during QA review,
hopefully making it easier for future devs to adopt the new framework of
tools.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:30 -06:00
Jonathan Druart 250580016d
Bug 40430: Fix Toolbar_spec.ts
See comment 1 on the bug.

We are adding the capability to insert vendors and baskets.

Test plan:
Confirm that
  yarn cypress run t/cypress/integration/Toolbar_spec.ts
pass, even if you do not have any vendors in DB.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:28 -06:00
Jonathan Druart 56fb5dc52f
Bug 40345: Properly cleanup old checkouts
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:27 -06:00
Jonathan Druart ed2c56ee6e
Bug 40345: Force checkout
Pass the confirmation token to force the checkout

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:26 -06:00
Jonathan Druart 959b7e8f05
Bug 40345: Add insertSamplePatron
So it's easier to build and insert a new patron

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:25 -06:00
Jonathan Druart 96bb7116b0
Bug 40345: Pass a patron to insertSampleCheckout
So we won't generate a new patron per checkout

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:25 -06:00
Jonathan Druart 19843bd9ba
Bug 40301: Add insertSampleCheckout
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:24 -06:00
Jonathan Druart 5e4032f0f1
Bug 40180: Improve deleteSampleObjects
We want the task to accept an Object or an Array of Objects

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:21 -06:00
Jonathan Druart e3ee3a0541
Bug 40180: Add tests for insertSampleHold
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:21 -06:00
Jonathan Druart af311b5395
Bug 40180: (bug 40118 follow-up) Add Cypress tests
This patch heavily reuses what has been introduced by the previous
patches in the tree, and add a insertSampleHold task to be reusable
easily in other tests.

Test plan:
All Cypress tests must pass

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:20 -06:00
Jonathan Druart 065f00ad67
Bug 40174: Do not generate bigint
Prevent "Out of range value for column 'deliverytime'" in a later
follow-up bug reports.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:20 -06:00
Jonathan Druart 7f8e4fd4b5
Bug 40174: Set minLength to 3
When we generate several objects we often get "Duplicate ID" from the
server. This mostly happens when the tests failed previously and the
objects have not been removed from the DB.

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:19 -06:00
Jonathan Druart da17bc0f91
Bug 40174: Deal with enum
Data too long for column 'checkprevcheckout'

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:18 -06:00
Jonathan Druart 9ca9d1e764
Bug 40174: Use api-client
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:18 -06:00
Jonathan Druart 52c57538c7
Bug 40174: Introduce Cypress auth plugin
So we can easily retrieve the value for the Authorization header.

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:17 -06:00
Jonathan Druart 892df0f0c0
Bug 40174: Allow proper E2E testing with Cypress
This is the first step toward implementing true end-to-end testing with
Cypress.

Until now, we have been mocking responses using cy.intercept(), but this
approach can lead to confusion. In some cases, we have even had to mock
global JavaScript variables, which makes the code unnecessarily complex
and unconventional (e.g. win.categories_map).

All the bug reports listed under this tree have helped lay the
groundwork for this patch. With it, we are able to build mock objects
(via plugin mockData) and insert them directly into the database
(insertData). Once the tests are complete, we’ll restore the database to
its previous state by removing any data generated during the tests.

The tests in KohaTable/Holdings_spec.ts have been updated to leverage
this new setup.

Additionally, a caching mechanism has been added to prevent _id
attributes from being generated with the same values (a rare issue we
occasionally encountered).

While this is still not a perfect solution, it introduces a solid
foundation for future improvements.

Test plan:
All Cypress tests must pass

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:17 -06:00
Jonathan Druart 892b0f4d53
Bug 40173: Add test for the api-client Cypress plugin
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-21 14:01:16 -06:00
Jonathan Druart 0aaf193a75
Bug 40169: mockData - Do not replace _id if passed
If we build an object and pass a primary key (ie. suffixed by _id) we
should not replace it.

Test plan:
The test highlights the problem, it won't affect existing tests.
0. Apply only the first patch (Cypress tests)
1. Run yarn cypress run t/cypress/integration/t/mockData.ts
=> It fails
2. Apply this patch
=> It passes

Signed-off-by: David Nind <david@davidnind.com>

Amended-by: Jonathan Druart
Remove .only

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-15 16:32:54 -06:00
Jonathan Druart 79060544a4
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>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-08 15:42:03 -06:00
Jonathan Druart cb384b2a1c
Bug 39315: MockData - generate full objects for libraries and item types
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-14 08:50:54 +02:00
Koha Development Team d659526b5a
Bug 38664: Tidy the whole codebase
This commit is generated using:
  % perl misc/devel/tidy.pl
*within* ktd, to get the same version of perltidy than what will be used
by our CI (currently v20230309).

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:24 +01:00
Jonathan Druart 55c3840588
Bug 38503: Do not generate too long strings
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-20 17:41:14 +01:00
Jonathan Druart a5eb0ba010
Bug 38503: Merge the module.exports
We redefine it and so the query/mysql plugin is not available

It fixes csrf.ts
14:36:17 koha_1       | The task &apos;query&apos; was not handled in the setupNodeEvents method. The following tasks are registered: buildSampleObject, buildSampleObjects

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-20 17:41:14 +01:00
Victor Grousset/tuxayo 4dbe67f6f2
Bug 38770: Remove @vue/cli-service and babel
And the webpack related dead config.

Test plan:
1. Do not apply
2. Switch to node 22
     sudo sed 's/18.x/22.x/g' -i /etc/apt/sources.list.d/nodesource.list
     sudo apt update ; sudo apt install nodejs
3. Try to install node deps
     sudo yarn install --modules-folder /kohadevbox/node_modules
4. It fails
     error @achrinza/node-ipc@9.2.5: The engine "node" is incompatible with this module.
     Expected version "8 || 9 || 10 || 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18". Got "22.12.0"
5. Apply patches
6. Try to install node deps
     sudo yarn install --modules-folder /kohadevbox/node_modules
7. It works! :)

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:56:15 +01:00
Jonathan Druart 9f5f4aa1d6
Bug 38503: Do not list the objects
No need to list all the objects, just retrieve the spec depending on the
"object" var we pass.

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:27:21 +01:00
Jonathan Druart ddd22c7887
Bug 38503: Generate correct values for date and date-time
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:27:20 +01:00
Jonathan Druart 3bc9bd8b62
Bug 38503: Deal with types that can be "null"
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:27:20 +01:00
Jonathan Druart 34f6663374
Bug 38503: Allow to pass values
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:27:19 +01:00
Jonathan Druart 3f880c5978
Bug 38503: Have a generic buildSampleObject[s]
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:27:19 +01:00
Jonathan Druart 7b3426928f
Bug 38503: Same for libraries
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:27:18 +01:00
Jonathan Druart bad59ca734
Bug 38503: Implement a plural form - buildSamplePatrons
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:27:18 +01:00
Jonathan Druart 3a3294966a
Bug 38503: Read patron swagger spec file and implement buildSamplePatron
Test plan:
1. Install deps
     sudo yarn install --modules-folder /kohadevbox/node_modules
2. Run tests
     cypress run --config video=false --spec t/cypress/integration/t/mockData.ts

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-16 15:27:17 +01:00
Jonathan Druart 06c62ab84a
Bug 36177: Cypress tests - cypress-mysql config
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-12 17:47:34 +01:00
Jonathan Druart 4f1f8bb4ea
Bug 32030: Move cypress to t/
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-08 09:44:51 -03:00