Bug 38503 - Add a Cypress task to generate objects based on its swagger def spec
Summary: Add a Cypress task to generate objects based on its swagger def spec
Status: ASSIGNED
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: Testopia
URL:
Keywords:
Depends on:
Blocks: 38461
  Show dependency treegraph
 
Reported: 2024-11-21 12:55 UTC by Jonathan Druart
Modified: 2024-11-22 22:18 UTC (History)
7 users (show)

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


Attachments
Bug 38503: Read patron swagger spec file and implement buildSamplePatron (4.99 KB, patch)
2024-11-21 13:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38503: Implement a plural form - buildSamplePatrons (2.42 KB, patch)
2024-11-21 13:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38503: Same for libraries (2.79 KB, patch)
2024-11-21 13:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38503: Have a generic buildSampleObject[s] (5.32 KB, patch)
2024-11-21 13:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38503: Allow to pass values (2.54 KB, patch)
2024-11-21 13:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38503: Deal with types that can be "null" (1.30 KB, patch)
2024-11-21 14:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38503: Generate correct values for date and date-time (2.18 KB, patch)
2024-11-21 14:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38503: [DO NOT PUSH] (follow-up) Generate correct values for date and date-time (183.67 KB, patch)
2024-11-22 10:57 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 38503: [DO NOT PUSH] (follow-up) Upgrade @vue/cli-service for compat with node v22 (183.67 KB, patch)
2024-11-22 10:58 UTC, Paul Derscheid
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2024-11-21 12:55:48 UTC
We have TestBuilder for the Perl tests.

However for the Cypress tests we have to:
1. either mock all the routes (which is painful and time-consuming),
2. or rely on the existing data in DB (which will produce failures if data has been inserted, and tests will have to cleanup before/after, which is painful, time-consuming and not robust)

We should have a way to generate objects easily, in order to mock the response of a GET route easily.

We can actually rely on the swagger spec files (the definition file) to generate random data and mock the response of routes.

The first intended goal is to provide tests for the tables (bug 38461) and allow future enhancements in this area (see dependent bugs of bug 36640).
Comment 1 Jonathan Druart 2024-11-21 13:45:05 UTC
Created attachment 174872 [details] [review]
Bug 38503: Read patron swagger spec file and implement buildSamplePatron
Comment 2 Jonathan Druart 2024-11-21 13:45:08 UTC
Created attachment 174873 [details] [review]
Bug 38503: Implement a plural form - buildSamplePatrons
Comment 3 Jonathan Druart 2024-11-21 13:45:11 UTC
Created attachment 174874 [details] [review]
Bug 38503: Same for libraries
Comment 4 Jonathan Druart 2024-11-21 13:45:14 UTC
Created attachment 174875 [details] [review]
Bug 38503: Have a generic buildSampleObject[s]
Comment 5 Jonathan Druart 2024-11-21 13:45:16 UTC
Created attachment 174876 [details] [review]
Bug 38503: Allow to pass values
Comment 6 Jonathan Druart 2024-11-21 14:16:22 UTC
Created attachment 174884 [details] [review]
Bug 38503: Deal with types that can be "null"
Comment 7 Jonathan Druart 2024-11-21 14:16:25 UTC
Created attachment 174885 [details] [review]
Bug 38503: Generate correct values for date and date-time
Comment 8 Paul Derscheid 2024-11-22 10:57:06 UTC
Created attachment 174921 [details] [review]
Bug 38503: [DO NOT PUSH] (follow-up) Generate correct values for date and date-time
Comment 9 Paul Derscheid 2024-11-22 10:58:37 UTC
Created attachment 174922 [details] [review]
Bug 38503: [DO NOT PUSH] (follow-up) Upgrade @vue/cli-service for compat with node v22
Comment 10 Paul Derscheid 2024-11-22 11:11:37 UTC
Sorry, forgot to edit the commit message the first time.

So for compatibility with node v22, I just upgraded @vue/cli-service to its latest version.

To reproduce:
1) Make sure you are on node v22
2) Apply the patch interactively without the updated lockfile
3) Run `yarn install`
4) Observe error:
kohadev-koha@kohadevbox:koha(bug_38503)$ yarn install
yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
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.11.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
5) Apply the last patch as well
6) Observe success
kohadev-koha@kohadevbox:koha(bug_38503)$ yarn install
yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@redocly/cli > redoc > @cfaester/enzyme-adapter-react-18@0.8.0" has unmet peer dependency "enzyme@^3.11.0".
warning " > eslint-config-prettier@9.1.0" has unmet peer dependency "eslint@>=7.0.0".
warning " > eslint-plugin-prettier@5.1.3" has unmet peer dependency "eslint@>=8.0.0".
warning " > eslint-plugin-prettier@5.1.3" has unmet peer dependency "prettier@>=3.0.0".
warning "swagger-cli > @apidevtools/swagger-cli > @apidevtools/swagger-parser@10.1.0" has unmet peer dependency "openapi-types@>=7".
[4/4] Building fresh packages...
Done in 303.71s.
Comment 11 Victor Grousset/tuxayo 2024-11-22 21:39:27 UTC
Does this really depend on vue-cli?

- I upgraded node to v22
- applied all patches
- removed vue-cli and babel deps
- sudo yarn install --modules-folder /kohadevbox/node_modules

and t/cypress/integration/t/mockData.ts ran after doing the same removals as:
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=174858&action=diff

cypress output confirms it's using node 22

Is there anything else to test?