-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a cypress test to assign a volunteer to a patient #9167
Closed
sidpg123
wants to merge
14
commits into
ohcnetwork:develop
from
sidpg123:issues/8913/test-to-assign-a-volunteer
Closed
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c5c6b0b
Added a cypress test to assign a volunteer to a patient
sidpg123 48cb8d9
Merge branch 'develop' into issues/8913/test-to-assign-a-volunteer
sidpg123 8ed99ed
Merge branch 'ohcnetwork:develop' into issues/8913/test-to-assign-a-v…
sidpg123 5be77e1
Refactored volunteer assignment logic and improved test cases
sidpg123 9654198
added edge case for volunteer not found
sidpg123 e99203b
improved searchVolunteer method
sidpg123 9cc5379
resolved merge conflicts
sidpg123 95d7dc6
Merge branch 'ohcnetwork:develop' into issues/8913/test-to-assign-a-v…
sidpg123 c0cc83a
Merge branch 'develop' into issues/8913/test-to-assign-a-volunteer
nihal467 60e3890
Merge branch 'ohcnetwork:develop' into issues/8913/test-to-assign-a-v…
sidpg123 3d30a92
Merge branch 'ohcnetwork:develop' into issues/8913/test-to-assign-a-v…
sidpg123 0dbf1e2
updated tests according to changes in frontend & used existing comman…
sidpg123 045f375
made suggested changes
sidpg123 b65f952
added a function for edge case - searching non existing name
sidpg123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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 - Multiple Tests", () => { | ||
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(() => { | ||
loginPage.loginByRole("districtAdmin"); | ||
cy.saveLocalStorage(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.restoreLocalStorage(); | ||
cy.clearLocalStorage(/filters--.+/); | ||
cy.request("/patients").its("status").should("eq", 200); | ||
|
||
cy.visit("/patients"); | ||
cy.wrap(null, { timeout: 10000 }).then(() => { | ||
patientPage.visitPatient(patient); | ||
}); | ||
|
||
cy.get("#patient-details").should("exist"); | ||
patientConsultationPage.clickPatientDetails(); | ||
}); | ||
|
||
it("should assign a new volunteer successfully", () => { | ||
patientDetailsPage.clickAssignOrReassignVolunteer(); | ||
patientDetailsPage.selectAndAssignVolunteer(volunteerName); | ||
}); | ||
|
||
it("should replace existing volunteer successfully", () => { | ||
patientDetailsPage.clickAssignOrReassignVolunteer(); | ||
patientDetailsPage.selectAndAssignVolunteer(anotherVolunteerName); | ||
}); | ||
|
||
it("should unassign volunteer successfully", () => { | ||
patientDetailsPage.clickAssignOrReassignVolunteer(); | ||
patientDetailsPage.unassignAndPrepareForReassignment(); | ||
patientDetailsPage.verifyBannerIsRemovedAfterUnassign(); | ||
}); | ||
|
||
it("should handle volunteer not found in dropdown", () => { | ||
patientDetailsPage.clickAssignOrReassignVolunteer(); | ||
patientDetailsPage.searchVolunteer("Non-existent Volunteer"); | ||
cy.get('[data-testid="no-results"]').should("be.visible"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
export class PatientDetailsPage { | ||
clickAssignToVolunteer() { | ||
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") | ||
.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.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("Unassign"); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix inconsistency between method name and implementation. The method name suggests preparation for reassignment, but it performs an unassignment:
- unassignAndPrepareForReassignment() {
+ unassignVolunteer() {
cy.get("#clear-button").should("be.visible").click();
cy.get("#dropdown-toggle").should("be.visible").click();
cy.clickSubmitButton("Unassign");
}
|
||
|
||
verifyBannerIsRemovedAfterUnassign() { | ||
cy.get("#assigned-volunteer", { timeout: 10000 }).should("not.exist"); | ||
} | ||
|
||
searchVolunteer(volunteerName: string) { | ||
cy.get("#assign_volunteer") | ||
.should("be.visible") | ||
.click() | ||
.type(volunteerName); | ||
|
||
cy.get("[data-testid='volunteer-search-results']", { | ||
timeout: 10000, | ||
}).should("be.visible"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Simplify implementation and remove redundant scroll.
The current implementation can be simplified by: