Skip to content

Commit

Permalink
fix death_report_spec, facility_spec and user_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed May 31, 2023
1 parent b83c9b6 commit 70a3ead
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 63 deletions.
29 changes: 21 additions & 8 deletions cypress/e2e/death_report_spec/death_report.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cy, it, describe, before, beforeEach } from "local-cypress";
import { before, beforeEach, cy, describe, it } from "local-cypress";

const user = { username: "devdistrictadmin", password: "Coronasafe@123" };
const address = "C-106,\nSector-H,\nAliganj,\nLucknow,\nUttar Pradesh";
Expand All @@ -12,9 +12,10 @@ describe("Death Report", () => {
beforeEach(() => {
cy.restoreLocalStorage();
cy.awaitUrl("/");
cy.intercept("**/api/v1/patient/**").as("getPatients");
cy.get("a").contains("Patients").click({ force: true });
cy.url().should("include", "/patients");
cy.contains("Details").click();
cy.wait("@getPatients").get("a[data-cy=patient]").first().click();
cy.url().then((url) => {
const patient_id = url.split("/")[6];
cy.visit(`/death_report/${patient_id}`, {
Expand All @@ -35,14 +36,24 @@ describe("Death Report", () => {
cy.get("textarea[name='address']").clear().type(address);
cy.get("input[name='phone_number']").clear().type("+919919266674");
cy.get("input[name='is_declared_positive']").clear().type("No");
cy.get("input[name='date_declared_positive']").clear().type("2021-12-01");
cy.get("input[name='date_declared_positive']")
.clear({ force: true })
.type("2021-12-01", { force: true });
cy.get("input[name='test_type']").clear().type("Rapid Antigen");
cy.get("input[name='date_of_test']").clear().type("2021-12-01");
cy.get("input[name='date_of_result']").clear().type("2021-12-01");
cy.get("input[name='date_of_test']")
.clear({ force: true })
.type("2021-12-01", { force: true });
cy.get("input[name='date_of_result']")
.clear({ force: true })
.type("2021-12-01", { force: true });
cy.get("input[name='hospital_tested_in']").clear().type("Apollo Hospital");
cy.get("input[name='hospital_died_in']").clear().type("Apollo Hospital");
cy.get("input[name='date_of_admission']").clear().type("2021-12-01");
cy.get("input[name='date_of_death']").clear().type("2021-12-01");
cy.get("input[name='date_of_admission']")
.clear({ force: true })
.type("2021-12-01", { force: true });
cy.get("input[name='date_of_death']")
.clear({ force: true })
.type("2021-12-01", { force: true });
cy.get("input[name='comorbidities']").clear().type("awesomeness");
cy.get("input[name='history_clinical_course']")
.clear()
Expand All @@ -51,7 +62,9 @@ describe("Death Report", () => {
cy.get("input[name='home_or_cfltc']").clear().type("-");
cy.get("input[name='is_vaccinated']").clear().type("Yes");
cy.get("input[name='kottayam_confirmation_sent']").clear().type("Yes");
cy.get("input[name='kottayam_sample_date']").clear().type("2021-12-01");
cy.get("input[name='kottayam_sample_date']")
.clear({ force: true })
.type("2021-12-01", { force: true });
cy.get("input[name='cause_of_death']")
.clear()
.type("Too awesome for earth");
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/facility_spec/facility.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class facility {

cy.get("input[id=pincode]").should("exist").clear().type(pincode);

cy.get("input[id=phone_number]").should("exist").type(phone);
cy.get("input[name=phone_number]").should("exist").type(phone);

cy.get("input[id=oxygen_capacity]").clear().type(oxygen_capacity);
cy.get("input[id=expected_oxygen_requirement]")
Expand Down
12 changes: 0 additions & 12 deletions cypress/e2e/users_spec/user_crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ describe("Edit Profile Testing", () => {

it("Invalid Whatsapp Number of " + username, () => {
const whatsapp_num = "11111-11111";

cy.get(".flag-dropdown").last().find(".arrow").click();
cy.get("li[data-flag-key='flag_no_84']").click();
cy.get("[placeholder='WhatsApp Number']")
.focus()
.type(`${backspace}${whatsapp_num}`)
Expand All @@ -207,9 +204,6 @@ describe("Edit Profile Testing", () => {

it("Valid Whatsapp Number of " + username, () => {
const whatsapp_num = "91111-11111";

cy.get(".flag-dropdown").last().find(".arrow").click();
cy.get("li[data-flag-key='flag_no_84']").click();
cy.get("[placeholder='WhatsApp Number']")
.focus()
.type(`${backspace}${whatsapp_num}`)
Expand All @@ -227,9 +221,6 @@ describe("Edit Profile Testing", () => {

it("Invalid Phone Number of " + username, () => {
const phone_num = "11111-11111";

cy.get(".flag-dropdown").first().find(".arrow").click();
cy.get("li[data-flag-key='flag_no_84']").click();
cy.get("[placeholder='Phone Number']")
.focus()
.type(`${backspace}${phone_num}`)
Expand All @@ -247,9 +238,6 @@ describe("Edit Profile Testing", () => {

it("Valid Phone Number of " + username, () => {
const phone_num = "99999-99999";

cy.get(".flag-dropdown").first().find(".arrow").click();
cy.get("li[data-flag-key='flag_no_84']").click();
cy.get("[placeholder='Phone Number']")
.focus()
.type(`${backspace}${phone_num}`)
Expand Down
18 changes: 11 additions & 7 deletions src/Components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { useState, useEffect, MutableRefObject } from "react";
import { MutableRefObject, useEffect, useState } from "react";
import {
format,
subMonths,
addMonths,
subYears,
addYears,
isEqual,
getDaysInMonth,
format,
getDay,
getDaysInMonth,
isEqual,
subMonths,
subYears,
} from "date-fns";

import CareIcon from "../../CAREUI/icons/CareIcon";
import { Popover } from "@headlessui/react";
import { classNames } from "../../Utils/utils";
import CareIcon from "../../CAREUI/icons/CareIcon";

type DatePickerType = "date" | "month" | "year";
export type DatePickerPosition = "LEFT" | "RIGHT" | "CENTER";

interface Props {
id?: string;
name?: string;
className?: string;
value: Date | undefined;
min?: Date;
Expand All @@ -34,6 +36,7 @@ const DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];

const DateInputV2: React.FC<Props> = ({
id,
name,
className,
value,
min,
Expand Down Expand Up @@ -215,6 +218,7 @@ const DateInputV2: React.FC<Props> = ({
<input type="hidden" name="date" />
<input
id={id}
name={name}
type="text"
readOnly
disabled={disabled}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Common/HelperInputFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ export const LegacyPhoneNumberField = (props: any) => {
country={undefined}
enableLongNumbers={true}
buttonClass="hidden"
inputProps={{ id, name, maxLength }}
inputProps={{ id, name: enableTollFree ? name : "", maxLength }}
/>
<ButtonV2
className="mt-[2px]"
Expand Down Expand Up @@ -718,7 +718,7 @@ export const LegacyPhoneNumberField = (props: any) => {
disabled={disabled}
autoFormat={!turnOffAutoFormat}
enableLongNumbers={true}
inputProps={{ id, name, maxLength }}
inputProps={{ id, name: enableTollFree ? "" : name, maxLength }}
{...countryRestriction}
/>
<ButtonV2
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Form/FormFields/DateFormField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { classNames } from "../../../Utils/utils";
import DateInputV2, { DatePickerPosition } from "../../Common/DateInputV2";
import FormField from "./FormField";
import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";

import FormField from "./FormField";
import { classNames } from "../../../Utils/utils";

type Props = FormFieldBaseProps<Date> & {
placeholder?: string;
max?: Date;
Expand Down Expand Up @@ -33,6 +34,7 @@ const DateFormField = (props: Props) => {
<DateInputV2
className={classNames(field.error && "border-red-500")}
id={field.id}
name={field.name}
value={field.value}
onChange={field.handleChange}
disabled={field.disabled}
Expand Down
64 changes: 33 additions & 31 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
import loadable from "@loadable/component";
import { Link, navigate } from "raviger";
import { parsePhoneNumberFromString } from "libphonenumber-js";
import moment from "moment";
import React, { useEffect, useState, useCallback } from "react";
import { useDispatch } from "react-redux";
import SwipeableViews from "react-swipeable-views";
import FacilitiesSelectDialogue from "../ExternalResult/FacilitiesSelectDialogue";
import { Tooltip } from "@material-ui/core";
import * as Notification from "../../Utils/Notifications.js";

import {
getAllPatient,
getDistrict,
getLocalBody,
getAnyFacility,
} from "../../Redux/actions";
import NavTabs from "../Common/NavTabs";
import {
ADMITTED_TO,
GENDER_TYPES,
PATIENT_CATEGORIES,
RESPIRATORY_SUPPORT,
PATIENT_SORT_OPTIONS,
RESPIRATORY_SUPPORT,
TELEMEDICINE_ACTIONS,
} from "../../Common/constants";
import PatientFilter from "./PatientFilter";
import { parseOptionId } from "../../Common/utils";
import { statusType, useAbortableEffect } from "../../Common/utils";
import Chip from "../../CAREUI/display/Chip";
import { FacilityModel, PatientCategory } from "../Facility/models";
import SearchInput from "../Form/SearchInput";
import useFilters from "../../Common/hooks/useFilters";
import FilterBadge from "../../CAREUI/display/FilterBadge";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { Link, navigate } from "raviger";
import React, { useCallback, useEffect, useState } from "react";
import {
getAllPatient,
getAnyFacility,
getDistrict,
getLocalBody,
} from "../../Redux/actions";
import { statusType, useAbortableEffect } from "../../Common/utils";

import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover";
import ButtonV2 from "../Common/components/ButtonV2";
import CareIcon from "../../CAREUI/icons/CareIcon";
import Chip from "../../CAREUI/display/Chip";
import CountBlock from "../../CAREUI/display/Count";
import DoctorVideoSlideover from "../Facility/DoctorVideoSlideover";
import { ExportMenu } from "../Common/Export";
import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField";
import FacilitiesSelectDialogue from "../ExternalResult/FacilitiesSelectDialogue";
import { FieldChangeEvent } from "../Form/FormFields/Utils";
import FilterBadge from "../../CAREUI/display/FilterBadge";
import NavTabs from "../Common/NavTabs";
import PatientFilter from "./PatientFilter";
import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField";
import RecordMeta from "../../CAREUI/display/RecordMeta";
import DoctorVideoSlideover from "../Facility/DoctorVideoSlideover";
import CountBlock from "../../CAREUI/display/Count";
import { useTranslation } from "react-i18next";
import * as Notification from "../../Utils/Notifications.js";
import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover";
import SearchInput from "../Form/SearchInput";
import SortDropdownMenu from "../Common/SortDropdown";
import SwipeableViews from "react-swipeable-views";
import { Tooltip } from "@material-ui/core";
import loadable from "@loadable/component";
import moment from "moment";
import { parseOptionId } from "../../Common/utils";
import { parsePhoneNumberFromString } from "libphonenumber-js";
import { useDispatch } from "react-redux";
import useFilters from "../../Common/hooks/useFilters";
import { useTranslation } from "react-i18next";

const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));
Expand Down Expand Up @@ -492,6 +493,7 @@ export const PatientManager = () => {
return (
<Link
key={`usr_${patient.id}`}
data-cy="patient"
href={patientUrl}
className={`relative w-full cursor-pointer p-4 pl-5 hover:pl-5 rounded-lg bg-white shadow text-black ring-2 ring-opacity-0 hover:ring-opacity-100 transition-all duration-200 ease-in-out group ${categoryClass}-ring overflow-hidden`}
>
Expand Down

0 comments on commit 70a3ead

Please sign in to comment.