-
Notifications
You must be signed in to change notification settings - Fork 442
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
base: develop
Are you sure you want to change the base?
Added a cypress test to assign a volunteer to a patient #9167
Conversation
WalkthroughThis pull request introduces a new Cypress end-to-end test suite in Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint (1.23.1)
cypress/e2e/patient_spec/PatientVolunteer.cy.tsOops! Something went wrong! :( ESLint: 8.57.1 Error: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc.json': Cannot find module '@typescript-eslint/parser'
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: 4
🧹 Outside diff range and nitpick comments (6)
cypress/pageobject/Patient/PatientDetails.ts (3)
12-16
: Improve text verification robustness and i18n supportThe current text verification might be too rigid and doesn't account for i18n requirements mentioned in the PR objectives.
verifyVolunteerBannerIsUpdated(volunteerName: string) { cy.get("#assigned-volunteer") - .scrollIntoView() .should("contain.text", `Assigned Volunteer:${volunteerName}`); + .invoke('text') + .should('match', new RegExp(`.*${volunteerName}.*`)); + + // Verify i18n key is used + cy.get("#assigned-volunteer") + .should('have.attr', 'data-i18n-key', 'patient.assigned_volunteer'); }
26-28
: Enhance verification robustnessThe verification could be more comprehensive by ensuring the transition is complete.
verifyBannerIsRemovedAfterUnassign() { - cy.get("#assigned-volunteer").should("not.exist"); // Ensure the banner does not exist + // Ensure the banner is removed and the assign button is available again + cy.get("#assigned-volunteer").should("not.exist"); + cy.contains('button', 'Assign to a volunteer').should('be.visible'); }
1-29
: Consider adding error case handlingThe current implementation focuses on the happy path. Consider adding methods to handle and verify error scenarios such as:
- Network failures during assignment
- Invalid volunteer selection
- Concurrent modifications
- Permission-related errors
This would make the test suite more robust and comprehensive.
Would you like me to provide example implementations for these scenarios?
cypress/e2e/patient_spec/PatientVolunteer.cy.ts (3)
1-4
: Maintain consistent import style across page objectsConsider using consistent import syntax for better maintainability. Currently mixing default export (
LoginPage
) with named exports (other page objects).-import LoginPage from "../../pageobject/Login/LoginPage"; +import { LoginPage } from "../../pageobject/Login/LoginPage";
6-14
: Consider moving test data to fixturesFor better maintainability and reusability, consider moving the test data constants (
patient
,volunteerName
,anotherVolunteerName
) to a Cypress fixture file.Example structure:
// cypress/fixtures/volunteers.json { "patient": "Dummy Patient 16", "volunteers": { "primary": "dummy volunteer", "secondary": "Abhi Patil" } }
15-24
: Enhance test hooks with better error handling and loggingThe hooks handle the basic setup well, but consider these improvements:
- Add error handling for login failure
- Add more descriptive logging for better test debugging
before(() => { - cy.log("Logging in as district admin"); + cy.log("Setting up test: Logging in as district admin"); loginPage.loginAsDistrictAdmin() + .then(() => { + cy.log("Login successful"); + }) + .catch((error) => { + cy.log("Login failed:", error); + throw error; + }); cy.saveLocalStorage(); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
cypress/e2e/patient_spec/PatientVolunteer.cy.ts
(1 hunks)cypress/pageobject/Patient/PatientDetails.ts
(1 hunks)src/components/Patient/PatientHome.tsx
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/components/Patient/PatientHome.tsx
🔇 Additional comments (1)
cypress/e2e/patient_spec/PatientVolunteer.cy.ts (1)
1-50
: Implementation meets requirements but verify edge cases
The test implementation successfully covers all required scenarios and follows the POM pattern. Please verify:
- Test behavior with network delays/failures
- Error messages when volunteer assignment fails
- Edge cases like attempting to assign an inactive volunteer
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"); | ||
} |
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
Improve method clarity and selector robustness
- The method name doesn't reflect that it also performs a reassignment
- The headlessui selector is brittle and might break with library updates
- unassignVolunteer() {
+ unassignAndPrepareForReassignment() {
cy.get("#clear-button")
.should("be.visible")
.find("svg")
.click();
- // Close the dropdown
- cy.get('button[id^="headlessui-combobox-button-"]').click();
+ // Use a more reliable selector for the dropdown
+ cy.get('[data-testid="volunteer-dropdown"]').click();
cy.clickSubmitButton("Assign");
}
Committable suggestion skipped: line range outside the PR's diff.
selectAndAssignVolunteer(volunteerName: string) { | ||
cy.clickAndSelectOption("#assign_volunteer", volunteerName); | ||
cy.clickSubmitButton("Assign"); | ||
cy.wait(2000); | ||
} |
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
Replace hardcoded wait with explicit conditions
The hardcoded cy.wait(2000)
is an anti-pattern that could make tests flaky. Instead, wait for specific conditions that indicate the assignment is complete.
selectAndAssignVolunteer(volunteerName: string) {
cy.clickAndSelectOption("#assign_volunteer", volunteerName);
cy.clickSubmitButton("Assign");
- cy.wait(2000);
+ // Wait for the assignment to complete
+ cy.get('#assigned-volunteer', { timeout: 10000 })
+ .should('be.visible')
+ .should('contain.text', volunteerName);
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
selectAndAssignVolunteer(volunteerName: string) { | |
cy.clickAndSelectOption("#assign_volunteer", volunteerName); | |
cy.clickSubmitButton("Assign"); | |
cy.wait(2000); | |
} | |
selectAndAssignVolunteer(volunteerName: string) { | |
cy.clickAndSelectOption("#assign_volunteer", volunteerName); | |
cy.clickSubmitButton("Assign"); | |
// Wait for the assignment to complete | |
cy.get('#assigned-volunteer', { timeout: 10000 }) | |
.should('be.visible') | |
.should('contain.text', volunteerName); | |
} |
export class PatientDetailsPage { | ||
clickAssignToAVounteer() { | ||
cy.get('button:contains("Assign to a volunteer")').click({ force: true }); | ||
} |
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.
Fix typo and avoid force clicks
- The method name contains a typo: "Vounteer" should be "Volunteer"
- Using
force: true
for clicks can make tests brittle and mask real issues. Consider:- Waiting for the button to be actionable
- Using proper selectors that ensure visibility
Here's the suggested fix:
- clickAssignToAVounteer() {
- cy.get('button:contains("Assign to a volunteer")').click({ force: true });
+ clickAssignToVolunteer() {
+ cy.contains('button', 'Assign to a volunteer')
+ .should('be.visible')
+ .should('be.enabled')
+ .click();
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export class PatientDetailsPage { | |
clickAssignToAVounteer() { | |
cy.get('button:contains("Assign to a volunteer")').click({ force: true }); | |
} | |
export class PatientDetailsPage { | |
clickAssignToVolunteer() { | |
cy.contains('button', 'Assign to a volunteer') | |
.should('be.visible') | |
.should('be.enabled') | |
.click(); | |
} |
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(); | ||
}); |
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
Enhance test organization and assertions
While the test covers all required scenarios, consider these improvements:
- Split into smaller, focused test cases using nested describes
- Add explicit assertions for navigation success
- Add error handling for critical steps
describe("Assign a volunteer to a patient", () => {
// ... existing setup ...
describe("volunteer assignment workflow", () => {
beforeEach(() => {
cy.visit("/patients").then(() => {
cy.log("Successfully navigated to patients page");
});
patientPage.visitPatient(patient);
patientConsultationPage.clickPatientDetails();
});
it("should assign a new volunteer successfully", () => {
patientDetailsPage.clickAssignToAVounteer();
patientDetailsPage.selectAndAssignVolunteer(volunteerName);
patientDetailsPage.verifyVolunteerBannerIsUpdated(volunteerName);
});
it("should replace existing volunteer successfully", () => {
patientDetailsPage.clickAssignToAVounteer();
patientDetailsPage.selectAndAssignVolunteer(anotherVolunteerName);
patientDetailsPage.verifyVolunteerBannerIsUpdated(anotherVolunteerName);
});
it("should unassign volunteer successfully", () => {
patientDetailsPage.clickAssignToAVounteer();
patientDetailsPage.unassignVolunteer();
patientDetailsPage.verifyBannerIsRemovedAfterUnassign();
});
});
});
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.
Some of the suggestions are worth doing, like this one (break it up into smaller tests). Go ahead and make the changes accordingly @sidpg123
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.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
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(); | ||
}); |
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.
Some of the suggestions are worth doing, like this one (break it up into smaller tests). Go ahead and make the changes accordingly @sidpg123
@Jacobjeevan i will do it. |
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: 5
🧹 Outside diff range and nitpick comments (4)
cypress/pageobject/Patient/PatientDetails.ts (3)
2-8
: Improve visibility check reliabilityThe current order of operations might cause flaky tests. Checking visibility after scrolling could miss elements that are initially visible without scrolling.
clickAssignToVolunteer() { cy.contains("button", "Assign to a volunteer") - .scrollIntoView() .should("be.visible") .should("be.enabled") + .scrollIntoView() .click(); }
10-17
: Add type safety for volunteer name parameterConsider adding string literal type or enum for valid volunteer names to prevent test failures due to invalid inputs.
- selectAndAssignVolunteer(volunteerName: string) { + selectAndAssignVolunteer(volunteerName: VolunteerName) {Add this type definition at the top of the file:
type VolunteerName = string & { readonly brand: unique symbol };
1-34
: Add error scenario handling methodsThe class should include methods to verify error states mentioned in the PR objectives, such as:
- Invalid volunteer assignment attempts
- Network error handling
- Concurrent assignment scenarios
Consider adding these methods:
verifyErrorMessage(message: string) { cy.get("[role='alert']") .should("be.visible") .and("contain.text", message); } verifyAssignButtonDisabledState() { cy.contains("button", "Assign") .should("be.disabled"); }cypress/e2e/patient_spec/PatientVolunteer.cy.ts (1)
11-13
: Consider moving test data to fixturesThe hardcoded test data (
patient
,volunteerName
,anotherVolunteerName
) should be moved to Cypress fixtures for better maintainability and reusability.Create a fixture file
cypress/fixtures/volunteer-assignment.json
:{ "patient": "Dummy Patient 16", "volunteers": { "primary": "dummy volunteer", "secondary": "Abhi Patil" } }Then update the test to use the fixture:
describe("Assign a volunteer to a patient", () => { let testData: any; before(() => { cy.fixture('volunteer-assignment').then((data) => { testData = data; }); // ... rest of before hook }); // Use testData.patient, testData.volunteers.primary, etc. });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
cypress/e2e/patient_spec/PatientVolunteer.cy.ts
(1 hunks)cypress/pageobject/Patient/PatientDetails.ts
(1 hunks)
🔇 Additional comments (1)
cypress/e2e/patient_spec/PatientVolunteer.cy.ts (1)
35-35
: Verify banner element targeting across components
The test relies on banner verification methods. Let's ensure the banner element's id attribute is consistently implemented across components.
Also applies to: 41-41, 47-47
✅ Verification successful
Let me try a different approach to verify the banner implementation.
Let me check the actual component implementation to verify the banner element's consistency.
Let me check the specific component implementations for the volunteer banner.
Based on the verification results, I can now provide the final response:
Banner element implementation is consistent and correct
The volunteer banner is correctly implemented using a unique id attribute assigned-volunteer
in the PatientHome component, and the test's verification method verifyVolunteerBannerIsUpdated
correctly targets this element. The implementation is consistent across both the component and test files.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify banner element implementation
# Check for banner element id in components
echo "Checking for banner element id..."
rg -l "assigned-volunteer" --type ts --type tsx
# Check for consistent data-testid usage
echo "Checking for data-testid attributes..."
ast-grep --pattern 'data-testid="volunteer-banner"'
Length of output: 293
Script:
#!/bin/bash
# Search for volunteer banner related code in test files and components
echo "Checking test files for volunteer banner verification..."
rg -A 3 "verifyVolunteerBannerIsUpdated" --type ts
echo "Checking component files for volunteer banner..."
rg -A 3 "volunteer.*banner" --type ts --ignore-case
Length of output: 2663
Script:
#!/bin/bash
# Search for the assigned-volunteer element in component files
echo "Checking for assigned-volunteer element in component files..."
rg -A 3 "assigned-volunteer" --type tsx --type jsx --type ts
# Search for volunteer-related components
echo "Checking for volunteer-related components..."
fd -e tsx -e jsx . | xargs rg -l "Volunteer"
Length of output: 462
Script:
#!/bin/bash
# Check PatientHome component implementation
echo "Checking PatientHome.tsx implementation..."
cat "src/components/Patient/PatientHome.tsx"
# Check for any data-testid usage in Patient components
echo "Checking for data-testid in Patient components..."
rg "data-testid.*volunteer" src/components/Patient/
Length of output: 59653
verifyVolunteerBannerIsUpdated(volunteerName: string) { | ||
cy.get("#assigned-volunteer") | ||
.scrollIntoView() | ||
.should("contain.text", `Assigned Volunteer:${volunteerName}`); | ||
} |
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
Fix banner text verification and remove redundant scroll
The banner text verification has formatting issues and unnecessary scrolling.
verifyVolunteerBannerIsUpdated(volunteerName: string) {
cy.get("#assigned-volunteer")
- .scrollIntoView()
.should("contain.text",
- `Assigned Volunteer:${volunteerName}`
+ `Assigned Volunteer: ${volunteerName}`
);
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
verifyVolunteerBannerIsUpdated(volunteerName: string) { | |
cy.get("#assigned-volunteer") | |
.scrollIntoView() | |
.should("contain.text", `Assigned Volunteer:${volunteerName}`); | |
} | |
verifyVolunteerBannerIsUpdated(volunteerName: string) { | |
cy.get("#assigned-volunteer") | |
.should("contain.text", | |
`Assigned Volunteer: ${volunteerName}` | |
); | |
} |
verifyBannerIsRemovedAfterUnassign() { | ||
cy.get("#assigned-volunteer").should("not.exist"); // Ensure the banner does not exist | ||
} |
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
Add timeout for banner removal verification
The verification should account for potential delays in DOM updates.
verifyBannerIsRemovedAfterUnassign() {
- cy.get("#assigned-volunteer").should("not.exist"); // Ensure the banner does not exist
+ cy.get("#assigned-volunteer", { timeout: 10000 }).should("not.exist");
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
verifyBannerIsRemovedAfterUnassign() { | |
cy.get("#assigned-volunteer").should("not.exist"); // Ensure the banner does not exist | |
} | |
verifyBannerIsRemovedAfterUnassign() { | |
cy.get("#assigned-volunteer", { timeout: 10000 }).should("not.exist"); | |
} |
unassignAndPrepareForReassignment() { | ||
cy.get("#clear-button").should("be.visible").find("svg").click(); | ||
cy.get("#dropdown-toggle").click(); | ||
cy.clickSubmitButton("Assign"); | ||
} |
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
Enhance unassign action reliability
The current implementation might be fragile due to direct SVG interaction and missing state verifications.
unassignAndPrepareForReassignment() {
- cy.get("#clear-button").should("be.visible").find("svg").click();
+ cy.get("#clear-button")
+ .should("be.visible")
+ .click()
+ .should("not.be.disabled");
cy.get("#dropdown-toggle")
+ .should("be.visible")
.click();
+ .should("have.attr", "aria-expanded", "true");
cy.clickSubmitButton("Assign");
}
Committable suggestion skipped: line range outside the PR's diff.
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(); | ||
}); | ||
}); |
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
Add test coverage for error states and edge cases
While the happy path scenarios are well covered, consider adding tests for error states and edge cases.
Add these test cases:
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 assignment cancellation", () => {
patientDetailsPage.clickAssignToVolunteer();
patientDetailsPage.cancelAssignment();
patientDetailsPage.verifyAssignmentModalClosed();
});
it("should prevent duplicate volunteer assignment", () => {
// Assuming the volunteer is already assigned
patientDetailsPage.clickAssignToVolunteer();
patientDetailsPage.selectAndAssignVolunteer(volunteerName);
cy.get('[data-testid="error-message"]')
.should('contain', 'Volunteer already assigned');
});
});
Also, verify the UI state between actions:
it("should replace existing volunteer successfully", () => {
patientDetailsPage.clickAssignToVolunteer();
+ // Verify current volunteer is shown as selected
+ cy.get('[data-testid="current-volunteer"]')
+ .should('contain', volunteerName);
patientDetailsPage.selectAndAssignVolunteer(anotherVolunteerName);
+ // Verify loading state during assignment
+ cy.get('[data-testid="loading-indicator"]')
+ .should('exist')
+ .should('not.exist');
patientDetailsPage.verifyVolunteerBannerIsUpdated(anotherVolunteerName);
});
cy.visit("/patients").then(() => { | ||
cy.log("Successfully navigated to patients page"); | ||
}); | ||
patientPage.visitPatient(patient); | ||
patientConsultationPage.clickPatientDetails(); |
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
Add error handling for critical navigation steps
The navigation steps should include error handling to ensure the test fails gracefully if the patient is not found.
Add error handling:
- cy.visit("/patients").then(() => {
- cy.log("Successfully navigated to patients page");
- });
- patientPage.visitPatient(patient);
- patientConsultationPage.clickPatientDetails();
+ cy.visit("/patients")
+ .its('status')
+ .should('eq', 200)
+ .then(() => {
+ cy.log("Successfully navigated to patients page");
+ });
+
+ // 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('[data-testid="patient-details"]').should('exist');
+ patientConsultationPage.clickPatientDetails();
Committable suggestion skipped: line range outside the PR's diff.
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Tests