[Bug 40173] New: Reuse http-client from Cypress tests
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Bug ID: 40173 Summary: Reuse http-client from Cypress tests Change sponsored?: --- Product: Koha Version: 24.11 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Test Suite Assignee: chris@bigballofwax.co.nz Reporter: jonathan.druart@gmail.com QA Contact: testopia@bugs.koha-community.org We will need to call REST API endpoints from Cypress tests, and more specifically from Cypress's tasks. It will be useful to reuse what has been done in http-client.js instead of using the low-level fetch JS function. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|24.11 |unspecified Status|NEW |ASSIGNED Assignee|chris@bigballofwax.co.nz |jonathan.druart@gmail.com Depends on| |40172 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40172 [Bug 40172] Remove jQuery from js/fetch/http-client.js -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Reuse http-client from |Reuse http-client from |Cypress tests |Cypress tests - preparation | |steps -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #1 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 183354 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183354&action=edit Bug 40173: Make http-client reusable from Cypress tests We will need to call REST API endpoints from Cypress tests, and more specifically from Cypress's tasks. It will be useful to reuse what has been done in http-client.js instead of using the low-level fetch JS function. 1. Add missing get and getAll functions 2. Allow overwrite of return_response and mark_submitting 3. Add a "default" client that will bring flexibility (can call any routes) 4. Add rspack config to generate t/cypress/plugins/dist/api-client.cjs.js that will make it reusable from Cypress's tasks -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #2 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 183355 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183355&action=edit Bug 40173: Return the response early if the caller needs it We returned the response too late: if something was wrong we processed the response already and thrown an error. This may introduce side-effects but it feels like a correct change. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #3 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 183356 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183356&action=edit Bug 40173: Add test for the api-client Cypress plugin -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #4 from Jonathan Druart <jonathan.druart@gmail.com> --- No proper test plan here, it affects the low-level http-client so it's hard to make sure it will not introduce bugs. Same test plan as bug 40172 would already be a good start. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au --- Comment #5 from David Cook <dcook@prosentient.com.au> --- (In reply to Jonathan Druart from comment #4)
No proper test plan here, it affects the low-level http-client so it's hard to make sure it will not introduce bugs.
I've been thinking about that for a little while now, and I think that we should start making Javascript unit tests. It likes "jest" is already included in "node_modules" for other dependencies. We might need to add "jest-fetch-mock" or "nock" but it would be a good way to test Javascript changes. I think it would encourage us to write Javascript in more re-usable ways as well. Anyway, food for thought. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #6 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to David Cook from comment #5)
(In reply to Jonathan Druart from comment #4)
No proper test plan here, it affects the low-level http-client so it's hard to make sure it will not introduce bugs.
I've been thinking about that for a little while now, and I think that we should start making Javascript unit tests. It likes "jest" is already included in "node_modules" for other dependencies. We might need to add "jest-fetch-mock" or "nock" but it would be a good way to test Javascript changes.
I think it would encourage us to write Javascript in more re-usable ways as well.
Anyway, food for thought.
I am actually adding test to http-client.js indirectly here, via t/cypress/integration/t/api-client.ts ;) The more we are going to use it in Cypress tests, the more it is going to be covered by tests. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |40174 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40174 [Bug 40174] Add a way to cleanly insert data in DB from Cypress tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #7 from David Cook <dcook@prosentient.com.au> --- (In reply to Jonathan Druart from comment #6)
I am actually adding test to http-client.js indirectly here, via t/cypress/integration/t/api-client.ts ;)
Indirectly being the key word there.
The more we are going to use it in Cypress tests, the more it is going to be covered by tests.
But not really. It's the difference between a unit test and an end to end test. Despite the word "integration" in "t/cypress/integration/t/api-client.ts", it's really an end to end test, and it's just covering the end effects. It's like saying we don't need Perl unit tests because we have the Cypress end to end tests. -- But that's fine. It's the status quo. I think that we could do better than we are currently, but it doesn't need to be right now. It's just an opportunity to try something better. But the current patches are still a good move forward. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #8 from David Cook <dcook@prosentient.com.au> --- And the end to end tests are super important. I'm not saying they're not. They definitely are. They're our last line of defence against bugs. But then the unit tests should be our first line of defence against bugs. That's all I'm saying. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #9 from Jonathan Druart <jonathan.druart@gmail.com> --- I think we are on the same page, note that I have not used the term "unit tests" ;) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Pedro Amorim <pedro.amorim@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Patch doesn't apply QA Contact|testopia@bugs.koha-communit |pedro.amorim@openfifth.co.u |y.org |k CC| |pedro.amorim@openfifth.co.u | |k --- Comment #10 from Pedro Amorim <pedro.amorim@openfifth.co.uk> --- Applying: Bug 40173: Add test for the api-client Cypress plugin Using index info to reconstruct a base tree... M t/cypress/plugins/index.js Falling back to patching base and 3-way merge... Auto-merging t/cypress/plugins/index.js CONFLICT (content): Merge conflict in t/cypress/plugins/index.js -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Patch doesn't apply |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #183356|0 |1 is obsolete| | --- Comment #11 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 183920 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183920&action=edit Bug 40173: Add test for the api-client Cypress plugin -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #12 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 183928 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183928&action=edit Bug 40173: Remove Cypress warnings Cypress Warning: Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise. -- You are receiving this mail because: You are watching all task changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #13 from Jonathan Druart <jonathan.druart@gmail.com> --- Please test and push this along with bug 40174. Tests from this patchset won't pass without the auth plugin added by bug 40174. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #183354|0 |1 is obsolete| | Attachment #183355|0 |1 is obsolete| | Attachment #183920|0 |1 is obsolete| | Attachment #183928|0 |1 is obsolete| | --- Comment #14 from Owen Leonard <oleonard@myacpl.org> --- Created attachment 183994 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183994&action=edit Bug 40173: Make http-client reusable from Cypress tests We will need to call REST API endpoints from Cypress tests, and more specifically from Cypress's tasks. It will be useful to reuse what has been done in http-client.js instead of using the low-level fetch JS function. 1. Add missing get and getAll functions 2. Allow overwrite of return_response and mark_submitting 3. Add a "default" client that will bring flexibility (can call any routes) 4. Add rspack config to generate t/cypress/plugins/dist/api-client.cjs.js that will make it reusable from Cypress's tasks Signed-off-by: Owen Leonard <oleonard@myacpl.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #15 from Owen Leonard <oleonard@myacpl.org> --- Created attachment 183995 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183995&action=edit Bug 40173: Return the response early if the caller needs it We returned the response too late: if something was wrong we processed the response already and thrown an error. This may introduce side-effects but it feels like a correct change. Signed-off-by: Owen Leonard <oleonard@myacpl.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #16 from Owen Leonard <oleonard@myacpl.org> --- Created attachment 183996 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183996&action=edit Bug 40173: Add test for the api-client Cypress plugin Signed-off-by: Owen Leonard <oleonard@myacpl.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #17 from Owen Leonard <oleonard@myacpl.org> --- Created attachment 183997 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183997&action=edit Bug 40173: Remove Cypress warnings Cypress Warning: Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise. Signed-off-by: Owen Leonard <oleonard@myacpl.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #183994|0 |1 is obsolete| | --- Comment #18 from Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> --- Created attachment 184098 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184098&action=edit Bug 40173: Make http-client reusable from Cypress tests We will need to call REST API endpoints from Cypress tests, and more specifically from Cypress's tasks. It will be useful to reuse what has been done in http-client.js instead of using the low-level fetch JS function. 1. Add missing get and getAll functions 2. Allow overwrite of return_response and mark_submitting 3. Add a "default" client that will bring flexibility (can call any routes) 4. Add rspack config to generate t/cypress/plugins/dist/api-client.cjs.js that will make it reusable from Cypress's tasks Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #183995|0 |1 is obsolete| | --- Comment #19 from Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> --- Created attachment 184099 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184099&action=edit Bug 40173: Return the response early if the caller needs it We returned the response too late: if something was wrong we processed the response already and thrown an error. This may introduce side-effects but it feels like a correct change. Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #183996|0 |1 is obsolete| | --- Comment #20 from Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> --- Created attachment 184100 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184100&action=edit 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #183997|0 |1 is obsolete| | --- Comment #21 from Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> --- Created attachment 184101 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184101&action=edit Bug 40173: Remove Cypress warnings Cypress Warning: Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise. Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |matt.blenkinsop@openfifth.c | |o.uk QA Contact|pedro.amorim@openfifth.co.u |matt.blenkinsop@openfifth.c |k |o.uk Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #184098|0 |1 is obsolete| | Attachment #184099|0 |1 is obsolete| | Attachment #184100|0 |1 is obsolete| | Attachment #184101|0 |1 is obsolete| | --- Comment #22 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 184323 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184323&action=edit Bug 40173: Make http-client reusable from Cypress tests We will need to call REST API endpoints from Cypress tests, and more specifically from Cypress's tasks. It will be useful to reuse what has been done in http-client.js instead of using the low-level fetch JS function. 1. Add missing get and getAll functions 2. Allow overwrite of return_response and mark_submitting 3. Add a "default" client that will bring flexibility (can call any routes) 4. Add rspack config to generate t/cypress/plugins/dist/api-client.cjs.js that will make it reusable from Cypress's tasks 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #23 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 184324 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184324&action=edit Bug 40173: Return the response early if the caller needs it We returned the response too late: if something was wrong we processed the response already and thrown an error. This may introduce side-effects but it feels like a correct change. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #24 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 184325 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184325&action=edit 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #25 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 184326 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184326&action=edit Bug 40173: Remove Cypress warnings Cypress Warning: Cypress detected that you returned a promise in a test, but also invoked one or more cy commands inside of that promise. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@openfifth.c | |o.uk --- Comment #26 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- I was testing the whole tree so adding my additional SO lines here too. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to main Version(s)| |25.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #27 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Nice work everyone! Pushed to main for 25.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |40493 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40493 [Bug 40493] t/cypress/plugins/dist/ must be git ignored -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to main |Pushed to stable Version(s)|25.11.00 |25.11.00,25.05.03 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 --- Comment #28 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Nice work everyone! Pushed to 25.05.x -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m Status|Pushed to stable |Needs documenting --- Comment #29 from Fridolin Somers <fridolin.somers@biblibre.com> --- Depends on Bug 40172 not in 24.11.x -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40173 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|Needs documenting |RESOLVED CC| |david@davidnind.com --- Comment #30 from David Nind <david@davidnind.com> --- Test suite related, no changes to the manual required. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org