Implementing E2E tests for the Login and Registration workflows of RefApp 3.x

After going through a lot of trials and errors, I was able to complete writing E2E tests for the login, patient search and patient registration workflows. The goal of the task was to give users confidence that the Login, Search & Registration workflows of the RefApp 3.x are working as expected. This is a quick update on what I discovered while working on this task.

Here’s the updated feature file of the login flow. I was trying to make it much readable as possible.

Here’s a demo of the test.

This is the PR:

The next step was to implement the registration flow.

Here’s the feature file:

Here’s a demo:

This is the PR, which is still in WIP state. The login flow PR should be merged before this PR.

Also, I have implemented Github action for each workflow. The status would be reflected on the readme file as a badge.


What I discovered?

When I’m implementing the tests for the above workflows, I discovered the following issues:

  1. Issues in the registration page
    When clicking on the “Create Patient” button,
    If the user hasn’t selected a gender:
    The page neither shows any validation errors nor create a patient. It remains silent.
    If the details are correct:
    A popup message is displayed, and the patient is being created on the backend. But the page doesn’t redirect anywhere else. When the user tries to navigate to another page, it displays a confirmation message as follows:

The country has auto-filled with “Uganda” and needs to clear it every time if the patient’s country is different. However, it’s not a problem if the default country is configurable.

2. Different versions
The UI is not identical when running it using `npx openmrs develop` (within the `openmrs-esm-template-app` repo) and directly visiting the demo server.

The homepage of the deployed instance
The homepage of the local instance

3. Long page loading time
Sometimes it takes a long time to load pages. Also, it pretended to be loaded in some cases while loading components slowly. Therefore, I had to increase the maximum waiting time to 40 seconds in cypress to avoid getting the tests failed.
Tested on:
Browsers: Chrome and Safari
Devices: Macbook Pro M1 16GB, Macbook Pro 2015 8GB
Connection: ~10Mbps

Other issues/doubts

The following are some other issues or doubts I’m having,

  1. Creating an unidentified patient
    On ticket RATEST-150 , it instructs to create an Unidentified patient with only a gender. But the UI doesn’t allow to do it. I have raised this question on the ticket.
  2. Searching a patient
    It’s impossible to achieve the given instruction on searching a patient. Especially for searching for a non-existing user “Andria Faiza”. The next scenario creates a patient with the same name. Therefore, the test will fail when running it for the second time, because “Andria Faiza” now exists on the database.
    Since the server is deployed on the cloud and the state of the data in the server is unpredictable, searching for an existing user also might fail because anyone can edit the data on the test server.
  3. When to use scenarios and scenario outlines
    I have seen that we have used scenario outlines in most of the places. I’m not clear when to use scenarios and scenario outlines. It would be appreciated if someone could share an online resource to read some more.