Skip to content

Commit

Permalink
use celery beat to check for pending migrations (ohcnetwork#6845)
Browse files Browse the repository at this point in the history
* use celery beat to check for pending migrations

* increase wait time for migrations

* Facility Module Fix

* Patient crud fix

* Patient Module Fix

* Fix for external results

* Patient manage fix

* revert vite

* fix flaky test

* try restarting backend after loading dummy data

* Update cypress.yaml

* retry check if care is up with delay

---------

Co-authored-by: Mohammed Nihal <[email protected]>
Co-authored-by: Rithvik Nishad <[email protected]>
  • Loading branch information
3 people authored Dec 14, 2023
1 parent c8a71f6 commit 12b4847
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 30 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ..
Expand All @@ -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
Expand Down Expand Up @@ -79,4 +85,3 @@ jobs:
with:
name: cypress-screenshots
path: cypress/screenshots

2 changes: 1 addition & 1 deletion cypress/e2e/external_results_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
8 changes: 7 additions & 1 deletion cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion cypress/e2e/patient_spec/patient_crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/patient_spec/patient_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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");
Expand Down
34 changes: 34 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
9 changes: 7 additions & 2 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
19 changes: 6 additions & 13 deletions cypress/pageobject/Patient/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -41,7 +45,6 @@ export class PatientPage {
gender: string,
address: string,
pincode: string,
wardName: string,
bloodGroup: string,
dateOfBirth: string
) {
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class ManageUserPage {
}

typeFacilitySearch(facilityName) {
cy.get("#search").click().clear();
cy.get("#search").click().type(facilityName);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ export const PatientManager = () => {
</div>
<div className="flex w-full flex-col gap-2 pl-2 md:block md:flex-row">
<div className="flex w-full items-center justify-between gap-2">
<div className="flex flex-wrap gap-2 font-semibold">
<div
className="flex flex-wrap gap-2 font-semibold"
id="patient-name-list"
>
<span className="text-xl capitalize">{patient.name}</span>
<span className="text-gray-800">
{formatAge(patient.age, patient.date_of_birth, true)}
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ export default function PatientInfoCard(props: {
</ButtonV2>
</div>
<div className="flex flex-col items-center gap-4 lg:items-start lg:gap-0 lg:pl-6">
<div className="mb-1 font-semibold sm:text-xl md:text-4xl">
<div
className="mb-1 font-semibold sm:text-xl md:text-4xl"
id="patient-name-consultation"
>
{patient.name}
</div>
<div>
Expand Down

0 comments on commit 12b4847

Please sign in to comment.