When I’m fixing some failing E2E tests by this PR, I noticed a strange behaviour in the patient registration. I’ve attached some screen recordings. Before going into that, let me first explain how the registration test is designed. The test contains two scenarios:
Scenario 1: Fill the form with the correct values and expect the message “New Patient Created”
Scenario 2: Fill the form with some missing values and expect the message “Incomplete form”
If a scenario is failed it will retry two times until it gets passed. It was configured because sometimes tests fail as it takes more than 40 seconds to load the page. The following screen records are produced by cypress when running tests on GitHub actions.
If you go through the video, you can identify following the following. Please note that I couldn’t any of these issues when testing it manually. It happens only when running with cypress. The chances of failing are very high on CI and low when running cypress on my local setup.
The “Register Patient” Button is disabled from the beginning.
You can see the button is disabled most of the time. Cypress fills the form and waits to click on the button, but it fails after the 40-second timeout because the button isn’t in a clickable state.
Inputs are being cleared while filling out the form
You can see some inputs are being reset while filling out the form
Possible reasons for the above issues are as follows:
An issue with Cypress
I think it’s highly unlikely in the given situation because we can see it’s trying to perform what we have expected.
An issue with the UI
It might be an issue with the way we have implemented the patient registration.
Performance of the machine
Since we are using a Github-hosted runner to spin up the docker container and run tests it might affect the performance of the application. (Maybe the UI isn’t completely loaded while we performing actions even though it seems loaded?) However, it fails on my local setup sometimes as well (I have a 16GB M1).
I thought of sharing this because it might help us to stabilise E2E tests as well as to track down if there are any performance issues with the application. Please let me know your input.
It opens up a new question, why it is taking such a long time?
@jayasanka , actually the fetching of patient identifiers makes subsequent calls to the backend. The requests are chained and hence it takes some time to load and hence it takes that much time.
Regarding the ending visit modal issue, can you share a suitable time for a meet where we can have a look at it together, since this behaviour is not coming up on the UI flow.
I and @hadijah315 will be happy to help you out.
Thanks for the reply @vasharma05 ! It was an issue with the way we have written the test. It clicked on the “End Visit” menu item instead of the red colour button on the modal. Which resulting another element to the modals container. I fixed the test and it is working fine now.
We need to pay extra attention when using selectors to pick elements in tests.
It would be a lot easier if we have e2e tests within relevant repositories. So that we can add identifiers for elements if needed and purpose changes with the same PR.