novu icon indicating copy to clipboard operation
novu copied to clipboard

fix(cypress): notifications editor flaky tests

Open p-fernandez opened this issue 2 years ago • 6 comments

  • What kind of change does this PR introduce? (Bug fix)

Some fixes for the tests in Cypress of Notifications editor. It seems to happen some race conditions where in the tests access to elements was tried before them fully load. Pattern quite repeatedly in less powerful dev environments.

  • Why was this change needed? (You can also link to an open issue here)

Improve the efficiency of the CI. Though at the cost of a bit of speed in test executions.

  • Other information: N/A

p-fernandez avatar Oct 11 '22 17:10 p-fernandez

gitpod-io[bot] avatar Oct 11 '22 17:10 gitpod-io[bot]

Ofcourse it failed 😅

scopsy avatar Oct 11 '22 17:10 scopsy

Ofcourse it failed 😅

The one I was suspecting. 🤦🏻 If someone knows a bit more that feature and could explain me what it does I think I could guess what's the potential race condition. With the other tests it was less hard to notice it.

p-fernandez avatar Oct 11 '22 17:10 p-fernandez

@p-fernandez when creating a notification template, you promote the changes of this template to production. Then switch to the production environment and click on the template edit button.

Once you are in the template editor screen on the Production environment, switch the environment flag to be Development This should automatically redirect the user to the Development template and basically have a different URL. This is what the test is testing.

scopsy avatar Oct 11 '22 17:10 scopsy

I think I identified where the flakiness comes from. The environment selector has a behaviour that before being available has an overlay on top and the size of the input radios (the element that renders every environment) has a size of 0x0 so Cypress can't pick them up to run a click there. I couldn't debug it very deep but it also looks like the environment selector re-renders multiple times when loading and has some API calls associated that might make it unavailable for Cypress tests. I need more investigation, but it is the line I think I will follow. Hope it is not a red herring.

p-fernandez avatar Oct 13 '22 07:10 p-fernandez

@p-fernandez might be it. Is it possible to wait until the element is visible and the overlay is not visible? Maybe with a combination of waitForIdle or something similar. Let me know if you will need help to go over it together in sync 🚀

scopsy avatar Oct 13 '22 07:10 scopsy

@scopsy I gave many runs in a row and seems only to fail when uploading artifacts. Tests seem quite stable (hope I am not jinxing it).

p-fernandez avatar Nov 10 '22 08:11 p-fernandez