Skip to content

Commit

Permalink
Merge branch 'develop' into issue/10215/newline-questionnaire
Browse files Browse the repository at this point in the history
  • Loading branch information
rajku-dev authored Jan 27, 2025
2 parents c85e1af + a481488 commit 654626f
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"useTabs": false,
"tabWidth": 2,
"semi": true,
"endOfLine": "lf",
"endOfLine": "auto",
"jsxSingleQuote": false,
"arrowParens": "always",
"tailwindFunctions": ["classNames"],
Expand Down
29 changes: 25 additions & 4 deletions care.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,31 @@ const careConfig = {
},

careApps: env.REACT_ENABLED_APPS
? env.REACT_ENABLED_APPS.split(",").map((app) => ({
branch: app.split("@")[1],
package: app.split("@")[0],
}))
? env.REACT_ENABLED_APPS.split(",").map((app) => {
const [module, cdn] = app.split("@");
const [org, repo] = module.split("/");

if (!org || !repo) {
throw new Error(
`Invalid plug configuration: ${module}. Expected 'org/repo@url'.`,
);
}

let url = "";
if (!cdn) {
url = `https://${org}.github.io/${repo}`;
}

if (!url.startsWith("http")) {
url = `${cdn.includes("localhost") ? "http" : "https"}://${cdn}`;
}

return {
url: new URL(url).toString(),
name: repo,
package: module,
};
})
: [],

plotsConfigUrl:
Expand Down
31 changes: 31 additions & 0 deletions cypress/e2e/patient_spec/patient_encounter.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { PatientEncounter } from "pageObject/Patients/PatientEncounter";
import { FacilityCreation } from "pageObject/facility/FacilityCreation";

const facilityCreation = new FacilityCreation();
const patientEncounter = new PatientEncounter();

describe("Patient Encounter Questionnaire", () => {
beforeEach(() => {
// Login and set up any necessary test state
cy.visit("/login");
});

it("Create a new ABG questionnaire and verify the values", () => {
const abgValues = {
pco2: "120",
po2: "80",
};
cy.loginByApi("devnurse");
facilityCreation.selectFacility("GHC Trikaripur");

// Chain the methods instead of multiple separate calls
patientEncounter
.navigateToEncounters()
.openFirstEncounterDetails()
.clickUpdateEncounter()
.addQuestionnaire("Arterial Blood Gas")
.fillQuestionnaire(abgValues)
.submitQuestionnaire()
.verifyOverviewValues(Object.values(abgValues));
});
});
4 changes: 4 additions & 0 deletions cypress/fixtures/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
"staff": {
"username": "nihalstaff",
"password": "Test@123"
},
"devnurse": {
"username": "dev-nurse",
"password": "Test@123"
}
}
72 changes: 72 additions & 0 deletions cypress/pageObject/Patients/PatientEncounter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
export class PatientEncounter {
// Navigation
navigateToEncounters() {
cy.get('[data-sidebar="content"]').contains("Encounters").click();
return this;
}

openFirstEncounterDetails() {
cy.get('[data-cy="encounter-list-cards"]')
.first()
.contains("View Details")
.click();
return this;
}

clickUpdateEncounter() {
cy.verifyAndClickElement('[data-cy="update-encounter-button"]', "Update");
cy.verifyAndClickElement(
'[data-cy="update-encounter-option"]',
"Update Encounter",
);
return this;
}

// Questionnaire actions
addQuestionnaire(questionnaireName: string) {
cy.get('[data-cy="add-questionnaire-button"]').click();
cy.get('[role="dialog"] input')
.should("be.visible")
.type(questionnaireName);
cy.get('[role="dialog"] button')
.contains(questionnaireName)
.should("be.visible")
.click();
return this;
}

fillQuestionnaire(answers: Record<string, string>) {
Object.entries(answers).forEach(([field, value]) => {
// Handle both text inputs and select dropdowns
cy.get(`[data-cy="question-${field}"]`).then(($el) => {
if ($el.is("select")) {
cy.wrap($el).select(value);
} else {
cy.wrap($el).type(value);
}
});
});
return this;
}

submitQuestionnaire() {
this.clickSubmitQuestionnaire();
this.verifyQuestionnaireSubmission();
return this;
}

clickSubmitQuestionnaire() {
cy.clickSubmitButton("Submit");
return this;
}

verifyQuestionnaireSubmission() {
cy.verifyNotification("Questionnaire submitted successfully");
return this;
}

verifyOverviewValues(expectedValues: string[]) {
cy.verifyContentPresence('[data-cy="encounter-overview"]', expectedValues);
return this;
}
}
12 changes: 11 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"i18next": "^24.2.1",
"i18next-browser-languagedetector": "^8.0.2",
"i18next-http-backend": "^3.0.1",
"i18next-resources-to-backend": "^1.2.1",
"input-otp": "^1.4.2",
"lodash-es": "^4.17.21",
"lucide-react": "^0.473.0",
Expand Down Expand Up @@ -140,7 +141,7 @@
"@types/google.maps": "^3.58.1",
"@types/jsdom": "^21.1.7",
"@types/markdown-it": "^14.1.2",
"@types/node": "^22.9.0",
"@types/node": "^22.10.10",
"@types/react": "^18.3.12",
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-csv": "^1.1.10",
Expand Down
Loading

0 comments on commit 654626f

Please sign in to comment.