Skip to content

Commit

Permalink
Merge branch 'develop' into rich-text-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
UdaySagar-Git authored Jun 20, 2024
2 parents 81450b4 + c8a579a commit 6600560
Show file tree
Hide file tree
Showing 48 changed files with 767 additions and 538 deletions.
49 changes: 31 additions & 18 deletions .github/workflows/auto-testing-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,37 @@ jobs:
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';
const comment = context.payload.comment;
const review = context.payload.review;
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 (pr) {
const isDraft = pr.draft;
const isReadyForTestingComment = comment && comment.body.includes('ready for testing');
const isChangesRequired = review && 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.'
});
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.'
});
if (pr.labels.some(label => label.name === 'needs testing')) {
await github.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
name: 'needs testing'
});
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches:
- develop
- master
- staging
workflow_dispatch:

jobs:
Expand Down
10 changes: 2 additions & 8 deletions .storybook/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
import { defineConfig } from "vite";

export default defineConfig({
esbuild: {
loader: "tsx",
include: [/src\/.*\.[tj]sx?$/, /.storybook\/.*\.[tj]sx?$/],
},
});
/** @type {import('vite').UserConfig} */
export default {};
3 changes: 3 additions & 0 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe("Facility Manage Functions", () => {
const loginPage = new LoginPage();
const facilityManage = new FacilityManage();
const facilityPage = new FacilityPage();
const facilityName = "Dummy Facility 40";
const facilityMiddlewareUpdateButton = "Update";
const facilityMiddleware = "dev-middleware.coronasafe.live";
const facilityUpdatedMiddleware = "updated.coronasafe.live";
Expand Down Expand Up @@ -35,6 +36,8 @@ describe("Facility Manage Functions", () => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
facilityPage.typeFacilitySearch(facilityName);
facilityPage.verifyFacilityBadgeContent(facilityName);
facilityPage.visitAlreadyCreatedFacility();
});

Expand Down
86 changes: 80 additions & 6 deletions cypress/e2e/patient_spec/patient_prescription.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
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();
const medicineName = "DOLO";
const medicineNameOne = "DOLO";
const medicineNameTwo = "FDEP PLUS";
const medicineBaseDosage = "4";
const medicineTargetDosage = "9";
const medicineFrequency = "Twice daily";
const medicineAdministerNote = "Medicine Administration Note";
const medicineIndicator = "Test Indicator";

describe("Patient Medicine Administration", () => {
before(() => {
Expand All @@ -23,14 +26,85 @@ describe("Patient Medicine Administration", () => {
cy.awaitUrl("/patients");
});

it("Add a new medicine | Verify the Edit and Discontinue Medicine workflow |", () => {
patientPage.visitPatient("Dummy Patient 9");
patientPrescription.visitMedicineTab();
patientPrescription.visitEditPrescription();
// Add a normal Medicine to the patient
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
// Edit the existing medicine & Verify they are properly moved to discontinue position
patientPrescription.clickReturnToDashboard();
patientPrescription.visitMedicineTab();
cy.verifyAndClickElement("#0", medicineNameOne);
cy.verifyContentPresence("#submit", ["Discontinue"]); // To verify the pop-up is open
cy.submitButton("Edit");
patientPrescription.enterDosage(medicineTargetDosage);
cy.submitButton("Submit");
cy.verifyNotification("Prescription edited successfully");
cy.closeNotification();
// Discontinue a medicine & Verify the notification
cy.verifyAndClickElement("#0", medicineNameOne);
cy.submitButton("Discontinue");
patientPrescription.enterDiscontinueReason("Medicine is been discontinued");
cy.submitButton("Discontinue");
cy.verifyNotification("Prescription discontinued");
cy.closeNotification();
// verify the discontinue medicine view
cy.verifyContentPresence("#discontinued-medicine", [
"discontinued prescription(s)",
]);
});

it("Add a PRN Prescription medicine | Group Administrate it |", () => {
patientPage.visitPatient("Dummy Patient 6");
patientPrescription.visitMedicineTab();
patientPrescription.visitEditPrescription();
// Add First Medicine
patientPrescription.clickAddPrnPrescriptionButton();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.enterIndicator(medicineIndicator);
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
// Add Second Medicine
patientPrescription.clickAddPrnPrescriptionButton();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineNameTwo);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.enterIndicator(medicineIndicator);
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
patientPrescription.clickReturnToDashboard();
// Group Administer the PRN Medicine
patientPrescription.visitMedicineTab();
patientPrescription.clickAdministerBulkMedicine();
patientPrescription.clickAllVisibleAdministration();
patientPrescription.clickAdministerSelectedMedicine();
cy.verifyNotification("Medicine(s) administered");
cy.closeNotification();
});

it("Add a new titrated medicine for a patient | Individual Administeration |", () => {
patientPage.visitPatient("Dummy Patient 5");
patientPrescription.visitMedicineTab();
patientPrescription.visitEditPrescription();
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineName);
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.clickTitratedDosage();
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.enterTargetDosage(medicineTargetDosage);
Expand All @@ -47,14 +121,14 @@ describe("Patient Medicine Administration", () => {
cy.closeNotification();
// Verify the Reflection on the Medicine
cy.verifyContentPresence("#medicine-preview", [
medicineName,
medicineNameOne,
medicineBaseDosage,
medicineTargetDosage,
]);
patientPrescription.clickReturnToDashboard();
// Go to medicine tab and administer it again
patientPrescription.visitMedicineTab();
cy.verifyAndClickElement("#0", medicineName);
cy.verifyAndClickElement("#0", medicineNameOne);
cy.submitButton("Administer");
patientPrescription.enterAdministerDosage(medicineBaseDosage);
cy.submitButton("Administer Medicine");
Expand All @@ -68,7 +142,7 @@ describe("Patient Medicine Administration", () => {
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineName);
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
cy.submitButton("Submit");
Expand All @@ -78,7 +152,7 @@ describe("Patient Medicine Administration", () => {
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineName);
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
cy.submitButton("Submit");
Expand Down
7 changes: 6 additions & 1 deletion cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class FacilityPage {
.should("eq", 200);
}

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

visitUpdateFacilityPage(url: string) {
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities");
cy.visit(url);
Expand Down Expand Up @@ -292,8 +297,8 @@ class FacilityPage {
}

selectLocation(location: string) {
cy.intercept("https://maps.googleapis.com/**").as("mapApi");
cy.get("span > svg.care-svg-icon__baseline.care-l-map-marker").click();
cy.intercept("https://maps.googleapis.com/maps/api/mapsjs/*").as("mapApi");
cy.wait("@mapApi").its("response.statusCode").should("eq", 200);
cy.get("input#pac-input").type(location).type("{enter}");
cy.wait(2000);
Expand Down
36 changes: 28 additions & 8 deletions cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cy } from "local-cypress";
export class PatientPrescription {
clickAddPrescription() {
cy.get("#add-prescription").scrollIntoView();
Expand All @@ -7,6 +8,10 @@ export class PatientPrescription {
);
}

clickAddPrnPrescriptionButton() {
cy.contains("button", "Add PRN Prescription").click();
}

interceptMedibase() {
cy.intercept("GET", "**/api/v1/medibase/**").as("getMedibase");
}
Expand All @@ -27,6 +32,15 @@ export class PatientPrescription {
cy.verifyAndClickElement("#administer-medicine", "Administer");
}

clickAdministerBulkMedicine() {
cy.get("#bulk-administer").should("be.visible");
cy.get("#bulk-administer").click();
}

clickAllVisibleAdministration() {
cy.get("#should_administer").should("be.visible").click();
}

selectMedicinebox() {
cy.get(
"div#medicine_object input[placeholder='Select'][role='combobox']",
Expand All @@ -38,9 +52,20 @@ export class PatientPrescription {
}

enterDosage(doseAmount: string) {
cy.get("#base_dosage").clear({ force: true });
cy.get("#base_dosage").click({ force: true });
cy.get("#base_dosage").type(doseAmount, { force: true });
}

enterIndicator(indicator: string) {
cy.get("#indicator").type(indicator);
}

enterDiscontinueReason(reason: string) {
cy.wait(2000);
cy.get("#discontinuedReason").type(reason);
}

enterAdministerDosage(dosage: string) {
cy.get("#dosage").type(dosage);
}
Expand All @@ -64,14 +89,9 @@ export class PatientPrescription {
);
}

discontinuePreviousPrescription() {
cy.intercept(
"POST",
"**/api/v1/consultation/*/prescriptions/*/discontinue/",
).as("deletePrescription");
cy.get("button").contains("Discontinue").click();
cy.get("#submit").contains("Discontinue").click();
cy.wait("@deletePrescription").its("response.statusCode").should("eq", 200);
clickAdministerSelectedMedicine() {
cy.get("#administer-selected-medicine").should("be.visible");
cy.get("#administer-selected-medicine").click();
}

visitMedicineTab() {
Expand Down
1 change: 1 addition & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Cypress.Commands.add("clearAllFilters", () => {
});

Cypress.Commands.add("submitButton", (buttonText = "Submit") => {
cy.get("button[type='submit']").contains(buttonText).scrollIntoView();
cy.get("button[type='submit']").contains(buttonText).click();
});

Expand Down
10 changes: 10 additions & 0 deletions src/Common/hooks/useMSEplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export const useMSEMediaPlayer = ({
if (!mseSourceBuffer.updating) {
if (mseQueue.length > 0) {
const packet = mseQueue.shift();
// Check if SourceBuffer has been removed before appending buffer
if (mseSourceBuffer.removed) {
console.error("Attempted to append to a removed SourceBuffer.");
return;
}
mseSourceBuffer.appendBuffer(packet);
} else {
mseStreamingStarted = false;
Expand All @@ -122,6 +127,11 @@ export const useMSEMediaPlayer = ({

const readPacket = (packet: any) => {
if (!mseStreamingStarted) {
// Check if SourceBuffer has been removed before appending buffer
if (mseSourceBuffer.removed) {
console.error("Attempted to append to a removed SourceBuffer.");
return;
}
mseSourceBuffer.appendBuffer(packet);
mseStreamingStarted = true;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/BloodPressureFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BloodPressure } from "../Patient/models";
type Props = FormFieldBaseProps<BloodPressure>;

export default function BloodPressureFormField(props: Props) {
const field = useFormFieldPropsResolver(props as any);
const field = useFormFieldPropsResolver(props);

const handleChange = (event: FieldChangeEvent<number>) => {
const value: BloodPressure = {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/FilePreviewDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const FilePreviewDialog = (props: FilePreviewProps) => {
<img
src={fileUrl}
alt="file"
className={`${
className={`h-full w-full object-contain ${
zoom_values[file_state.zoom - 1]
} ${getRotationClass(file_state.rotation)}`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type PMJAYPackageItem = {
type Props = FormFieldBaseProps<PMJAYPackageItem>;

export default function PMJAYProcedurePackageAutocomplete(props: Props) {
const field = useFormFieldPropsResolver(props as any);
const field = useFormFieldPropsResolver(props);

const { fetchOptions, isLoading, options } =
useAsyncOptions<PMJAYPackageItem>("code");
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/RouteToFacilitySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const keys = Object.keys(ROUTE_TO_FACILITY_OPTIONS).map((key) =>
type Props = FormFieldBaseProps<keyof typeof ROUTE_TO_FACILITY_OPTIONS>;

export default function RouteToFacilitySelect(props: Props) {
const field = useFormFieldPropsResolver(props as any);
const field = useFormFieldPropsResolver(props);

return (
<SelectFormField
Expand Down
Loading

0 comments on commit 6600560

Please sign in to comment.