Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress test for patient discharge #7573

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions cypress/e2e/patient_spec/patient_discharge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import PatientDischarge from "../../pageobject/Patient/PatientDischarge";
import PatientPrescription from "../../pageobject/Patient/PatientPrescription";

describe("Patient Discharge based on multiple reason", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientDischarge = new PatientDischarge();
const patientPrescription = new PatientPrescription();

before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

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

it("Discharge a recovered patient with all fields", () => {
patientPage.visitPatient("Dummy Patient 6");
patientDischarge.clickDischarge();
patientDischarge.selectDischargeReason("Recovered");
patientDischarge.typeDischargeNote("Discharge Advice");
// Prescribe a medicine for the patient
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine("ZOLE");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.submitButton();
cy.verifyNotification("Patient Discharged Successfully");
// Verify the dashboard and discharge information
});

afterEach(() => {
cy.saveLocalStorage();
});
});
14 changes: 14 additions & 0 deletions cypress/pageobject/Patient/PatientDischarge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class PatientDischarge {
clickDischarge() {
cy.clickAndSelectOption("#show-more", "Discharge from CARE");
}

selectDischargeReason(reason: string) {
cy.clickAndSelectOption("#discharge_reason", reason);
}

typeDischargeNote(note: string) {
cy.get("#discharge_notes").type(note);
}
}
export default PatientDischarge;
2 changes: 1 addition & 1 deletion src/CAREUI/display/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export default function Card(
props: {
children?: ReactNode;
} & HTMLAttributes<HTMLDivElement>,
} & HTMLAttributes<HTMLDivElement>

Check failure on line 6 in src/CAREUI/display/Card.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
) {
const { children, ...rest } = props;
return (
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/display/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
custom: "",
}[variant],

props.className,
props.className

Check failure on line 46 in src/CAREUI/display/Chip.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)}
title={props.tooltip}
>
Expand Down
4 changes: 2 additions & 2 deletions src/CAREUI/display/NetworkSignal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
strength === 0 && "text-danger-500",
strength === 1 && "text-danger-500",
strength === 2 && "text-warning-500",
strength === 3 && "text-primary-500",
strength === 3 && "text-primary-500"

Check failure on line 26 in src/CAREUI/display/NetworkSignal.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)}
>
<div className="flex items-end gap-0.5 p-2">
Expand All @@ -45,7 +45,7 @@
i === 2 && "h-[15px]",

// Whether to infill with strength color or not
strength > i ? "bg-current" : "bg-zinc-600",
strength > i ? "bg-current" : "bg-zinc-600"

Check failure on line 48 in src/CAREUI/display/NetworkSignal.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)}
/>
))
Expand Down
6 changes: 3 additions & 3 deletions src/CAREUI/display/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<div
className={classNames(
props.isLast ? "h-6" : "-bottom-6",
"absolute left-0 top-0 flex w-6 justify-center",
"absolute left-0 top-0 flex w-6 justify-center"

Check failure on line 60 in src/CAREUI/display/Timeline.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)}
>
<div className="w-px bg-gray-300" />
Expand All @@ -66,14 +66,14 @@
<div
className={classNames(
props.className,
"group flex w-full flex-col items-start gap-y-1",
"group flex w-full flex-col items-start gap-y-1"

Check failure on line 69 in src/CAREUI/display/Timeline.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)}
>
<div className="relative flex w-full justify-between gap-x-4">
<div
className={classNames(
"flex w-full gap-x-4",
props.event.cancelled && "line-through",
props.event.cancelled && "line-through"

Check failure on line 76 in src/CAREUI/display/Timeline.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)}
>
{props.title || (
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/icons/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
const el = document.createElementNS(xmlns, "svg");
el.setAttribute(
"class",
className.replace("care", "care-svg-icon__baseline"),
className.replace("care", "care-svg-icon__baseline")

Check failure on line 21 in src/CAREUI/icons/icon.js

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
);
el.setAttribute("role", "img");
el.setAttribute("xmlns", xmlns);
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/interactive/KeyboardShortcut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<span
className={classNames(
"tooltip-text flex items-center gap-0.5 text-xs",
props.tooltipClassName || "tooltip-bottom",
props.tooltipClassName || "tooltip-bottom"

Check failure on line 24 in src/CAREUI/interactive/KeyboardShortcut.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)}
>
<span className="px-1 font-bold">{props.helpText}</span>
Expand Down
4 changes: 2 additions & 2 deletions src/CAREUI/interactive/LegendInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
(focused || ref.current?.value) &&
props.size === "small" &&
"-top-[7px]",
props.error && "text-red-500",
props.error && "text-red-500"

Check failure on line 100 in src/CAREUI/interactive/LegendInput.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
)}
>
{props.legend}
Expand Down Expand Up @@ -134,7 +134,7 @@
props.size === "large" && "px-5 py-4 text-lg",
props.type === "PASSWORD" && "pr-10",
props.error && "border-red-500",
props.className,
props.className
)}
/>
{props.type === "PASSWORD" && (
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/interactive/ScrollOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function ScrollOverlay(props: Props) {
<div
className={classNames(
"sticky inset-x-0 -bottom-3.5 z-10 flex items-end justify-center bg-gradient-to-t from-gray-900/90 to-transparent text-white transition-all duration-500 ease-in-out md:bottom-0",
hasScrollContent ? "h-16 opacity-75" : "h-0 opacity-0",
hasScrollContent ? "h-16 opacity-75" : "h-0 opacity-0"
)}
>
{hasScrollContent && props.overlay}
Expand Down
6 changes: 3 additions & 3 deletions src/CAREUI/interactive/SlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function SlideOver({
<div
className={classNames(
"fixed transition-all",
backdropBlur && "inset-0 bg-black/75 backdrop-blur-sm",
backdropBlur && "inset-0 bg-black/75 backdrop-blur-sm"
)}
/>
</Transition.Child>
Expand All @@ -94,7 +94,7 @@ export default function SlideOver({
className={classNames(
"pointer-events-auto fixed",
directionClasses[slideFrom].stick,
!onlyChild && "md:p-2",
!onlyChild && "md:p-2"
)}
>
{onlyChild ? (
Expand All @@ -104,7 +104,7 @@ export default function SlideOver({
className={classNames(
"flex flex-col bg-white md:rounded-xl",
directionClasses[slideFrom].proportions,
dialogClass,
dialogClass
)}
>
<div className="flex items-center gap-2 p-2 pt-4">
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/interactive/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function Switch<T extends string>({
size === "lg" && "px-4 py-3 text-base",
props.selected === tab
? "border-primary-500 bg-primary-500 font-semibold text-white hover:bg-primary-600 focus:border-primary-500 focus:ring-primary-500"
: "border-gray-400 bg-gray-50 hover:bg-gray-200 focus:border-primary-500 focus:ring-primary-500",
: "border-gray-400 bg-gray-50 hover:bg-gray-200 focus:border-primary-500 focus:ring-primary-500"
)}
onClick={() => props.onChange(tab as T)}
>
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface Props<TItem> extends QueryOptions<PaginatedResponse<TItem>> {
perPage?: number;
children: (
ctx: PaginatedListContext<TItem>,
query: ReturnType<typeof useQuery<PaginatedResponse<TItem>>>,
query: ReturnType<typeof useQuery<PaginatedResponse<TItem>>>
) => JSX.Element | JSX.Element[];
}

Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/misc/ThemedFavicon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function ThemedFavicon() {
useEffect(() => {
const darkThemeMq = window.matchMedia("(prefers-color-scheme: dark)");
const favicon = document.querySelector(
"link[rel~='icon']",
"link[rel~='icon']"
) as HTMLLinkElement;

favicon.href = darkThemeMq.matches ? "/favicon-light.ico" : "/favicon.ico";
Expand Down
4 changes: 2 additions & 2 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ export const CAMERA_TYPE = [

export const GENDER: { [key: number]: string } = GENDER_TYPES.reduce(
(acc, curr) => ({ ...acc, [curr.id]: curr.text }),
{},
{}
);

export type CameraPTZ = {
Expand Down Expand Up @@ -1013,7 +1013,7 @@ export const XLSXAssetImportSchema = {
if (!ip) return null;
const isValid =
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(
ip,
ip
);

if (!isValid) {
Expand Down
8 changes: 4 additions & 4 deletions src/Common/hooks/useAsyncOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface IUseAsyncOptionsArgs {
*/
export function useAsyncOptions<T extends Record<string, unknown>>(
uniqueKey: keyof T,
args?: IUseAsyncOptionsArgs,
args?: IUseAsyncOptionsArgs
) {
const dispatch = useDispatch<any>();
const [queryOptions, setQueryOptions] = useState<T[]>([]);
Expand All @@ -47,18 +47,18 @@ export function useAsyncOptions<T extends Record<string, unknown>>(
const res = await dispatch(action);
if (res?.data)
setQueryOptions(
args?.queryResponseExtractor?.(res.data) ?? (res.data as T[]),
args?.queryResponseExtractor?.(res.data) ?? (res.data as T[])
);
setIsLoading(false);
}, args?.debounceInterval ?? 300),
[dispatch, args?.debounceInterval],
[dispatch, args?.debounceInterval]
);

const mergeValueWithQueryOptions = (selected?: T[]) => {
return mergeQueryOptions(
selected ?? [],
queryOptions,
(obj) => obj[uniqueKey],
(obj) => obj[uniqueKey]
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/Common/hooks/useAuthUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useAuthContext = () => {
const ctx = useContext(AuthUserContext);
if (!ctx) {
throw new Error(
"'useAuthContext' must be used within 'AuthUserProvider' only",
"'useAuthContext' must be used within 'AuthUserProvider' only"
);
}
return ctx;
Expand Down
2 changes: 1 addition & 1 deletion src/Common/hooks/useBreakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const BREAKPOINT_WIDTH: Record<Breakpoints, number> = {
* @returns The value mapped to the current breakpoint.
*/
export default function useBreakpoints<T>(
map: Partial<Record<Breakpoints, T>> & { default: T },
map: Partial<Record<Breakpoints, T>> & { default: T }
) {
const { width } = useWindowDimensions();

Expand Down
6 changes: 3 additions & 3 deletions src/Common/hooks/useExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function useExport() {
const exportCSV = async (
filenamePrefix: string,
action: any,
parse = (data: string) => data,
parse = (data: string) => data
) => {
setIsExporting(true);

Expand All @@ -40,7 +40,7 @@ export default function useExport() {
const exportJSON = async (
filenamePrefix: string,
action: any,
parse = (data: string) => data,
parse = (data: string) => data
) => {
setIsExporting(true);

Expand All @@ -62,7 +62,7 @@ export default function useExport() {
action: any,
filePrefix = "export",
type = "csv",
parse = (data: string) => data,
parse = (data: string) => data
) => {
if (!action) return;

Expand Down
14 changes: 7 additions & 7 deletions src/Common/hooks/useFeedPTZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface UseMSEMediaPlayerReturnType {
getPTZPayload: (
action: PTZ,
precision?: number,
value?: number,
value?: number
) => PTZPayload;
getCameraStatus: (options: IOptions) => void;
getPresets: (options: IOptions) => void;
Expand Down Expand Up @@ -80,7 +80,7 @@ const getCameraStatus =
action: {
type: "get_status",
},
}),
})
);
resp &&
(resp.status === 200
Expand All @@ -97,7 +97,7 @@ const getPresets =
action: {
type: "get_presets",
},
}),
})
);
resp &&
(resp.status === 200
Expand All @@ -119,7 +119,7 @@ const gotoPreset =
type: "goto_preset",
data: payload,
},
}),
})
);
resp &&
(resp.status === 200
Expand All @@ -137,7 +137,7 @@ const absoluteMove =
type: "absolute_move",
data: payload,
},
}),
})
);
resp &&
(resp.status === 200
Expand All @@ -155,7 +155,7 @@ const relativeMove =
type: "relative_move",
data: payload,
},
}),
})
);
resp &&
(resp.status === 200
Expand All @@ -166,7 +166,7 @@ const relativeMove =
export const getPTZPayload = (
action: PTZ,
precision = 1,
value?: number,
value?: number
): PTZPayload => {
let x = 0;
let y = 0;
Expand Down
Loading
Loading