Skip to content

Commit

Permalink
Merge branch 'develop' into test#fixconsultationurl
Browse files Browse the repository at this point in the history
  • Loading branch information
konavivekramakrishna authored Dec 20, 2023
2 parents 85e6e6d + 7c21b80 commit a41601b
Show file tree
Hide file tree
Showing 54 changed files with 488 additions and 315 deletions.
8 changes: 1 addition & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
### WHAT
copilot:summary

## Proposed Changes

- Fixes #issue?
- Fixes #issue_number
- Change 1
- Change 2
- More?
Expand All @@ -18,6 +15,3 @@ copilot:summary
- [ ] Prep screenshot or demo video for changelog entry, and attach it to issue.
- [ ] Request for Peer Reviews
- [ ] Completion of QA

### HOW
copilot:walkthrough
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 .github/workflows/thank-you.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Say thanks for the contributors

on:
pull_request:
pull_request_target:
types:
- closed

Expand Down
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
22 changes: 19 additions & 3 deletions cypress/pageobject/Users/UserSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,25 @@ export class UserPage {
cy.url().should("include", `page=${pageNumber}`);
}

verifyMultipleBadgesWithSameId(expectedContents: string[]) {
cy.get("#user-view-name").each((el, index) => {
expect(el.text().trim()).to.equal(expectedContents[index]);
verifyMultipleBadgesWithSameId(alreadylinkedusersviews: string[]) {
cy.get("#user-view-name").then(($elements) => {
const userViews = $elements
.map((_, el) => Cypress.$(el).text().trim())
.get();
let foundMatches = 0;

alreadylinkedusersviews.forEach((expectedContent) => {
const index = userViews.findIndex((actualContent) =>
actualContent.includes(expectedContent)
);
if (index !== -1) {
userViews.splice(index, 1); // Remove the matched element
foundMatches++;
}
if (foundMatches === alreadylinkedusersviews.length) {
return false; // Break the loop if all matches are found
}
});
});
}
}
29 changes: 28 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,34 @@

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<div id="root">
<style>
.App-logo {
height: 10vmin;
pointer-events: none;
filter: brightness(80%);
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-blink 1s linear infinite;
}
}
@keyframes App-logo-blink {
0% { opacity: 0;}
25% { opacity: 0.5;}
50% {opacity: 1;}
75% {opacity: 0.5;}
100% {opacity: 0;}
}
</style>
<div style="display: grid;place-items: center;height: 100vh; text-align: center;">
<img
class="App-logo"
src="https://cdn.coronasafe.network/light-logo.svg"
alt="Care is loading"
/>
</div>
</div>
<script type="module" src="/src/index.tsx"></script>
<script
src="https://kit.fontawesome.com/d69454c2e7.js"
Expand Down
Loading

0 comments on commit a41601b

Please sign in to comment.