Skip to content

Commit

Permalink
added edge case for volunteer not found
Browse files Browse the repository at this point in the history
  • Loading branch information
sidpg123 committed Nov 24, 2024
1 parent 5be77e1 commit 9654198
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
19 changes: 18 additions & 1 deletion cypress/e2e/patient_spec/PatientVolunteer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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");
});
});
});
17 changes: 11 additions & 6 deletions cypress/pageobject/Patient/PatientDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
5 changes: 4 additions & 1 deletion src/components/Form/FormFields/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
{`Please enter at least ${props.minQueryLength} characters to search`}
</div>
) : filteredOptions.length === 0 ? (
<div className="p-2 text-sm text-secondary-500">
<div
data-testid="no-results"
className="p-2 text-sm text-secondary-500"
>
No options found
</div>
) : (
Expand Down

0 comments on commit 9654198

Please sign in to comment.