From c5c6b0bf84730259c7030f054a347b0ab83e910a Mon Sep 17 00:00:00 2001
From: sidpg123
Date: Wed, 20 Nov 2024 14:16:26 +0530
Subject: [PATCH 1/7] Added a cypress test to assign a volunteer to a patient
---
.../e2e/patient_spec/PatientVolunteer.cy.ts | 50 +++++++++++++++++++
cypress/pageobject/Patient/PatientDetails.ts | 29 +++++++++++
src/components/Patient/PatientHome.tsx | 5 +-
3 files changed, 83 insertions(+), 1 deletion(-)
create mode 100644 cypress/e2e/patient_spec/PatientVolunteer.cy.ts
create mode 100644 cypress/pageobject/Patient/PatientDetails.ts
diff --git a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
new file mode 100644
index 00000000000..79cf51513bf
--- /dev/null
+++ b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
@@ -0,0 +1,50 @@
+import LoginPage from "../../pageobject/Login/LoginPage";
+import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation";
+import { PatientPage } from "../../pageobject/Patient/PatientCreation";
+import { PatientDetailsPage } from "../../pageobject/Patient/PatientDetails";
+
+describe("Assign a volunteer to a patient", () => {
+ const loginPage = new LoginPage();
+ const patientPage = new PatientPage();
+ const patientConsultationPage = new PatientConsultationPage();
+ const patientDetailsPage = new PatientDetailsPage();
+ const patient = "Dummy Patient 16";
+ const volunteerName = "dummy volunteer";
+ const anotherVolunteerName = "Abhi Patil";
+
+ before(() => {
+ cy.log("Logging in as district admin");
+ loginPage.loginAsDistrictAdmin();
+ cy.saveLocalStorage();
+ });
+
+ beforeEach(() => {
+ cy.restoreLocalStorage();
+ cy.clearLocalStorage(/filters--.+/);
+ });
+
+ it("assigns a volunteer to a patient and checks the banner that shows the volunteer's name", () => {
+ cy.visit("/patients");
+
+ patientPage.visitPatient(patient);
+ patientConsultationPage.clickPatientDetails();
+
+ patientDetailsPage.clickAssignToAVounteer();
+
+ patientDetailsPage.selectAndAssignVolunteer(volunteerName);
+
+ patientDetailsPage.verifyVolunteerBannerIsUpdated(volunteerName);
+
+ patientDetailsPage.clickAssignToAVounteer();
+
+ patientDetailsPage.selectAndAssignVolunteer(anotherVolunteerName);
+
+ patientDetailsPage.verifyVolunteerBannerIsUpdated(anotherVolunteerName);
+
+ patientDetailsPage.clickAssignToAVounteer();
+
+ patientDetailsPage.unassignVolunteer();
+
+ patientDetailsPage.verifyBannerIsRemovedAfterUnassign();
+ });
+});
diff --git a/cypress/pageobject/Patient/PatientDetails.ts b/cypress/pageobject/Patient/PatientDetails.ts
new file mode 100644
index 00000000000..aa1aa78b98f
--- /dev/null
+++ b/cypress/pageobject/Patient/PatientDetails.ts
@@ -0,0 +1,29 @@
+export class PatientDetailsPage {
+ clickAssignToAVounteer() {
+ cy.get('button:contains("Assign to a volunteer")').click({ force: true });
+ }
+
+ selectAndAssignVolunteer(volunteerName: string) {
+ cy.clickAndSelectOption("#assign_volunteer", volunteerName);
+ cy.clickSubmitButton("Assign");
+ cy.wait(2000);
+ }
+
+ verifyVolunteerBannerIsUpdated(volunteerName: string) {
+ cy.get("#assigned-volunteer")
+ .scrollIntoView()
+ .should("contain.text", `Assigned Volunteer:${volunteerName}`);
+ }
+
+ unassignVolunteer() {
+ cy.get("#clear-button").should("be.visible").find("svg").click();
+ // Close the dropdown
+ cy.get('button[id^="headlessui-combobox-button-"]').click(); // Click the dropdown close button
+
+ cy.clickSubmitButton("Assign");
+ }
+
+ verifyBannerIsRemovedAfterUnassign() {
+ cy.get("#assigned-volunteer").should("not.exist"); // Ensure the banner does not exist
+ }
+}
diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx
index a7b08bdea58..e8811ebcec7 100644
--- a/src/components/Patient/PatientHome.tsx
+++ b/src/components/Patient/PatientHome.tsx
@@ -285,7 +285,10 @@ export const PatientHome = (props: any) => {
)}
{patientData.assigned_to_object && (
-
+
Assigned Volunteer:
{formatName(patientData.assigned_to_object)}
From 5be77e1ca4443816631ee20465d2752aa27a9978 Mon Sep 17 00:00:00 2001
From: sidpg123
Date: Sat, 23 Nov 2024 21:14:53 +0530
Subject: [PATCH 2/7] Refactored volunteer assignment logic and improved test
cases
---
.../e2e/patient_spec/PatientVolunteer.cy.ts | 44 +++++++++----------
cypress/pageobject/Patient/PatientDetails.ts | 19 +++++---
2 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
index 79cf51513bf..841ebb42581 100644
--- a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
+++ b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
@@ -21,30 +21,30 @@ describe("Assign a volunteer to a patient", () => {
beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
- });
-
- it("assigns a volunteer to a patient and checks the banner that shows the volunteer's name", () => {
- cy.visit("/patients");
-
+ cy.visit("/patients").then(() => {
+ cy.log("Successfully navigated to patients page");
+ });
patientPage.visitPatient(patient);
patientConsultationPage.clickPatientDetails();
+ });
- patientDetailsPage.clickAssignToAVounteer();
-
- patientDetailsPage.selectAndAssignVolunteer(volunteerName);
-
- patientDetailsPage.verifyVolunteerBannerIsUpdated(volunteerName);
-
- patientDetailsPage.clickAssignToAVounteer();
-
- patientDetailsPage.selectAndAssignVolunteer(anotherVolunteerName);
-
- patientDetailsPage.verifyVolunteerBannerIsUpdated(anotherVolunteerName);
-
- patientDetailsPage.clickAssignToAVounteer();
-
- patientDetailsPage.unassignVolunteer();
-
- patientDetailsPage.verifyBannerIsRemovedAfterUnassign();
+ describe("volunteer assignment workflow", () => {
+ it("should assign a new volunteer successfully", () => {
+ patientDetailsPage.clickAssignToVolunteer();
+ patientDetailsPage.selectAndAssignVolunteer(volunteerName);
+ patientDetailsPage.verifyVolunteerBannerIsUpdated(volunteerName);
+ });
+
+ it("should replace existing volunteer successfully", () => {
+ patientDetailsPage.clickAssignToVolunteer();
+ patientDetailsPage.selectAndAssignVolunteer(anotherVolunteerName);
+ patientDetailsPage.verifyVolunteerBannerIsUpdated(anotherVolunteerName);
+ });
+
+ it("should unassign volunteer successfully", () => {
+ patientDetailsPage.clickAssignToVolunteer();
+ patientDetailsPage.unassignAndPrepareForReassignment();
+ patientDetailsPage.verifyBannerIsRemovedAfterUnassign();
+ });
});
});
diff --git a/cypress/pageobject/Patient/PatientDetails.ts b/cypress/pageobject/Patient/PatientDetails.ts
index aa1aa78b98f..a22674508db 100644
--- a/cypress/pageobject/Patient/PatientDetails.ts
+++ b/cypress/pageobject/Patient/PatientDetails.ts
@@ -1,12 +1,19 @@
export class PatientDetailsPage {
- clickAssignToAVounteer() {
- cy.get('button:contains("Assign to a volunteer")').click({ force: true });
+ clickAssignToVolunteer() {
+ cy.contains("button", "Assign to a volunteer")
+ .scrollIntoView()
+ .should("be.visible")
+ .should("be.enabled")
+ .click();
}
selectAndAssignVolunteer(volunteerName: string) {
cy.clickAndSelectOption("#assign_volunteer", volunteerName);
cy.clickSubmitButton("Assign");
- cy.wait(2000);
+ cy.get("#assigned-volunteer", { timeout: 10000 })
+ .scrollIntoView()
+ .should("be.visible")
+ .should("contain.text", volunteerName);
}
verifyVolunteerBannerIsUpdated(volunteerName: string) {
@@ -15,11 +22,9 @@ export class PatientDetailsPage {
.should("contain.text", `Assigned Volunteer:${volunteerName}`);
}
- unassignVolunteer() {
+ unassignAndPrepareForReassignment() {
cy.get("#clear-button").should("be.visible").find("svg").click();
- // Close the dropdown
- cy.get('button[id^="headlessui-combobox-button-"]').click(); // Click the dropdown close button
-
+ cy.get("#dropdown-toggle").click();
cy.clickSubmitButton("Assign");
}
From 96541986423a99f2785010e41016740b3cc918cd Mon Sep 17 00:00:00 2001
From: sidpg123
Date: Mon, 25 Nov 2024 00:10:45 +0530
Subject: [PATCH 3/7] added edge case for volunteer not found
---
.../e2e/patient_spec/PatientVolunteer.cy.ts | 19 ++++++++++++++++++-
cypress/pageobject/Patient/PatientDetails.ts | 17 +++++++++++------
.../Form/FormFields/Autocomplete.tsx | 5 ++++-
3 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
index 841ebb42581..322e35685b6 100644
--- a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
+++ b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
@@ -21,10 +21,19 @@ describe("Assign a volunteer to a patient", () => {
beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
+ cy.request("/patients").its("status").should("eq", 200);
+
cy.visit("/patients").then(() => {
cy.log("Successfully navigated to patients page");
});
- patientPage.visitPatient(patient);
+
+ // Add timeout and retry strategy for patient search
+ cy.wrap(null, { timeout: 10000 }).then(() => {
+ patientPage.visitPatient(patient);
+ });
+
+ // Verify patient details page is accessible
+ cy.get("#patient-details").should("exist");
patientConsultationPage.clickPatientDetails();
});
@@ -47,4 +56,12 @@ describe("Assign a volunteer to a patient", () => {
patientDetailsPage.verifyBannerIsRemovedAfterUnassign();
});
});
+
+ describe("error states and edge cases", () => {
+ it("should handle volunteer not found in dropdown", () => {
+ patientDetailsPage.clickAssignToVolunteer();
+ patientDetailsPage.searchVolunteer("Non-existent Volunteer");
+ cy.get('[data-testid="no-results"]').should("be.visible");
+ });
+ });
});
diff --git a/cypress/pageobject/Patient/PatientDetails.ts b/cypress/pageobject/Patient/PatientDetails.ts
index a22674508db..93b1dbd24b3 100644
--- a/cypress/pageobject/Patient/PatientDetails.ts
+++ b/cypress/pageobject/Patient/PatientDetails.ts
@@ -17,18 +17,23 @@ export class PatientDetailsPage {
}
verifyVolunteerBannerIsUpdated(volunteerName: string) {
- cy.get("#assigned-volunteer")
- .scrollIntoView()
- .should("contain.text", `Assigned Volunteer:${volunteerName}`);
+ cy.get("#assigned-volunteer").should(
+ "contain.text",
+ `Assigned Volunteer:${volunteerName}`,
+ );
}
unassignAndPrepareForReassignment() {
- cy.get("#clear-button").should("be.visible").find("svg").click();
- cy.get("#dropdown-toggle").click();
+ cy.get("#clear-button").should("be.visible").click();
+ cy.get("#dropdown-toggle").should("be.visible").click();
cy.clickSubmitButton("Assign");
}
verifyBannerIsRemovedAfterUnassign() {
- cy.get("#assigned-volunteer").should("not.exist"); // Ensure the banner does not exist
+ cy.get("#assigned-volunteer", { timeout: 10000 }).should("not.exist");
+ }
+
+ searchVolunteer(volunteerName: string) {
+ cy.get("#assign_volunteer").click().type(volunteerName);
}
}
diff --git a/src/components/Form/FormFields/Autocomplete.tsx b/src/components/Form/FormFields/Autocomplete.tsx
index df552883152..2d7147f6d79 100644
--- a/src/components/Form/FormFields/Autocomplete.tsx
+++ b/src/components/Form/FormFields/Autocomplete.tsx
@@ -249,7 +249,10 @@ export const Autocomplete = (props: AutocompleteProps) => {
{`Please enter at least ${props.minQueryLength} characters to search`}
) : filteredOptions.length === 0 ? (
-
+
No options found
) : (
From e99203b5eff2e01d8350bf1a33b3b43021ca7657 Mon Sep 17 00:00:00 2001
From: sidpg123
Date: Mon, 25 Nov 2024 00:42:18 +0530
Subject: [PATCH 4/7] improved searchVolunteer method
---
cypress/pageobject/Patient/PatientDetails.ts | 9 ++++++++-
src/components/Form/FormFields/Autocomplete.tsx | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/cypress/pageobject/Patient/PatientDetails.ts b/cypress/pageobject/Patient/PatientDetails.ts
index 93b1dbd24b3..f0b5ecca68b 100644
--- a/cypress/pageobject/Patient/PatientDetails.ts
+++ b/cypress/pageobject/Patient/PatientDetails.ts
@@ -34,6 +34,13 @@ export class PatientDetailsPage {
}
searchVolunteer(volunteerName: string) {
- cy.get("#assign_volunteer").click().type(volunteerName);
+ cy.get("#assign_volunteer")
+ .should("be.visible")
+ .click()
+ .type(volunteerName);
+
+ cy.get("[data-testid='volunteer-search-results']", {
+ timeout: 10000,
+ }).should("be.visible");
}
}
diff --git a/src/components/Form/FormFields/Autocomplete.tsx b/src/components/Form/FormFields/Autocomplete.tsx
index 2d7147f6d79..cf7e4837327 100644
--- a/src/components/Form/FormFields/Autocomplete.tsx
+++ b/src/components/Form/FormFields/Autocomplete.tsx
@@ -240,6 +240,7 @@ export const Autocomplete = (props: AutocompleteProps) => {
Date: Tue, 17 Dec 2024 11:55:57 +0530
Subject: [PATCH 5/7] updated tests according to changes in frontend & used
existing commands from command.ts
---
.../e2e/patient_spec/PatientVolunteer.cy.ts | 50 +++++++------------
cypress/pageobject/Patient/PatientDetails.ts | 39 +++++++++------
2 files changed, 44 insertions(+), 45 deletions(-)
diff --git a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
index 322e35685b6..168cc0838a2 100644
--- a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
+++ b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
@@ -3,7 +3,7 @@ import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsult
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import { PatientDetailsPage } from "../../pageobject/Patient/PatientDetails";
-describe("Assign a volunteer to a patient", () => {
+describe("Assign a volunteer to a patient - Multiple Tests", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientConsultationPage = new PatientConsultationPage();
@@ -13,8 +13,7 @@ describe("Assign a volunteer to a patient", () => {
const anotherVolunteerName = "Abhi Patil";
before(() => {
- cy.log("Logging in as district admin");
- loginPage.loginAsDistrictAdmin();
+ loginPage.loginByRole("districtAdmin");
cy.saveLocalStorage();
});
@@ -23,45 +22,34 @@ describe("Assign a volunteer to a patient", () => {
cy.clearLocalStorage(/filters--.+/);
cy.request("/patients").its("status").should("eq", 200);
- cy.visit("/patients").then(() => {
- cy.log("Successfully navigated to patients page");
- });
-
- // Add timeout and retry strategy for patient search
+ cy.visit("/patients");
cy.wrap(null, { timeout: 10000 }).then(() => {
patientPage.visitPatient(patient);
});
- // Verify patient details page is accessible
cy.get("#patient-details").should("exist");
patientConsultationPage.clickPatientDetails();
});
- describe("volunteer assignment workflow", () => {
- it("should assign a new volunteer successfully", () => {
- patientDetailsPage.clickAssignToVolunteer();
- patientDetailsPage.selectAndAssignVolunteer(volunteerName);
- patientDetailsPage.verifyVolunteerBannerIsUpdated(volunteerName);
- });
+ it("should assign a new volunteer successfully", () => {
+ patientDetailsPage.clickAssignOrReassignVolunteer();
+ patientDetailsPage.selectAndAssignVolunteer(volunteerName);
+ });
- it("should replace existing volunteer successfully", () => {
- patientDetailsPage.clickAssignToVolunteer();
- patientDetailsPage.selectAndAssignVolunteer(anotherVolunteerName);
- patientDetailsPage.verifyVolunteerBannerIsUpdated(anotherVolunteerName);
- });
+ it("should replace existing volunteer successfully", () => {
+ patientDetailsPage.clickAssignOrReassignVolunteer();
+ patientDetailsPage.selectAndAssignVolunteer(anotherVolunteerName);
+ });
- it("should unassign volunteer successfully", () => {
- patientDetailsPage.clickAssignToVolunteer();
- patientDetailsPage.unassignAndPrepareForReassignment();
- patientDetailsPage.verifyBannerIsRemovedAfterUnassign();
- });
+ it("should unassign volunteer successfully", () => {
+ patientDetailsPage.clickAssignOrReassignVolunteer();
+ patientDetailsPage.unassignAndPrepareForReassignment();
+ patientDetailsPage.verifyBannerIsRemovedAfterUnassign();
});
- describe("error states and edge cases", () => {
- it("should handle volunteer not found in dropdown", () => {
- patientDetailsPage.clickAssignToVolunteer();
- patientDetailsPage.searchVolunteer("Non-existent Volunteer");
- cy.get('[data-testid="no-results"]').should("be.visible");
- });
+ it("should handle volunteer not found in dropdown", () => {
+ patientDetailsPage.clickAssignOrReassignVolunteer();
+ patientDetailsPage.searchVolunteer("Non-existent Volunteer");
+ cy.get('[data-testid="no-results"]').should("be.visible");
});
});
diff --git a/cypress/pageobject/Patient/PatientDetails.ts b/cypress/pageobject/Patient/PatientDetails.ts
index 8b032ca9bf7..b17eb86de43 100644
--- a/cypress/pageobject/Patient/PatientDetails.ts
+++ b/cypress/pageobject/Patient/PatientDetails.ts
@@ -1,32 +1,43 @@
export class PatientDetailsPage {
clickAssignToVolunteer() {
- cy.contains("button", "Assign to a Volunteer")
+ cy.verifyAndClickElement("#assign-volunteer", "Assign to a Volunteer");
+ }
+
+ clickReassignToVolunteer() {
+ cy.verifyAndClickElement("#assign-volunteer", "Reassign Volunteer");
+ }
+
+ clickAssignOrReassignVolunteer() {
+ cy.get("#assign-volunteer")
.scrollIntoView()
.should("be.visible")
.should("be.enabled")
- .click();
+ .invoke("text")
+ .then((text) => {
+ if (text.includes("Assign to a Volunteer")) {
+ cy.verifyAndClickElement(
+ "#assign-volunteer",
+ "Assign to a Volunteer",
+ );
+ } else if (text.includes("Reassign Volunteer")) {
+ cy.verifyAndClickElement("#assign-volunteer", "Reassign Volunteer");
+ } else {
+ throw new Error("Expected button text not found.");
+ }
+ });
}
selectAndAssignVolunteer(volunteerName: string) {
cy.clickAndSelectOption("#assign_volunteer", volunteerName);
cy.clickSubmitButton("Assign");
- cy.get("#assigned-volunteer", { timeout: 10000 })
- .scrollIntoView()
- .should("be.visible")
- .should("contain.text", volunteerName);
- }
-
- verifyVolunteerBannerIsUpdated(volunteerName: string) {
- cy.get("#assigned-volunteer").should(
- "contain.text",
- `Assigned Volunteer:${volunteerName}`,
- );
+ cy.wait(1000);
+ cy.verifyContentPresence("#assigned-volunteer", [volunteerName]);
}
unassignAndPrepareForReassignment() {
cy.get("#clear-button").should("be.visible").click();
cy.get("#dropdown-toggle").should("be.visible").click();
- cy.clickSubmitButton("Assign");
+ cy.clickSubmitButton("Unassign");
}
verifyBannerIsRemovedAfterUnassign() {
From 045f375bc846dd49d9f0b07bd618e7111550da41 Mon Sep 17 00:00:00 2001
From: sidpg123
Date: Tue, 17 Dec 2024 14:48:57 +0530
Subject: [PATCH 6/7] made suggested changes
---
cypress/e2e/patient_spec/PatientVolunteer.cy.ts | 2 +-
cypress/pageobject/Patient/PatientDetails.ts | 16 ++++++----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
index 168cc0838a2..febb5730403 100644
--- a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
+++ b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
@@ -43,7 +43,7 @@ describe("Assign a volunteer to a patient - Multiple Tests", () => {
it("should unassign volunteer successfully", () => {
patientDetailsPage.clickAssignOrReassignVolunteer();
- patientDetailsPage.unassignAndPrepareForReassignment();
+ patientDetailsPage.unassignVolunteer();
patientDetailsPage.verifyBannerIsRemovedAfterUnassign();
});
diff --git a/cypress/pageobject/Patient/PatientDetails.ts b/cypress/pageobject/Patient/PatientDetails.ts
index b17eb86de43..841f2e50c55 100644
--- a/cypress/pageobject/Patient/PatientDetails.ts
+++ b/cypress/pageobject/Patient/PatientDetails.ts
@@ -9,20 +9,16 @@ export class PatientDetailsPage {
clickAssignOrReassignVolunteer() {
cy.get("#assign-volunteer")
- .scrollIntoView()
- .should("be.visible")
- .should("be.enabled")
.invoke("text")
.then((text) => {
if (text.includes("Assign to a Volunteer")) {
- cy.verifyAndClickElement(
- "#assign-volunteer",
- "Assign to a Volunteer",
- );
+ this.clickAssignToVolunteer();
} else if (text.includes("Reassign Volunteer")) {
- cy.verifyAndClickElement("#assign-volunteer", "Reassign Volunteer");
+ this.clickReassignToVolunteer();
} else {
- throw new Error("Expected button text not found.");
+ throw new Error(
+ `Button text must be either "Assign to a Volunteer" or "Reassign Volunteer", but found: "${text}"`,
+ );
}
});
}
@@ -34,7 +30,7 @@ export class PatientDetailsPage {
cy.verifyContentPresence("#assigned-volunteer", [volunteerName]);
}
- unassignAndPrepareForReassignment() {
+ unassignVolunteer() {
cy.get("#clear-button").should("be.visible").click();
cy.get("#dropdown-toggle").should("be.visible").click();
cy.clickSubmitButton("Unassign");
From b65f9522c117d456598dda03337548a6b69ef1fa Mon Sep 17 00:00:00 2001
From: sidpg123
Date: Tue, 17 Dec 2024 16:09:58 +0530
Subject: [PATCH 7/7] added a function for edge case - searching non existing
name
---
cypress/e2e/patient_spec/PatientVolunteer.cy.ts | 6 ++++--
cypress/pageobject/Patient/PatientDetails.ts | 17 ++++++++++-------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
index febb5730403..87a406bc251 100644
--- a/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
+++ b/cypress/e2e/patient_spec/PatientVolunteer.cy.ts
@@ -49,7 +49,9 @@ describe("Assign a volunteer to a patient - Multiple Tests", () => {
it("should handle volunteer not found in dropdown", () => {
patientDetailsPage.clickAssignOrReassignVolunteer();
- patientDetailsPage.searchVolunteer("Non-existent Volunteer");
- cy.get('[data-testid="no-results"]').should("be.visible");
+ patientDetailsPage.searchNonExistingVolunteer(
+ "Non-existent Volunteer",
+ false,
+ );
});
});
diff --git a/cypress/pageobject/Patient/PatientDetails.ts b/cypress/pageobject/Patient/PatientDetails.ts
index 841f2e50c55..9514870fbf8 100644
--- a/cypress/pageobject/Patient/PatientDetails.ts
+++ b/cypress/pageobject/Patient/PatientDetails.ts
@@ -9,6 +9,8 @@ export class PatientDetailsPage {
clickAssignOrReassignVolunteer() {
cy.get("#assign-volunteer")
+ .scrollIntoView()
+ .should("be.visible")
.invoke("text")
.then((text) => {
if (text.includes("Assign to a Volunteer")) {
@@ -41,13 +43,14 @@ export class PatientDetailsPage {
}
searchVolunteer(volunteerName: string) {
- cy.get("#assign_volunteer")
- .should("be.visible")
- .click()
- .type(volunteerName);
+ cy.typeAndSelectOption("#assign_volunteer", volunteerName);
+ }
- cy.get("[data-testid='volunteer-search-results']", {
- timeout: 10000,
- }).should("be.visible");
+ searchNonExistingVolunteer(
+ volunteerName: string,
+ clearBeforeTyping: boolean = false,
+ ) {
+ cy.typeIntoField("#assign_volunteer", volunteerName, { clearBeforeTyping });
+ cy.verifyContentPresence('[data-testid="no-results"]', []);
}
}