-
Notifications
You must be signed in to change notification settings - Fork 509
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 HCX Workflow in the platform #9007
Changes from all commits
0a39eb2
3e4f3b3
4d7dc3b
b0b7b80
ceed7e3
59d5642
8c9bbc7
4d5d3ab
7a5f92a
fc4f060
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { HcxClaims } from "pageobject/Hcx/HcxClaims"; | ||
import { PatientConsultationPage } from "pageobject/Patient/PatientConsultation"; | ||
import PatientInsurance from "pageobject/Patient/PatientInsurance"; | ||
|
||
import LoginPage from "../../pageobject/Login/LoginPage"; | ||
import { PatientPage } from "../../pageobject/Patient/PatientCreation"; | ||
|
||
describe("HCX Claims configuration and approval workflow", () => { | ||
const loginPage = new LoginPage(); | ||
const patientPage = new PatientPage(); | ||
const patientConsultationPage = new PatientConsultationPage(); | ||
const patientInsurance = new PatientInsurance(); | ||
const hcxClaims = new HcxClaims(); | ||
const hcxPatientName = "Dummy Patient 14"; | ||
const firstInsuranceIdentifier = "insurance-details-0"; | ||
const patientMemberId = "001"; | ||
const patientPolicyId = "100"; | ||
const patientInsurerName = "Demo Payor"; | ||
|
||
before(() => { | ||
loginPage.loginAsDistrictAdmin(); | ||
cy.saveLocalStorage(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.restoreLocalStorage(); | ||
cy.clearLocalStorage(/filters--.+/); | ||
cy.awaitUrl("/patients"); | ||
}); | ||
|
||
it("Verify the HCX Workflow for a patient with mocked eligibility", () => { | ||
// Modify the insurance for a facility | ||
patientPage.visitPatient(hcxPatientName); | ||
patientConsultationPage.clickPatientDetails(); | ||
patientPage.clickPatientUpdateDetails(); | ||
patientInsurance.clickAddInsruanceDetails(); | ||
patientInsurance.typePatientInsuranceDetail( | ||
firstInsuranceIdentifier, | ||
"subscriber_id", | ||
patientMemberId, | ||
); | ||
patientInsurance.typePatientInsuranceDetail( | ||
firstInsuranceIdentifier, | ||
"policy_id", | ||
patientPolicyId, | ||
); | ||
patientInsurance.selectPatientInsurerName( | ||
firstInsuranceIdentifier, | ||
patientInsurerName, | ||
); | ||
cy.submitButton("Save Details"); | ||
cy.verifyNotification("Patient updated successfully"); | ||
cy.closeNotification(); | ||
// Navigate to Consultation View and capture dynamic consultation ID | ||
let consultationId: string; | ||
patientConsultationPage.clickViewConsultationButton(); | ||
cy.url().then((url) => { | ||
const urlRegex = | ||
/facility\/([^/]+)\/patient\/([^/]+)\/consultation\/([^/]+)/; | ||
const match = url.match(urlRegex); | ||
if (match) { | ||
consultationId = match[3]; | ||
} | ||
}); | ||
// Intercept and mock the eligibility check response using captured consultationId | ||
cy.intercept("POST", "/api/hcx/check_eligibility", (req) => { | ||
req.reply({ | ||
statusCode: 200, | ||
body: { | ||
api_call_id: "bfa228f0-cdfa-4426-bebe-26e996079dbb", | ||
correlation_id: "86ae030c-1b33-4e52-a6f1-7a74a48111eb", | ||
timestamp: Date.now(), | ||
consultation: consultationId, | ||
policy: patientPolicyId, | ||
outcome: "Complete", | ||
limit: 1, | ||
}, | ||
}); | ||
}).as("checkEligibility"); | ||
// Raise a HCX Pre-auth | ||
patientConsultationPage.clickManagePatientButton(); | ||
patientConsultationPage.clickClaimsButton(); | ||
hcxClaims.selectEligiblePolicy(patientInsurerName); | ||
hcxClaims.verifyPolicyEligibility(); | ||
cy.verifyNotification("Checking Policy Eligibility"); | ||
cy.closeNotification(); | ||
// Confirm that the eligibility check displays as successful | ||
cy.wait("@checkEligibility").then((interception) => { | ||
const response = interception.response.body; | ||
expect(response.outcome).to.equal("Complete"); | ||
}); | ||
}); | ||
Comment on lines
+31
to
+92
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. 🛠️ Refactor suggestion Consider breaking down the test into smaller, focused scenarios. The current test covers multiple aspects of the workflow in a single test. This makes it harder to maintain and debug failures. Consider splitting into separate test cases: it('should update patient insurance details')
it('should capture consultation ID from URL')
it('should verify policy eligibility check') 🧰 Tools🪛 Gitleaks70-70: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) |
||
|
||
afterEach(() => { | ||
cy.saveLocalStorage(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class HcxClaims { | ||
selectEligiblePolicy(policy: string) { | ||
cy.clickAndSelectOption("#select-insurance-policy", policy); | ||
} | ||
Comment on lines
+2
to
+4
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. 🛠️ Refactor suggestion Improve selector maintainability and add type safety. Consider using data-testid attributes instead of CSS IDs for more reliable test selectors: - selectEligiblePolicy(policy: string) {
+ selectEligiblePolicy(policy: string): void {
- cy.clickAndSelectOption("#select-insurance-policy", policy);
+ cy.clickAndSelectOption("[data-testid=insurance-policy-select]", policy);
+ cy.get("[data-testid=insurance-policy-select]")
+ .should("contain.text", policy);
}
|
||
|
||
verifyPolicyEligibility() { | ||
cy.verifyAndClickElement("#check-eligibility", "Check Eligibility"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,6 +13,7 @@ export class PatientConsultationPage { | |||||||||||||||||||||||||||||||||||||||
selectSymptomsDate(date: string) { | ||||||||||||||||||||||||||||||||||||||||
cy.clickAndTypeDate("#symptoms_onset_date", date); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
clickAddSymptom() { | ||||||||||||||||||||||||||||||||||||||||
cy.get("#add-symptom").click(); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
@@ -111,4 +112,22 @@ export class PatientConsultationPage { | |||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
cy.wait(3000); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
clickViewConsultationButton() { | ||||||||||||||||||||||||||||||||||||||||
cy.verifyAndClickElement( | ||||||||||||||||||||||||||||||||||||||||
"#view_consultation_updates", | ||||||||||||||||||||||||||||||||||||||||
"View Consultation / Consultation Updates", | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+116
to
+121
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. 🛠️ Refactor suggestion Add wait handling after click action The click action might trigger page load or state changes. Add appropriate wait handling to improve test reliability. clickViewConsultationButton() {
cy.verifyAndClickElement(
"#view_consultation_updates",
"View Consultation / Consultation Updates",
);
+ // Wait for the consultation updates to load
+ cy.get('.consultation-updates-container').should('be.visible', { timeout: 10000 });
}
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
clickManagePatientButton() { | ||||||||||||||||||||||||||||||||||||||||
cy.verifyAndClickElement("#show-more", "Manage Patient"); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+123
to
+125
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. 🛠️ Refactor suggestion Consider improving selector specificity and method consistency.
Consider these improvements: clickManagePatientButton() {
- cy.verifyAndClickElement("#show-more", "Manage Patient");
+ cy.get("#consultation-buttons") // Add parent container for better specificity
+ .find("#show-more")
+ .should("contain", "Manage Patient")
+ .click();
+ cy.wait(3000); // Add appropriate wait time or better, wait for a specific element/network request
} Also, consider consolidating this with
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
clickClaimsButton() { | ||||||||||||||||||||||||||||||||||||||||
cy.get("#log-update").scrollIntoView(); | ||||||||||||||||||||||||||||||||||||||||
cy.intercept(/\/api\/hcx\/policy\/\?.*/).as("policyStatus"); | ||||||||||||||||||||||||||||||||||||||||
cy.get("#consultation-buttons").contains("Claims").click(); | ||||||||||||||||||||||||||||||||||||||||
cy.wait("@policyStatus").its("response.statusCode").should("eq", 200); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+127
to
+132
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. 🛠️ Refactor suggestion Enhance API handling and test reliability. The current implementation has several potential reliability issues:
Consider these improvements: clickClaimsButton() {
cy.get("#log-update").scrollIntoView();
- cy.intercept(/\/api\/hcx\/policy\/\?.*/).as("policyStatus");
+ cy.intercept({
+ method: 'GET',
+ url: '/api/hcx/policy/*'
+ }).as("policyStatus");
cy.get("#consultation-buttons").contains("Claims").click();
- cy.wait("@policyStatus").its("response.statusCode").should("eq", 200);
+ cy.wait("@policyStatus", { timeout: 10000 })
+ .then((interception) => {
+ expect(interception.response?.statusCode).to.be.oneOf([200, 201, 204]);
+ // Add additional response validation if needed
+ });
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
} |
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 consultation ID extraction reliability.
The current URL parsing approach could fail silently. Consider adding error handling and type safety.
📝 Committable suggestion