ohcnetwork / care_fe

Care is a Digital Public Good enabling TeleICU & Decentralised Administration of Healthcare Capacity across States.
https://care.ohc.network
MIT License
241 stars 425 forks source link

Add a new cypress test for shifting request #8914

Open nihal467 opened 1 week ago

nihal467 commented 1 week ago

Description

Add a new cypress test for new shifting requests for a patient

General Note

Follow the Page Object Model (POM) approach. : reference Refer to commands.ts in the Cypress folder to understand existing reusable components. Use proper function names for easier code review. Since there's nothing related to shifting requests is currently present, create a new file named ShiftingRequest.cy.ts under the shifting_spec folder.

Steps to Assign a Shifting Request

  1. Go to the patient tab
  2. click on any live patient card
  3. On the patient consultation page, click on manage patients
  4. from the dropdown, select shift patient
  5. submit the shifting form and verify the card is present in the shifting board

Make sure to verify the below things

Ensure the normal workflow is functional. Edit the request form and verify the modification are reflected properly

Ayush1404 commented 1 week ago

@nihal467 Can I work on this? Please assign it me.

Ayush1404 commented 1 week ago

Hey @nihal467,

I have started working on the issue, and I have written the test as below (I am attaching an image of the code I have written so far, which performs the following):

1: Creating a New Shift Request

  1. Visit the patients tab.
  2. Intercept the shift request API call.
  3. Select the patient named "Dummy Patient 16".
  4. Click the "Manage Patient" button.
  5. Select the "Shift Patient" option.
  6. Enter the contact person's name as "new".
  7. Enter the contact person's phone number as "9465666768".
  8. Enter the shift reason as "emmergency".
  9. Submit the shift request form.
  10. Wait for the shift request API call to complete and verify the status code is 201.

2:

Verifying Shift Request Creation

  1. Visit the shift board page.
  2. Verify that "Dummy Patient 16" exists on the board.

I have also attached a video of this test performing successfully.


I know this isn’t perfect, but it is a starting point. Without knowing exactly what you expect, I wouldn't know what to modify. Could you let me know if there are any improvements or changes you'd like me to make?

One thing to mention is that I have hardcoded "Dummy Patient 16". Should I replace that by creating a new patient dynamically for the test, or is it fine to reference an existing one? Your thoughts on this would help guide the next steps.

Image

https://github.com/user-attachments/assets/d53c6bb2-1427-41f7-b8de-1884c6606c7e

nihal467 commented 1 week ago

@Ayush1404

  1. verify and creating should be one single test
  2. Patient selection, manage patient, all have reusable function already use them,
  3. edit the existing request and verify the reflection in the details form
  4. input all the fields in the shifting form
Ayush1404 commented 1 week ago

Hey @nihal467 , i understand the corrections that you suggested , sorry for the inconvinience . Here are the screenshots of the modified test file and some functions that i have added . It seems pretty modular now , still let me know if anything can be improved

Image Image Image

i am confused about the third point that you added

  1. edit the existing request and verify the reflection in the details form Which edit option are you takling about here . Are you refering to the update option in the shifting request ? If so it can be accessed in 2 ways
    1. visit '/patiens' -> click on the patient card -> manage patient -> Track Shifting -> update
    2. visit '/shifting/board' -> scroll and click on the shift request card -> update

which way should i write test for ? Thank you for your quick attention !