-
Notifications
You must be signed in to change notification settings - Fork 502
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
Fixed the flaky investigation cypress test #9091
Conversation
WalkthroughThe changes made in this pull request involve updating the Changes
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
cypress/e2e/patient_spec/PatientInvestigation.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. |
Deploying care-fe with Cloudflare Pages
|
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: 1
🧹 Outside diff range and nitpick comments (1)
cypress/e2e/patient_spec/PatientInvestigation.cy.ts (1)
Line range hint
22-35
: Test implementation is incomplete and may cause flakiness.The test has several issues that could contribute to flakiness:
- Only verifies the error case
- Contains a TODO comment about temporary workflow
- Missing assertions for successful investigation creation
Consider completing the test implementation:
it("Create a investigation for a patient and verify its reflection", () => { patientPage.visitPatient(patientName); patientInvestigation.clickInvestigationTab(); patientInvestigation.clickLogLabResults(); // Select investigations patientInvestigation.selectInvestigationOption([ "Haematology", "Urine Test", ]); // First verify error case cy.submitButton("Save Investigation"); cy.verifyNotification("Please Enter at least one value"); cy.closeNotification(); // Then test the happy path patientInvestigation.enterTestResults({ haematology: { value: "Normal", notes: "Test notes" }, urineTest: { value: "Normal", notes: "Test notes" } }); cy.submitButton("Save Investigation"); cy.verifyNotification("Investigation saved successfully"); // Verify investigation appears in the list patientInvestigation.verifyInvestigationExists({ type: ["Haematology", "Urine Test"], status: "Completed" }); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
cypress/e2e/patient_spec/PatientInvestigation.cy.ts
(1 hunks)
🔇 Additional comments (1)
cypress/e2e/patient_spec/PatientInvestigation.cy.ts (1)
Line range hint 15-21
: Review state management approach.
The current state management using localStorage and filter clearing could lead to test interference:
clearLocalStorage(/filters--.+/)
suggests filtering state might affect the test- No verification that the state is properly reset
Let's check for other tests that might interfere with this one:
Consider implementing more robust state isolation:
beforeEach(() => {
cy.restoreLocalStorage();
// Clear all application state, not just filters
cy.window().then((win) => {
win.localStorage.clear();
win.sessionStorage.clear();
});
// Explicitly set required state
cy.setInitialState({
filters: {},
// other required state
});
cy.awaitUrl("/patients");
});
@@ -7,7 +7,7 @@ describe("Patient Investigation Creation from Patient consultation page", () => | |||
const loginPage = new LoginPage(); | |||
const patientPage = new PatientPage(); | |||
const patientInvestigation = new PatientInvestigation(); | |||
const patientName = "Dummy Patient 12"; | |||
const patientName = "Dummy Patient 14"; |
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.
Changing patient name may not address the root cause of flakiness.
While updating the patient name might temporarily fix the issue, it suggests a deeper problem with test data management. The test appears to depend on pre-existing data without proper setup/teardown.
Consider implementing one of these approaches:
- Create test data during the test setup
- Use dynamic test data generation
- Implement proper cleanup to ensure test isolation
Example approach using test data creation:
before(() => {
loginPage.loginAsDistrictAdmin();
// Create test patient with known state
cy.createTestPatient(patientName, {
// Add required patient properties
}).then(patient => {
cy.saveLocalStorage();
});
});
after(() => {
// Cleanup test data
cy.deleteTestPatient(patientName);
});
CARE Run #3885
Run Properties:
|
Project |
CARE
|
Branch Review |
flaky-investigation
|
Run status |
Passed #3885
|
Run duration | 04m 37s |
Commit |
491eb46bd5: Fixed the flaky investigation test
|
Committer | Mohammed Nihal |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
128
|
View all changes introduced in this branch ↗︎ |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit