Skip to content

Commit

Permalink
Merge pull request #7518 from coronasafe/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
gigincg authored Apr 1, 2024
2 parents 56209d2 + f96d5ca commit 5268cf1
Show file tree
Hide file tree
Showing 135 changed files with 1,533 additions and 794 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/patient_spec/patient_consultation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ describe("Patient Consultation in multiple combination", () => {
cy.verifyNotification(
"Create Diagnoses - Atleast one diagnosis is required"
);
cy.closeNotification();
patientConsultationPage.selectPatientDiagnosis(
diagnosis4,
"add-icd11-diagnosis-as-confirmed"
Expand Down
3 changes: 3 additions & 0 deletions cypress/e2e/patient_spec/patient_logupdate.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientConsultationPage.selectPatientSuggestion("Domiciliary Care");
cy.submitButton("Update Consultation");
cy.verifyNotification("Consultation updated successfully");
cy.closeNotification();
patientLogupdate.clickLogupdate();
patientLogupdate.typePhysicalExamination(physicalExamination);
patientLogupdate.typeOtherDetails(otherExamination);
Expand Down Expand Up @@ -79,6 +80,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientConsultationPage.selectPatientSuggestion("Domiciliary Care");
cy.submitButton("Update Consultation");
cy.verifyNotification("Consultation updated successfully");
cy.closeNotification();
patientLogupdate.clickLogupdate();
patientLogupdate.typePhysicalExamination(physicalExamination);
patientLogupdate.typeOtherDetails(otherExamination);
Expand All @@ -95,6 +97,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
cy.get("#consciousness_level-2").click();
cy.submitButton("Save");
cy.verifyNotification("Consultation Updates details created successfully");
cy.closeNotification();
// edit the card and verify the data.
patientLogupdate.clickLogupdateCard("#dailyround-entry", patientCategory);
cy.verifyContentPresence("#consultation-preview", [
Expand Down
16 changes: 9 additions & 7 deletions cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("User Creation", () => {
"Please select the User Type",
"Please enter valid phone number",
"Please enter the username",
"Please enter date in YYYY/MM/DD format",
"Please enter date in DD/MM/YYYY format",
"Please enter the password",
"Confirm password is required",
"First Name is required",
Expand All @@ -52,10 +52,7 @@ describe("User Creation", () => {
const EXPECTED_PROFILE_ERROR_MESSAGES = [
"Field is required",
"Field is required",
"This field is required",
"Please enter valid phone number",
"This field is required",
"This field is required",
];

before(() => {
Expand All @@ -81,7 +78,6 @@ describe("User Creation", () => {
"District Editted"
);
userCreationPage.typeIntoElementByIdPostClear("lastName", "Cypress");
userCreationPage.typeIntoElementByIdPostClear("age", "22");
userCreationPage.selectDropdownOption("gender", "Male");
userCreationPage.typeIntoElementByIdPostClear(
"phoneNumber",
Expand All @@ -93,6 +89,10 @@ describe("User Creation", () => {
);
userCreationPage.typeIntoElementByIdPostClear("email", "[email protected]");
userCreationPage.typeIntoElementByIdPostClear("weekly_working_hours", "14");
userCreationPage.typeIntoElementByIdPostClearDob(
"date_of_birth",
"01011998"
);
userCreationPage.clickElementById("submit");
userCreationPage.verifyElementContainsText(
"contactno-profile-details",
Expand All @@ -110,7 +110,10 @@ describe("User Creation", () => {
"lastname-profile-details",
"Cypress"
);
userCreationPage.verifyElementContainsText("age-profile-details", "22");
userCreationPage.verifyElementContainsText(
"date_of_birth-profile-details",
"01/01/1998"
);
userCreationPage.verifyElementContainsText(
"emailid-profile-details",
"[email protected]"
Expand All @@ -130,7 +133,6 @@ describe("User Creation", () => {
userCreationPage.clickElementById("edit-cancel-profile-button");
userCreationPage.clearIntoElementById("firstName");
userCreationPage.clearIntoElementById("lastName");
userCreationPage.clearIntoElementById("age");
userCreationPage.clearIntoElementById("phoneNumber");
userCreationPage.clearIntoElementById("altPhoneNumber");
userCreationPage.clearIntoElementById("weekly_working_hours");
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/users_spec/user_profile.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Manage User Profile", () => {
const userProfilePage = new UserProfilePage();
const manageUserPage = new ManageUserPage();

const age = "30";
const date_of_birth = "01011999";
const gender = "Male";
const email = "[email protected]";
const phone = "+918899887788";
Expand All @@ -32,10 +32,10 @@ describe("Manage User Profile", () => {
cy.awaitUrl("/user/profile");
});

it("Set Age, Gender, Email, Phone and Working Hours for a user and verify its reflection in user profile", () => {
it("Set Dob, Gender, Email, Phone and Working Hours for a user and verify its reflection in user profile", () => {
userProfilePage.clickEditProfileButton();

userProfilePage.typeAge(age);
userProfilePage.typedate_of_birth(date_of_birth);
userProfilePage.selectGender(gender);
userProfilePage.typeEmail(email);
userProfilePage.typePhone(phone);
Expand All @@ -49,7 +49,7 @@ describe("Manage User Profile", () => {

cy.verifyNotification("Details updated successfully");

userProfilePage.assertAge(age);
userProfilePage.assertdate_of_birth("01/01/1999");
userProfilePage.assertGender(gender);
userProfilePage.assertEmail(email);
userProfilePage.assertPhone(phone);
Expand Down
5 changes: 4 additions & 1 deletion cypress/pageobject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export class UserCreationPage {
.click()
.type(value);
}

typeIntoElementByIdPostClearDob(elementId: string, value: string) {
cy.get("#" + elementId).click();
cy.get("#date-input").clear().type(value);
}
clearIntoElementById(elementId: string) {
cy.get("#" + elementId)
.click()
Expand Down
15 changes: 11 additions & 4 deletions cypress/pageobject/Users/UserProfilePage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { cy } from "local-cypress";

export default class UserProfilePage {
assertVideoConnectLink(link: string) {
cy.get("#videoconnectlink-profile-details").should("contain.text", link);
Expand All @@ -15,8 +17,10 @@ export default class UserProfilePage {
cy.get("#submit").click();
}

typeAge(age: string) {
cy.get("#age").click().clear().type(age);
typedate_of_birth(date_of_birth: string) {
//check
cy.get("#date_of_birth").click();
cy.get("#date-input").clear().type(date_of_birth);
}

selectGender(gender: string) {
Expand Down Expand Up @@ -55,8 +59,11 @@ export default class UserProfilePage {
.type(medicalCouncilRegistration);
};

assertAge(age: string) {
cy.get("#age-profile-details").should("contain.text", age);
assertdate_of_birth(date_of_birth: string) {
cy.get("#date_of_birth-profile-details").should(
"contain.text",
date_of_birth
);
}

assertGender(gender: string) {
Expand Down
3 changes: 1 addition & 2 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ Cypress.Commands.add(
);

Cypress.Commands.add("verifyNotification", (text) => {
cy.get(".pnotify-container").should("exist").contains(text);
return cy.get(".pnotify-container").contains(text).click({ force: true });
return cy.get(".pnotify-container").should("exist").contains(text);
});

Cypress.on("uncaught:exception", () => {
Expand Down
94 changes: 94 additions & 0 deletions plugins/treeShakeCareIcons.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { Plugin } from "vite";
import * as fs from "fs";
import * as path from "path";
import * as glob from "glob";

/**
* Interface defining options for the treeShakeUniconPathsPlugin.
*
* @interface TreeShakeUniconPathsPluginOptions
* @property {string[]} iconWhitelist - An array of icon names to always include, even if not found in code.
*/

export interface TreeShakeCareIconsOptions {
iconWhitelist: string[];
}

/**
* Creates a Webpack plugin that tree-shakes unused Unicon paths from UniconPaths.json in production builds.
*
* @param {TreeShakeCareIconsOptions} [options] - Optional configuration options. Defaults to an empty iconWhitelist.
* @returns {Plugin} Webpack plugin object.
*/

export function treeShakeCareIcons(
options: TreeShakeCareIconsOptions = { iconWhitelist: [] }
): Plugin {
const rootDir = path.resolve(__dirname, ".."); // update this if moving this code to a different file
const lineIconNameRegex = /"l-[a-z]+(?:-[a-z]+)*"/g;
const allUniconPaths = JSON.parse(
fs.readFileSync(
path.resolve(rootDir, "src/CAREUI/icons/UniconPaths.json"),
"utf8"
)
);

// Extracts icon names from a given file's content.
// Returns an array of icon names like ["l-eye", "l-sync", "l-hearbeat"]
function extractCareIconNames(file: string): string[] {
const fileContent = fs.readFileSync(file, "utf8");

const lineIconNameMatches = fileContent.match(lineIconNameRegex) || [];

const lineIconNames = lineIconNameMatches.map(
(lineIconName) => lineIconName.slice(1, -1) // remove quotes
);

return lineIconNames;
}
// Finds all used icon names within the project's source files (`.tsx` or `.res` extensions).
function getAllUsedIconNames() {
const files = glob.sync(path.resolve(rootDir, "src/**/*.{tsx,res}"));
const usedIconsArray: string[] = [];

files.forEach((file) => {
const iconNames = extractCareIconNames(file);
usedIconsArray.push(...iconNames);
});

return new Set(usedIconsArray);
}
// Generates a map of used icon names to their paths from UniconPaths.json, including any whitelisted icons.
function getTreeShakenUniconPaths() {
const usedIcons = [...getAllUsedIconNames(), ...options.iconWhitelist];
const treeshakenCareIconPaths = {};

for (const iconName of usedIcons) {
const path = allUniconPaths[iconName];
if (path === undefined) {
throw new Error(`Icon ${iconName} is not found in UniconPaths.json`);
} else {
treeshakenCareIconPaths[iconName] = path;
}
}

return treeshakenCareIconPaths;
}

return {
name: "tree-shake-care-icons",
transform(_src, id) {
if (process.env.NODE_ENV !== "production") {
return;
}

// Replace the UniconPaths with the tree-shaken version
if (id.endsWith("UniconPaths.json")) {
return {
code: `export default ${JSON.stringify(getTreeShakenUniconPaths())}`,
map: null,
};
}
},
};
}
4 changes: 2 additions & 2 deletions src/CAREUI/display/RecordMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const RecordMeta = ({
{user && !inlineUser && (
<span className="flex items-center gap-1">
by
<CareIcon className="care-l-user" />
<CareIcon icon="l-user" />
{formatName(user)}
{isOnline && (
<div className="h-1.5 w-1.5 rounded-full bg-primary-400" />
Expand All @@ -61,7 +61,7 @@ const RecordMeta = ({
{prefix}
{child}
{user && inlineUser && <span>by</span>}
{user && !inlineUser && <CareIcon className="care-l-user" />}
{user && !inlineUser && <CareIcon icon="l-user" />}
{user && inlineUser && (
<span className="font-medium">{formatName(user)}</span>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/display/SubHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function SubHeading(props: Props) {
</span>
{props.lastModified && (
<div className="ml-3 flex flex-row gap-2 text-xs font-medium text-gray-600">
<CareIcon className="care-l-history-alt text-sm" />
<CareIcon icon="l-history-alt" className="text-sm" />
<RecordMeta time={props.lastModified} prefix="Last modified" />
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/CAREUI/icons/CareIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import iconData from "./UniconPaths.json";
export type IconName = keyof typeof iconData;

export interface CareIconProps {
icon?: IconName;
icon: IconName;
className?: string | undefined;
onClick?: React.MouseEventHandler<HTMLSpanElement> | undefined;
id?: string;
Expand All @@ -16,7 +16,7 @@ export interface CareIconProps {
* ### CARE's Official Icon Library.
* @param className icon class name
* @returns icon component
* @example ```<CareIcon className="care-l-hospital" /> ```
* @example ```<CareIcon icon="l-hospital"/> ```
*
* @see [icon library](https://iconscout.com/unicons/)
*/
Expand Down
4 changes: 2 additions & 2 deletions src/CAREUI/interactive/FiltersSlideover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function FiltersSlideover({
onClick={onClear}
id="clear-filter"
>
<CareIcon className="care-l-filter-slash text-lg" />
<CareIcon icon="l-filter-slash" className="text-lg" />
<span>{t("clear")}</span>
</ButtonV2>
<ButtonV2 ghost onClick={onApply} id="apply-filter">
Expand All @@ -62,7 +62,7 @@ export const AdvancedFilterButton = ({ onClick }: { onClick: () => void }) => {
onClick={onClick}
id="advanced-filter"
>
<CareIcon className="care-l-filter" />
<CareIcon icon="l-filter" />
<span className="py-0.5">{t("advanced_filters")}</span>
</ButtonV2>
);
Expand Down
3 changes: 2 additions & 1 deletion src/CAREUI/interactive/LegendInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export default function LegendInput(props: InputProps) {
onClick={() => setShowPassword(!showPassword)}
>
<CareIcon
className={`care-l-eye${showPassword ? "" : "-slash"} text-lg`}
icon={showPassword ? "l-eye" : "l-eye-slash"}
className="text-lg"
/>
</button>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/interactive/SlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function SlideOver({
onCloseClick && onCloseClick();
}}
>
<CareIcon className="care-l-arrow-left" />
<CareIcon icon="l-arrow-left" />
</button>
<div className="flex w-full">
<h1 className="w-full text-xl font-black">{title}</h1>
Expand Down
17 changes: 16 additions & 1 deletion src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ export const GENDER: { [key: number]: string } = GENDER_TYPES.reduce(
);

export type CameraPTZ = {
icon?: string;
icon?: IconName;
label: string;
action: string;
loadingLabel?: string;
Expand Down Expand Up @@ -1172,6 +1172,21 @@ export const IN_LANDLINE_AREA_CODES = [
"891",
"4822",
];

export const CONSENT_TYPE_CHOICES = [
{ id: 1, text: "Consent for admission" },
{ id: 2, text: "Patient Code Status" },
{ id: 3, text: "Consent for procedure" },
{ id: 4, text: "High risk consent" },
{ id: 5, text: "Others" },
];

export const CONSENT_PATIENT_CODE_STATUS_CHOICES = [
{ id: 1, text: "Do Not Hospitalise (DNH)" },
{ id: 2, text: "Do Not Resuscitate (DNR)" },
{ id: 3, text: "Comfort Care Only" },
{ id: 4, text: "Active treatment (Default)" },
];
export const OCCUPATION_TYPES = [
{ id: 1, text: "Student", value: "STUDENT" },
{
Expand Down
Loading

0 comments on commit 5268cf1

Please sign in to comment.