[Bug 36607] New: Use test builder in cypress tests
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Bug ID: 36607 Summary: Use test builder in cypress tests Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Test Suite Assignee: chris@bigballofwax.co.nz Reporter: matt.blenkinsop@ptfs-europe.com QA Contact: testopia@bugs.koha-community.org At hackfest it was discussed that it would be useful to be able to use the perl TestBuilder module in Cypress along with the new Cypress mysql. This bug is for a proof of concept to discuss -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|chris@bigballofwax.co.nz |matt.blenkinsop@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 --- Comment #1 from Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> --- Created attachment 164899 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164899&action=edit Bug 36607: Add cypress commands to build and delete objects This patch is a proof of concept for using test builder in cypress. The commands take in a Koha class and any data values and pass these to a perl script to run test builder To delete values we can either pass values to identify the data to delete or simply tell the command how many rows to delete from the end of the table -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 --- Comment #2 from Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> --- Created attachment 164900 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164900&action=edit Bug 36607: [DO NOT PUSH] Test for the commands cypress run --spec t/cypress/integration/DataTest_spec.ts -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164899|0 |1 is obsolete| | --- Comment #3 from Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> --- Created attachment 164901 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164901&action=edit Bug 36607: Add cypress commands to build and delete objects This patch is a proof of concept for using test builder in cypress. The commands take in a Koha class and any data values and pass these to a perl script to run test builder To delete values we can either pass values to identify the data to delete or simply tell the command how many rows to delete from the end of the table -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164900|0 |1 is obsolete| | --- Comment #4 from Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> --- Created attachment 164902 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164902&action=edit Bug 36607: [DO NOT PUSH] Test for the commands cypress run --spec t/cypress/integration/DataTest_spec.ts -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 --- Comment #5 from Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> --- The patch above allows us to use an object builder directly in the test - the alternative would be to just write a perl data generation script and call that directly at the start and end of each test to generate/tidy up data. Ideally the command could also return the newly created value but that is a future step as we can retrieve it with cypress mysql for now Let me know any concerns/feedback -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@gmail.com, | |koha@trust-box.at, | |martin.renvoize@ptfs-europe | |.com, | |nick@bywatersolutions.com, | |paul.derscheid@lmscloud.de, | |pedro.amorim@ptfs-europe.co | |m -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 --- Comment #6 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to Matt Blenkinsop from comment #5)
The patch above allows us to use an object builder directly in the test - the alternative would be to just write a perl data generation script and call that directly at the start and end of each test to generate/tidy up data.
Ideally the command could also return the newly created value but that is a future step as we can retrieve it with cypress mysql for now
Let me know any concerns/feedback
We need to cleanup behind us. So for instance if you create a patron you need to remove it AND what has been auto-generated: library + patron's category. So yes, we should retrieve the id of the resource we have created. The "delete the last X entries" approach is not robust enough IMO. See t/db_dependent/selenium/regressions.t: push @cleanup, $patron, $patron->category, $patron->library; -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 --- Comment #7 from Mark Hofstetter <koha@trust-box.at> --- Created attachment 166180 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=166180&action=edit added teardown -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |In Discussion --- Comment #8 from Mark Hofstetter <koha@trust-box.at> --- hi, I think Jonathan is right, ideally tests should be idempotent ie you have to clean up after testing. I added a "teardown" option in both t/cypress/support/e2e.js t/cypress/support/cypress_builder.pl additionally I think there was an error in t/lib/TestBuilder.pm because it used hashes and not objects when trying to delete objects to run yarn cypress run --config video=false,screenshotOnRunFailure=false --spec t/cypress/integration/DataTestSetupTeardown_spec.ts which creates a patron and then removes exactly this patron + the library/branch created implicitly. If this approach seems worthwhile it needs fleshing out for each object. the point of this approach is that you may not simply create an object randomly but you have to use a identifier, in the case of a patron the cardnumber. with this identifier you "keep state" during the test and in the end you issue a teardown command which not only deletes the explictly created object, but also all dependent object. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #166180|0 |1 is obsolete| | --- Comment #9 from Mark Hofstetter <koha@trust-box.at> --- Created attachment 166237 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=166237&action=edit Bug 36607: [discuss] setup and teardown patron please checkout/push to https://github.com/HKS3/koha-devel/tree/bug-36607 Current status: In Discussion -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://github.com/HKS3/koh | |a-devel/tree/bug-36607 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|In Discussion |RESOLVED Resolution|--- |DUPLICATE --- Comment #10 from Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> --- *** This bug has been marked as a duplicate of bug 38503 *** -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |victor@tuxayo.net --- Comment #11 from Victor Grousset/tuxayo <victor@tuxayo.net> ---
duplicate of bug 38503
Not really. Because 38503 is to build JSON objects to use when mocking the API. As opposed to TestBuilder that builds objects in the DB. That difference is what makes bug 38503 not that much of an help in testing stuff that doesn't use the API. It's perfect for Vue stuff. But for replacing Selenium tests, it doesn't work :( So back to in discussion? Unless I missed something. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=29285 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36607 --- Comment #12 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to Victor Grousset/tuxayo from comment #11)
duplicate of bug 38503
Not really. Because 38503 is to build JSON objects to use when mocking the API.
As opposed to TestBuilder that builds objects in the DB. That difference is what makes bug 38503 not that much of an help in testing stuff that doesn't use the API. It's perfect for Vue stuff. But for replacing Selenium tests, it doesn't work :(
So back to in discussion? Unless I missed something.
We should try our best to avoid it. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org