diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f04045d0c72..001ceda68dc 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - containers: [1,2,3,4,5,6,7,8] + containers: [1, 2, 3, 4, 5, 6, 7, 8] steps: - name: Checkout 📥 uses: actions/checkout@v3 @@ -32,9 +32,9 @@ jobs: run: | cd care make docker_config_file=docker-compose.pre-built.yaml up - while docker compose exec backend bash -c "python manage.py showmigrations 2>/dev/null | cat | grep -q '\[ \]'"; do + while docker compose exec celery-beat bash -c "python manage.py showmigrations 2>/dev/null | cat | grep -q '\[ \]'"; do >&2 echo "Migrations are not yet applied - sleeping" - sleep 5 + sleep 10 done echo "Migrations are applied" cd .. @@ -43,10 +43,16 @@ jobs: run: | cd care docker compose exec backend bash -c "python manage.py load_dummy_data" + docker restart care-backend-1 cd .. - - name: Check care is up ♻ - run: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 + - name: Wait for care to be up ♻ + uses: nick-fields/retry@v2 + with: + timeout_minutes: 1 + max_attempts: 5 + command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 + on_retry_command: sleep 5 - name: Install dependencies 📦 run: npm install @@ -79,4 +85,3 @@ jobs: with: name: cypress-screenshots path: cypress/screenshots - diff --git a/cypress/e2e/external_results_spec/filter.cy.ts b/cypress/e2e/external_results_spec/filter.cy.ts index 577b6a46d98..3dd18704a46 100644 --- a/cypress/e2e/external_results_spec/filter.cy.ts +++ b/cypress/e2e/external_results_spec/filter.cy.ts @@ -20,7 +20,7 @@ describe("External Results Filters", () => { cy.get("#local_bodies").click(); cy.get("#wards").click(); cy.get("[role='option']").should("be.visible"); - cy.contains("[role='option']", "12").click(); + cy.contains("[role='option']", "4").click(); cy.contains("Apply").click(); }); diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index 9fe78f84256..9725ed42a28 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -120,6 +120,8 @@ describe("Facility Creation", () => { cy.get("[role='option']").contains(featureText).click(); }); facilityPage.fillPincode("682001"); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Ernakulam"); facilityPage.selectLocalBody("Aluva"); facilityPage.selectWard("4"); facilityPage.fillAddress(facilityAddress); @@ -190,6 +192,8 @@ describe("Facility Creation", () => { facilityPage.visitCreateFacilityPage(); facilityPage.fillFacilityName(facilityName); facilityPage.fillPincode("682001"); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Ernakulam"); facilityPage.selectLocalBody("Aluva"); facilityPage.selectWard("4"); facilityPage.fillAddress(facilityAddress); @@ -217,7 +221,7 @@ describe("Facility Creation", () => { .should("be.visible"); // verify the facility homepage cy.visit("/facility"); - cy.clearAllFilters(); + cy.get("#removeicon").click(); manageUserPage.typeFacilitySearch(facilityName); facilityPage.verifyFacilityBadgeContent(facilityName); manageUserPage.assertFacilityInCard(facilityName); @@ -228,6 +232,8 @@ describe("Facility Creation", () => { facilityPage.visitCreateFacilityPage(); facilityPage.fillFacilityName(facilityName); facilityPage.fillPincode("682001"); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Ernakulam"); facilityPage.selectLocalBody("Aluva"); facilityPage.selectWard("4"); facilityPage.fillAddress(facilityAddress); diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index b9843c1556d..06a27333b9e 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -2,6 +2,7 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; import LoginPage from "../../pageobject/Login/LoginPage"; import { PatientPage } from "../../pageobject/Patient/PatientCreation"; import { UpdatePatientPage } from "../../pageobject/Patient/PatientUpdate"; +import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation"; import { emergency_phone_number, @@ -19,6 +20,7 @@ describe("Patient Creation with consultation", () => { const patientPage = new PatientPage(); const updatePatientPage = new UpdatePatientPage(); const patientConsultationPage = new PatientConsultationPage(); + const facilityPage = new FacilityPage(); before(() => { loginPage.loginAsDisctrictAdmin(); @@ -42,10 +44,13 @@ describe("Patient Creation with consultation", () => { "Male", "Test Patient Address", "682001", - "1: PAZHAMTHOTTAM", "O+", "01012001" ); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Ernakulam"); + facilityPage.selectLocalBody("Aluva"); + facilityPage.selectWard("4"); patientPage.clickCreatePatient(); patientPage.verifyPatientIsCreated(); diff --git a/cypress/e2e/patient_spec/patient_manage.cy.ts b/cypress/e2e/patient_spec/patient_manage.cy.ts index 89d00b6bb9f..6c58767c06b 100644 --- a/cypress/e2e/patient_spec/patient_manage.cy.ts +++ b/cypress/e2e/patient_spec/patient_manage.cy.ts @@ -36,7 +36,7 @@ describe("Patient", () => { // commented out the shifting request, as logic need to be re-visited it("Post doctor notes for an already created patient", () => { - patientPage.visitPatient(); + patientPage.visitPatient("Dummy Patient 3"); patientConsultationPage.visitDoctorNotesPage(); patientConsultationPage.addDoctorsNotes("Test Doctor Notes"); patientConsultationPage.postDoctorNotes(); @@ -46,7 +46,7 @@ describe("Patient", () => { }); it("Edit prescription for an already created patient", () => { - patientPage.visitPatient(); + patientPage.visitPatient("Dummy Patient 4"); patientConsultationPage.visitEditPrescriptionPage(); patientConsultationPage.clickAddPrescription(); patientConsultationPage.interceptMediaBase(); @@ -59,14 +59,14 @@ describe("Patient", () => { }); it("Upload consultations file ", () => { - patientPage.visitPatient(); + patientPage.visitPatient("Dummy Patient 5"); patientConsultationPage.visitFilesPage(); patientConsultationPage.uploadFile(); patientConsultationPage.clickUploadFile(); }); it("Discharge a patient", () => { - patientPage.visitPatient(); + patientPage.visitPatient("Dummy Patient 6"); patientConsultationPage.clickDischargePatient(); patientConsultationPage.selectDischargeReason("Recovered"); patientConsultationPage.addDischargeNotes("Discharge notes"); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index c13f5beac8e..608dd9c357b 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -402,6 +402,40 @@ class FacilityPage { .its("response.statusCode") .should("eq", 201); } + + getStateElement() { + return cy.get("#state"); + } + + getDistrictElement() { + return cy.get("#district"); + } + + selectStateOnPincode(stateName) { + this.getStateElement() + .scrollIntoView() + .should("be.visible") + .then(($element) => { + const text = $element.text(); + if (!text.includes(stateName)) { + this.getStateElement().click(); + cy.get("li[role=option]").contains(stateName).click(); + } + }); + } + + selectDistrictOnPincode(districtName) { + this.getDistrictElement() + .scrollIntoView() + .should("be.visible") + .then(($element) => { + const text = $element.text(); + if (!text.includes(districtName)) { + this.getDistrictElement().click(); + cy.get("li[role=option]").contains(districtName).click(); + } + }); + } } export default FacilityPage; diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 26d75feba2e..7528b30da06 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -103,7 +103,8 @@ export class PatientConsultationPage { } visitFilesPage() { - cy.get("a").contains("Files").click(); + cy.get("#consultation_tab_nav").scrollIntoView(); + cy.get("#consultation_tab_nav").contains("Files").click(); } uploadFile() { @@ -199,11 +200,13 @@ export class PatientConsultationPage { } visitDoctorNotesPage() { + cy.get("#patient_doctor_notes").scrollIntoView(); cy.get("#patient_doctor_notes").click(); } addDoctorsNotes(notes: string) { - cy.get("#doctor_notes_textarea").type(notes); + cy.get("#doctor_notes_textarea").scrollIntoView(); + cy.get("#doctor_notes_textarea").click().type(notes); } postDoctorNotes() { @@ -213,6 +216,7 @@ export class PatientConsultationPage { } clickDischargePatient() { + cy.get("#show-more").scrollIntoView(); cy.get("#show-more").click(); cy.contains("p", "Discharge from CARE").click(); } @@ -248,6 +252,7 @@ export class PatientConsultationPage { } visitEditPrescriptionPage() { + cy.get("#consultation_tab_nav").scrollIntoView(); cy.get("#consultation_tab_nav").contains("Medicines").click(); cy.get("a[href='prescriptions']").first().click(); } diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 47bf9c913ad..4e2f92ac040 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -10,10 +10,14 @@ export class PatientPage { cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); } - visitPatient() { + visitPatient(patientName) { + cy.get("#name").click().type(patientName); cy.intercept("GET", "**/api/v1/consultation/**").as("getPatient"); - cy.get("[data-cy='patient']").first().click(); + cy.get("#patient-name-list").contains(patientName).click(); cy.wait("@getPatient").its("response.statusCode").should("eq", 200); + cy.get("#patient-name-consultation") + .should("be.visible") + .contains(patientName); } selectFacility(facilityName: string) { @@ -41,7 +45,6 @@ export class PatientPage { gender: string, address: string, pincode: string, - wardName: string, bloodGroup: string, dateOfBirth: string ) { @@ -58,16 +61,6 @@ export class PatientPage { cy.get("[data-testid=current-address] textarea").type(address); cy.get("[data-testid=permanent-address] input").check(); cy.get("#pincode").type(pincode); - cy.get("[data-testid=localbody] button") - .click() - .then(() => { - cy.get("[role='option']").first().click(); - }); - cy.get("[data-testid=ward-respective-lsgi] button") - .click() - .then(() => { - cy.get("[role='option']").contains(wardName).click(); - }); cy.get("[name=medical_history_check_1]").check(); cy.get("[data-testid=blood-group] button") .click() diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index b79b96447f0..d3f7e17e7d5 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -94,6 +94,7 @@ export class ManageUserPage { } typeFacilitySearch(facilityName) { + cy.get("#search").click().clear(); cy.get("#search").click().type(facilityName); } diff --git a/index.html b/index.html index 58cb9fffcd1..83c80ef3214 100644 --- a/index.html +++ b/index.html @@ -34,7 +34,34 @@ -
+
+ +
+ +
+