Skip to content

Commit

Permalink
Merge branch 'develop' into pressure-pain-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored May 8, 2024
2 parents 1b428ad + 3025c46 commit d35e3b0
Show file tree
Hide file tree
Showing 53 changed files with 5,040 additions and 6,081 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/auto-testing-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Auto Add Needs Testing Label

on:
pull_request:
types: [opened, reopened, edited]
issue_comment:
types: [created]
pull_request_review:
types: [submitted]

jobs:
auto_label:
runs-on: ubuntu-latest

steps:
- name: Check PR Conditions and Add Label
id: check_conditions
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const isDraft = pr.draft;
const isReadyForTestingComment = context.payload.comment?.body.includes('ready for testing');
const isChangesRequired = context.payload.review?.state === 'changes_requested';
if ((isReadyForTestingComment && !isDraft) || (!isDraft && pr.draft_changed)) {
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['needs testing']
});
}
if (isChangesRequired) {
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: 'Reminder: To add the "needs testing" label, comment "ready for testing" on this PR.'
});
}
1 change: 1 addition & 0 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- name: Start care docker containers 🐳
run: |
cd care
echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env
make docker_config_file=docker-compose.pre-built.yaml up
make docker_config_file=docker-compose.pre-built.yaml load-dummy-data
cd ..
Expand Down
15 changes: 10 additions & 5 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-vite",
options: {
builder: {
core: {
builder: {
name: "@storybook/builder-vite",
options: {
viteConfigPath: "./.storybook/vite.config.mts",
},
},
},
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
Expand Down
12 changes: 3 additions & 9 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<script>
window.global = window;
</script>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<script>
window.global = window;
</script>
3 changes: 1 addition & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import "../src/style/index.css";

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
date: /Date$/i,
},
},
},
Expand Down
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,33 @@ Authenticate to staging API with any of the following credentials

#### 🧪 Run cypress tests

Ensure that the development server is running and then run the cypress tests in either of the ways described below.
To run cypress tests locally, you'll need to setup the backend to run locally and load dummy data required for cypress to the database. See [docs](https://github.com/coronasafe/care#self-hosting).

Once backend is running locally, you'll have to ensure your local front-end is connected to local backend, by setting the `CARE_API` env.

```env
#.env
CARE_API=http://127.0.0.1:9000
```

Once done, start the development server by running

```sh
npm run dev
```

Once development server is running, then run the cypress tests in either of the ways described below.

```sh
npm run cypress:run # To run all tests in headless mode.
```

```sh
npm run cypress:run:gui # To run all tests in headed mode.
```

```sh
$ npm run cypress:run # To run all tests in headless mode.
$ npm run cypress:run:gui # To run all tests in headed mode.
$ npm run cypress:open # To debug and run tests individually.
npm run cypress:open # To debug and run tests individually.
```

- Failed test screenshots are saved in `cypress/screenshots`
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("Facility Creation", () => {
initialTriageValue,
initialTriageValue,
initialTriageValue,
initialTriageValue
initialTriageValue,
);
manageUserPage.clickSubmit();
// edit the entry and verify reflection
Expand All @@ -106,7 +106,7 @@ describe("Facility Creation", () => {
modifiedTriageValue,
modifiedTriageValue,
modifiedTriageValue,
modifiedTriageValue
modifiedTriageValue,
);
manageUserPage.clickSubmit();
facilityPage.scrollToFacilityTriage();
Expand Down Expand Up @@ -318,7 +318,7 @@ describe("Facility Creation", () => {
facilityPage.fillMiddleWareAddress("dev_middleware.coronasafe.live");
facilityPage.clickupdateMiddleWare();
facilityPage.verifySuccessNotification(
"Facility middleware updated successfully"
"Facility middleware updated successfully",
);
});

Expand Down
45 changes: 40 additions & 5 deletions cypress/e2e/patient_spec/patient_logupdate.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
cy.closeNotification();
patientLogupdate.clickLogupdate();
patientLogupdate.typePhysicalExamination(physicalExamination);
patientLogupdate.selectRoundType("Telemedicine");
patientLogupdate.typeOtherDetails(otherExamination);
patientLogupdate.typeAdditionalSymptoms(additionalSymptoms);
patientLogupdate.selectPatientCategory(patientCategory);
Expand All @@ -58,7 +59,9 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.typeRhythm(patientRhythm);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Consultation Updates details created successfully");
cy.verifyNotification(
"Telemedicine Log Updates details created successfully",
);
// verify the copied previous value
cy.closeNotification();
patientLogupdate.clickLogupdate();
Expand All @@ -71,7 +74,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
]);
cy.verifyContentPresence("#rhythm_detail", [patientRhythm]);
cy.submitButton("Continue");
cy.verifyNotification("Consultation Updates details updated successfully");
cy.verifyNotification("Normal Log Updates details updated successfully");
});

