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).
Created attachment 174872 [details] [review] Bug 38503: Read patron swagger spec file and implement buildSamplePatron
Created attachment 174873 [details] [review] Bug 38503: Implement a plural form - buildSamplePatrons
Created attachment 174874 [details] [review] Bug 38503: Same for libraries
Created attachment 174875 [details] [review] Bug 38503: Have a generic buildSampleObject[s]
Created attachment 174876 [details] [review] Bug 38503: Allow to pass values
Created attachment 174884 [details] [review] Bug 38503: Deal with types that can be "null"
Created attachment 174885 [details] [review] Bug 38503: Generate correct values for date and date-time
Created attachment 174921 [details] [review] Bug 38503: [DO NOT PUSH] (follow-up) Generate correct values for date and date-time
Created attachment 174922 [details] [review] Bug 38503: [DO NOT PUSH] (follow-up) Upgrade @vue/cli-service for compat with node v22
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.
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?