-
Notifications
You must be signed in to change notification settings - Fork 536
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
New cypress test for assigning a user to patient #10394
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request modifies the Cypress tests for patient management. In the patient creation tests, calls to Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Patient Creation Test
participant PE as PatientEncounter Page Object
participant cy as Cypress
Test->>PE: verifyEncounterPatientInfo(expectedInfo)
PE->>cy: cy.verifyContentPresence('#patient-infobadges', expectedInfo)
cy-->>PE: Return verification result
PE-->>Test: Return instance for chaining
sequenceDiagram
participant Test as Patient Assignment Test
participant PD as PatientDetails Page Object
Test->>PD: clickUsersTab()
Test->>PD: clickAssignUserButton()
Test->>PD: selectUserToAssign("nihal-nurse")
Test->>PD: selectUserRole("Nurse")
Test->>PD: confirmUserAssignment()
Test->>PD: verifyUserAssignmentSuccess()
Test->>PD: clickRemoveUserButton()
Test->>PD: confirmUserRemoval()
Test->>PD: verifyUserRemovalSuccess()
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🌐 Web search-backed reviews and chat
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Actionable comments posted: 0
🧹 Nitpick comments (6)
cypress/e2e/patient_spec/patient_details.cy.ts (2)
16-17
: Extract user details as test data constants.Move the hardcoded user details to constants at the top of the file or to a test data file for better maintainability.
+const TEST_USER = { + username: "nihal-nurse", + role: "Nurse", +}; + describe("Patient Management", () => { beforeEach(() => { cy.loginByApi("doctor"); cy.visit("/"); }); it("Assign users to a patient", () => { - const userName = "nihal-nurse"; - const userRole = "Nurse"; + const { username, role } = TEST_USER;
18-18
: Extract facility name as a test data constant.Move the hardcoded facility name to a constant at the top of the file or to a test data file for better maintainability.
+const TEST_FACILITY = "GHC Trikaripur"; + describe("Patient Management", () => { beforeEach(() => { cy.loginByApi("doctor"); cy.visit("/"); }); it("Assign users to a patient", () => { - facilityCreation.selectFacility("GHC Trikaripur"); + facilityCreation.selectFacility(TEST_FACILITY);cypress/pageObject/Patients/PatientDetails.ts (1)
39-42
: Use consistent click operation pattern.The
clickRemoveUserButton
method uses a different pattern for clicking compared to other methods. For consistency, use theverifyAndClickElement
custom command.clickRemoveUserButton() { - cy.get('[data-cy="patient-user-remove-button"]').first().click(); + cy.verifyAndClickElement( + '[data-cy="patient-user-remove-button"]', + "Remove User", + ); return this; }cypress/pageObject/Patients/PatientEncounter.ts (1)
25-28
: Use data-cy attribute for patient info badges selector.Replace the hardcoded ID selector with a data-cy attribute for consistency with other selectors in the codebase.
verifyEncounterPatientInfo(contents: string[]) { - cy.verifyContentPresence("#patient-infobadges", contents); + cy.verifyContentPresence('[data-cy="patient-info-badges"]', contents); return this; }cypress/e2e/patient_spec/patient_creation.cy.ts (2)
17-19
: Extract encounter constants to a test data file.Move the hardcoded encounter constants to a separate test data file for better maintainability and reusability across test files.
+// testData/encounterData.ts +export const ENCOUNTER_DATA = { + TYPE: "Observation", + STATUS: "In Progress", + PRIORITY: "ASAP", +}; + -const ENCOUNTER_TYPE = "Observation"; -const ENCOUNTER_STATUS = "In Progress"; -const ENCOUNTER_PRIORITY = "ASAP"; +const { TYPE: ENCOUNTER_TYPE, STATUS: ENCOUNTER_STATUS, PRIORITY: ENCOUNTER_PRIORITY } = ENCOUNTER_DATA;
184-188
: Use data-cy attribute for general info selector.Replace the hardcoded ID selector with a data-cy attribute for consistency with other selectors in the codebase.
- cy.verifyContentPresence("#general-info", [ + cy.verifyContentPresence('[data-cy="general-info"]', [ updatedPatientData.gender, updatedPatientData.address, ]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
cypress/e2e/patient_spec/patient_creation.cy.ts
(2 hunks)cypress/e2e/patient_spec/patient_details.cy.ts
(1 hunks)cypress/pageObject/Patients/PatientDashboard.ts
(0 hunks)cypress/pageObject/Patients/PatientDetails.ts
(1 hunks)cypress/pageObject/Patients/PatientEncounter.ts
(1 hunks)src/components/Patient/PatientDetailsTab/PatientUsers.tsx
(7 hunks)src/components/Patient/PatientHome.tsx
(1 hunks)
💤 Files with no reviewable changes (1)
- cypress/pageObject/Patients/PatientDashboard.ts
🧰 Additional context used
📓 Learnings (2)
cypress/e2e/patient_spec/patient_creation.cy.ts (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts:93-94
Timestamp: 2024-11-18T10:48:08.501Z
Learning: In `cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts`, bed capacity verification assertions after patient admission are already being performed elsewhere, so adding them here is unnecessary.
cypress/e2e/patient_spec/patient_details.cy.ts (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9145
File: cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts:93-94
Timestamp: 2024-11-18T10:48:08.501Z
Learning: In `cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts`, bed capacity verification assertions after patient admission are already being performed elsewhere, so adding them here is unnecessary.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/components/Patient/PatientHome.tsx (1)
112-112
: LGTM! Well-structured test selector.The dynamic data-cy attribute
tab-${tab.route}
provides a clear and unique identifier for each tab, making it easily targetable in Cypress tests.src/components/Patient/PatientDetailsTab/PatientUsers.tsx (2)
106-106
: LGTM! Well-structured test selectors for the user assignment flow.The data-cy attributes follow a clear naming convention and cover the complete user assignment workflow, making it easy to write and maintain Cypress tests.
Also applies to: 117-117, 170-170, 191-191, 315-315
268-272
: LGTM! Comprehensive test selectors for the user removal flow.The separate data-cy attributes for the remove button and confirm button provide clear distinction between the initial trigger and the confirmation action, which is essential for testing multi-step operations.
Also applies to: 288-288
CARE Run #4607
Run Properties:
|
Project |
CARE
|
Branch Review |
cypress-patientassign
|
Run status |
Passed #4607
|
Run duration | 06m 31s |
Commit |
482c64d7b9: New cypress test for assigning a user to patient
|
Committer | Mohammed Nihal |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
11
|
View all changes introduced in this branch ↗︎ |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit