From 0d2e876a596458c06dd6eaada0619082d0b051e4 Mon Sep 17 00:00:00 2001 From: SwanandBhuskute Date: Sat, 23 Nov 2024 14:03:18 +0000 Subject: [PATCH] fixing cypress tests --- .../e2e/patient_spec/PatientConsultationCreation.cy.ts | 6 ++++-- cypress/e2e/patient_spec/PatientRegistration.cy.ts | 1 - cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts | 8 -------- cypress/pageobject/Patient/PatientConsultation.ts | 2 +- cypress/pageobject/Patient/PatientCreation.ts | 4 +++- cypress/pageobject/Sample/SampleTestCreate.ts | 2 +- 6 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts index 8e46dc86ede..3eacd9b718f 100644 --- a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts +++ b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts @@ -201,8 +201,10 @@ describe("Patient Consultation in multiple combination", () => { cy.clickSubmitButton("Create Consultation"); cy.verifyNotification("Consultation created successfully"); // verify the data and death report - cy.get("#consultation-buttons").should("be.visible"); - cy.contains("#consultation-buttons", "EXPIRED").should("exist"); + patientConsultationPage.verifyTextInConsultation( + "#consultation-buttons", + "EXPIRED", + ); patientConsultationPage.clickPatientDetails(); patientDeathReport.clickDeathReport(); patientDeathReport.verifyDeathReportAutofill( diff --git a/cypress/e2e/patient_spec/PatientRegistration.cy.ts b/cypress/e2e/patient_spec/PatientRegistration.cy.ts index 3863e302438..c3647ceac3a 100644 --- a/cypress/e2e/patient_spec/PatientRegistration.cy.ts +++ b/cypress/e2e/patient_spec/PatientRegistration.cy.ts @@ -83,7 +83,6 @@ describe("Patient Creation with consultation", () => { patientPage.createPatient(); patientPage.selectFacility(patientFacility); patientPage.patientformvisibility(); - cy.get("div:contains('Age')").scrollIntoView().should("be.visible").click(); // Patient Details page patientPage.typePatientPhoneNumber(phone_number); patientPage.checkPhoneNumberIsEmergencyNumber(); diff --git a/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts b/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts index b016e0f5aae..da4d8aabd20 100644 --- a/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts +++ b/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts @@ -42,8 +42,6 @@ describe("Sample Test", () => { patientConsultationPage.verifyPatientDetailsResponse(); // Visit SampleRequest Page sampleTestPage.visitSampleRequestPage(); - // Wait for necessary APIs - cy.intercept("GET", "/api/sample-test-status").as("sampleTestStatus"); // Fill Sample Test Request Form sampleTestPage.selectSampleType(sampleTestType); sampleTestPage.selectIcmrCategory(icmrCategory); @@ -62,12 +60,6 @@ describe("Sample Test", () => { cy.clickSubmitButton("Confirm your request to send sample for testing"); sampleTestPage.verifySampleTestReq(); cy.verifyNotification("Sample test created successfully"); - // Wait for status element to load - cy.wait("@sampleTestStatus"); - cy.get("#sample-test-status", { timeout: 20000 }) - .should("exist") - .and("contain.text", sampleTestStatus); - // Check the updated request history sampleTestPage.checkRequestHistory( sampleTestStatus, diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index c8046a39a9e..b5f13803d27 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -96,7 +96,7 @@ export class PatientConsultationPage { verifyTextInConsultation(selector: string, text: string) { cy.get(selector).scrollIntoView(); - cy.get(selector).contains(text).should("be.visible"); + cy.get(selector).contains(text, { timeout: 20000 }).should("be.visible"); } typeReferringFacility(referringFacility: string) { diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index a38b8ab6a5c..2767ba6d035 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -7,7 +7,9 @@ export class PatientPage { cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities"); cy.get("#add-patient-details").should("be.visible"); cy.get("#add-patient-details").click(); - cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); + cy.wait("@getFacilities", { timeout: 20000 }) + .its("response.statusCode") + .should("eq", 200); } visitPatient(patientName: string) { diff --git a/cypress/pageobject/Sample/SampleTestCreate.ts b/cypress/pageobject/Sample/SampleTestCreate.ts index cd2e93e5072..b554d82edb0 100644 --- a/cypress/pageobject/Sample/SampleTestCreate.ts +++ b/cypress/pageobject/Sample/SampleTestCreate.ts @@ -1,7 +1,7 @@ export class SampleTestPage { visitSampleRequestPage(): void { cy.verifyAndClickElement("#sample-request-btn", "Request Sample Test"); - cy.url().should("include", "/sample-test"); + cy.url().should("include", "/sample-test", { timeout: 20000 }); } selectSampleType(option: string): void {