it("Create a new log normal update for a domicilary care patient and edit it", () => {
Expand All @@ -96,7 +99,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.typeRhythm(patientRhythm);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Consultation Updates details created successfully");
cy.verifyNotification("Normal Log Updates details created successfully");
cy.closeNotification();
// edit the card and verify the data.
patientLogupdate.clickLogupdateCard("#dailyround-entry", patientCategory);
Expand All @@ -118,7 +121,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.clickClearButtonInElement("#diastolic");
patientLogupdate.typeDiastolic(patientModifiedDiastolic);
cy.submitButton("Continue");
cy.verifyNotification("Consultation Updates details updated successfully");
cy.verifyNotification("Normal Log Updates details updated successfully");
patientLogupdate.clickLogupdateCard("#dailyround-entry", patientCategory);
cy.verifyContentPresence("#consultation-preview", [
patientModifiedDiastolic,
Expand Down Expand Up @@ -148,12 +151,44 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.wait(2000);
cy.verifyNotification("Consultation Updates details created successfully");
cy.verifyNotification("Normal Log Updates details created successfully");
// Verify the card content
cy.get("#basic-information").scrollIntoView();
cy.verifyContentPresence("#basic-information", [additionalSymptoms]);
});

it("Create a normal log update to verify MEWS Score Functionality", () => {
patientPage.visitPatient(domicilaryPatient);
patientConsultationPage.clickEditConsultationButton();
patientConsultationPage.selectPatientSuggestion("Domiciliary Care");
cy.submitButton("Update Consultation");
cy.verifyNotification("Consultation updated successfully");
cy.closeNotification();
patientLogupdate.clickLogupdate();
// Verify the MEWS Score reflection
patientLogupdate.selectPatientCategory(patientCategory);
patientLogupdate.typeSystolic(patientSystolic);
patientLogupdate.typeDiastolic(patientDiastolic);
patientLogupdate.typePulse(patientPulse);
patientLogupdate.typeTemperature(patientTemperature);
patientLogupdate.typeRespiratory(patientRespiratory);
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Normal Log Updates details created successfully");
cy.closeNotification();
cy.verifyContentPresence("#consultation-buttons", ["9"]);
// Verify the Incomplete data will give blank info
patientLogupdate.clickLogupdate();
patientLogupdate.selectPatientCategory(patientCategory);
patientLogupdate.typeSystolic(patientSystolic);
patientLogupdate.typeDiastolic(patientDiastolic);
patientLogupdate.typePulse(patientPulse);
cy.submitButton("Save");
cy.verifyNotification("Normal Log Updates details created successfully");
cy.closeNotification();
cy.verifyContentPresence("#consultation-buttons", ["-"]);
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
15 changes: 0 additions & 15 deletions cypress/e2e/patient_spec/patient_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import PatientPrescription from "../../pageobject/Patient/PatientPrescription";

describe("Patient", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientConsultationPage = new PatientConsultationPage();
const patientPrescription = new PatientPrescription();

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand Down Expand Up @@ -45,19 +43,6 @@ describe("Patient", () => {
cy.verifyNotification("Note added successfully");
});

it("Edit prescription for an already created patient", () => {
patientPage.visitPatient("Dummy Patient 4");
patientPrescription.visitEditPrescriptionPage();
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine("DOLO");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
49 changes: 49 additions & 0 deletions cypress/e2e/patient_spec/patient_prescription.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import PatientPrescription from "../../pageobject/Patient/PatientPrescription";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";

const patientPrescription = new PatientPrescription();
const loginPage = new LoginPage();
const patientPage = new PatientPage();

describe("Patient Medicine Administration", () => {
before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/patients");
});

it("Add a new medicine for a patient and verify the duplicate medicine validation", () => {
patientPage.visitPatient("Dummy Patient 4");
patientPrescription.visitMedicineTab();
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine("DOLO");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
// verify the duplicate medicine error message
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine("DOLO");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification(
"Medicine - This medicine is already prescribed to this patient. Please discontinue the existing prescription to prescribe again.",
);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
Loading

0 comments on commit d35e3b0

Please sign in to comment.