diff --git a/cypress.config.ts b/cypress.config.ts index 10f9ab82c9b..014eb1f4d07 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,13 +1,15 @@ import { defineConfig } from "cypress"; - import fs from "fs"; export default defineConfig({ projectId: "wf7d2m", defaultCommandTimeout: 10000, e2e: { - setupNodeEvents(on, _) { + setupNodeEvents(on, config) { // implement node event listeners here + + require("cypress-localstorage-commands/plugin")(on, config); // eslint-disable-line + on("task", { readFileMaybe(filename) { if (fs.existsSync(filename)) { @@ -17,6 +19,8 @@ export default defineConfig({ return null; }, }); + + return config; }, baseUrl: "http://localhost:4000", retries: 2, diff --git a/cypress/e2e/facility_spec/facility.cy.ts b/cypress/e2e/facility_spec/facility.cy.ts index f9c7e8edc1b..e1eae94ad04 100644 --- a/cypress/e2e/facility_spec/facility.cy.ts +++ b/cypress/e2e/facility_spec/facility.cy.ts @@ -1,4 +1,4 @@ -import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; +import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; class facility { static create(facility) { @@ -31,7 +31,7 @@ class facility { features, address, pincode, - tel, + phone, state, district, localbody, @@ -47,63 +47,63 @@ class facility { latitude, longitude, }) { - cy.get("[id=facility-type] > div > button").click(); + cy.get("[id=facility_type] > div > button").click(); cy.get("div").contains(type).click(); - cy.get("input[id=facility-name]").should("exist").type(name); + cy.get("input[id=name]").should("exist").type(name); - cy.get("[id=facility-features] > div > div > button").click(); + cy.get("[id=features] > div > div > button").click(); cy.get("li").contains(features[0]).click(); cy.get("li").contains(features[1]).click(); cy.get("body").click(); - cy.get("[id=facility-state] > div > button").click(); + cy.get("[id=state] > div > button").click(); cy.get("div").contains(state).click(); - cy.get("[id=facility-district] > div > button").click(); + cy.get("[id=district] > div > button").click(); cy.get("div").contains(district).click(); - cy.get("[id=facility-localbody] > div > button").click(); + cy.get("[id=local_body] > div > button").click(); cy.get("div").contains(localbody).click(); - cy.get("[id=facility-ward] > div > button").click(); + cy.get("[id=ward] > div > button").click(); cy.get("div").contains(ward).click(); - cy.get("textarea[id=facility-address]").should("exist").type(address); + cy.get("textarea[id=address]").should("exist").type(address); - cy.get("input[id=facility-pincode]").should("exist").clear().type(pincode); + cy.get("input[id=pincode]").should("exist").clear().type(pincode); - cy.get("input[type=tel]").should("exist").type(tel); + cy.get("input[id=phone_number]").should("exist").type(phone); - cy.get("input[id=facility-oxygen_capacity]").clear().type(oxygen_capacity); - cy.get("input[id=facility-expected_oxygen_requirement]") + cy.get("input[id=oxygen_capacity]").clear().type(oxygen_capacity); + cy.get("input[id=expected_oxygen_requirement]") .should("exist") .clear() .type(oxygen_requirement); - cy.get("input[id=facility-type_b_cylinders]") + cy.get("input[id=type_b_cylinders]") .should("exist") .clear() .type(type_b_cylinders); - cy.get("input[id=facility-expected_type_b_cylinders]") + cy.get("input[id=expected_type_b_cylinders]") .should("exist") .clear() .type(expected_type_b_cylinders); - cy.get("input[id=facility-type_c_cylinders]") + cy.get("input[id=type_c_cylinders]") .should("exist") .clear() .type(type_c_cylinders); - cy.get("input[id=facility-expected_type_c_cylinders]") + cy.get("input[id=expected_type_c_cylinders]") .should("exist") .clear() .type(expected_type_c_cylinders); - cy.get("input[id=facility-type_d_cylinders]") + cy.get("input[id=type_d_cylinders]") .should("exist") .clear() .type(type_d_cylinders); - cy.get("input[id=facility-expected_type_d_cylinders]") + cy.get("input[id=expected_type_d_cylinders]") .should("exist") .clear() .type(expected_type_d_cylinders); @@ -138,7 +138,7 @@ describe("Facility", () => { ward: "MANAKKAPADY", address: "some address", pincode: "884656", - tel: "9985784535", + phone: "9985784535", oxygen_capacity: "20", oxygen_requirement: "30", type_b_cylinders: "20", @@ -166,7 +166,7 @@ describe("Facility", () => { cy.get("[id=area-of-specialization] > div > button").click(); cy.get("ul > li:nth-child(2)").click(); cy.get("[id=count]").type("15"); - cy.get("[id=submit").click(); + cy.get("[id=save-and-exit").click(); cy.verifyNotification("Doctor count added successfully"); cy.url().then((url) => { @@ -185,7 +185,7 @@ describe("Facility", () => { ward: "PAZHAMTHOTTAM", address: " update", pincode: "584675", - tel: "9985784535", + phone: "9985784535", oxygen_capacity: "30", oxygen_requirement: "40", type_b_cylinders: "23", diff --git a/src/Components/Common/HelperInputFields.tsx b/src/Components/Common/HelperInputFields.tsx index b5cc2376df9..c000faf662d 100644 --- a/src/Components/Common/HelperInputFields.tsx +++ b/src/Components/Common/HelperInputFields.tsx @@ -1,4 +1,5 @@ -import DateFnsUtils from "@date-io/date-fns"; +import "react-phone-input-2/lib/high-res.css"; + import { Checkbox, Chip, @@ -14,23 +15,24 @@ import { TextField, TextFieldProps, } from "@material-ui/core"; -import Box from "@material-ui/core/Box"; -import FormControl from "@material-ui/core/FormControl"; -import { NativeSelectInputProps } from "@material-ui/core/NativeSelect/NativeSelectInput"; -import { SelectProps } from "@material-ui/core/Select"; -import Autocomplete from "@material-ui/lab/Autocomplete"; import { DatePickerProps, KeyboardDatePicker, KeyboardDateTimePicker, MuiPickersUtilsProvider, } from "@material-ui/pickers"; -import { MaterialUiPickersDate } from "@material-ui/pickers/typings/date"; -import React, { ChangeEvent, useEffect, useState } from "react"; import PhoneInput, { ICountryData } from "react-phone-input-2"; -import "react-phone-input-2/lib/high-res.css"; -import CareIcon from "../../CAREUI/icons/CareIcon"; +import React, { ChangeEvent, useEffect, useState } from "react"; + +import Autocomplete from "@material-ui/lab/Autocomplete"; +import Box from "@material-ui/core/Box"; import ButtonV2 from "./components/ButtonV2"; +import CareIcon from "../../CAREUI/icons/CareIcon"; +import DateFnsUtils from "@date-io/date-fns"; +import FormControl from "@material-ui/core/FormControl"; +import { MaterialUiPickersDate } from "@material-ui/pickers/typings/date"; +import { NativeSelectInputProps } from "@material-ui/core/NativeSelect/NativeSelectInput"; +import { SelectProps } from "@material-ui/core/Select"; export interface DefaultSelectInputProps extends Omit { options: Array; @@ -578,6 +580,7 @@ export const LegacyPhoneNumberField = (props: any) => { disabled, countryCodeEditable = false, className, + id, name, requiredError = false, } = props; @@ -662,83 +665,86 @@ export const LegacyPhoneNumberField = (props: any) => { requiredError && "border border-red-500 rounded" } relative flex flex-col`} > -
-
- + {enableTollFree ? ( +
+
+ +
+ + { + onChange("+91"); + setEnableTollFree(false); + setFocus(); + }} + > + {" "} + +
- - { - onChange("+91"); - setEnableTollFree(false); - setFocus(); - }} - > - {" "} - - -
-
- - { - onChange("+91"); - setEnableTollFree(false); - setFocus(); - }} - > - - -
+ ) : ( +
+ + { + onChange("+91"); + setEnableTollFree(false); + setFocus(); + }} + > + + +
+ )}
{errors && } diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index d6c8a4bc6d4..6b4fe5e8769 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -1,59 +1,59 @@ +import * as Notification from "../../Utils/Notifications.js"; + +import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2"; +import { CapacityModal, DoctorModal } from "./models"; import { Card, CardContent } from "@material-ui/core"; -import Popover from "@material-ui/core/Popover"; -import { navigate } from "raviger"; -import loadable from "@loadable/component"; -import { parsePhoneNumberFromString } from "libphonenumber-js"; -import React, { useCallback, useReducer, useState } from "react"; -import { useDispatch } from "react-redux"; import { FACILITY_FEATURE_TYPES, FACILITY_TYPES, getBedTypes, } from "../../Common/constants"; -import { statusType, useAbortableEffect } from "../../Common/utils"; import { - phonePreg, - validatePincode, - validateLatitude, - validateLongitude, -} from "../../Common/validation"; + MultiSelectFormField, + SelectFormField, +} from "../Form/FormFields/SelectFormField"; +import React, { useCallback, useReducer, useState } from "react"; +import Steps, { Step } from "../Common/Steps"; import { createFacility, getDistrictByState, - getPermittedFacility, getLocalbodyByDistrict, + getPermittedFacility, getStates, - updateFacility, getWardByLocalBody, listCapacity, listDoctor, + updateFacility, } from "../../Redux/actions"; -import * as Notification from "../../Utils/Notifications.js"; -import GLocationPicker from "../Common/GLocationPicker"; +import { getPincodeDetails, includesIgnoreCase } from "../../Utils/utils"; import { - includesIgnoreCase as includesIgnoreCase, - getPincodeDetails, -} from "../../Utils/utils"; -import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; -import { FieldChangeEvent } from "../Form/FormFields/Utils"; -import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2"; -import TextFormField from "../Form/FormFields/TextFormField"; -import Steps, { Step } from "../Common/Steps"; + phonePreg, + validateLatitude, + validateLongitude, + validatePincode, +} from "../../Common/validation"; +import { statusType, useAbortableEffect } from "../../Common/utils"; + import { BedCapacity } from "./BedCapacity"; -import { DoctorCapacity } from "./DoctorCapacity"; -import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; -import useConfig from "../../Common/hooks/useConfig"; -import { CapacityModal, DoctorModal } from "./models"; import BedTypeCard from "./BedTypeCard"; +import CareIcon from "../../CAREUI/icons/CareIcon"; +import { DoctorCapacity } from "./DoctorCapacity"; import DoctorsCountCard from "./DoctorsCountCard"; -import { - MultiSelectFormField, - SelectFormField, -} from "../Form/FormFields/SelectFormField"; +import { FieldChangeEvent } from "../Form/FormFields/Utils"; +import GLocationPicker from "../Common/GLocationPicker"; +import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; +import Popover from "@material-ui/core/Popover"; import RadioFormField from "../Form/FormFields/RadioFormField"; -import CareIcon from "../../CAREUI/icons/CareIcon"; -import { useTranslation } from "react-i18next"; +import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; +import TextFormField from "../Form/FormFields/TextFormField"; +import loadable from "@loadable/component"; +import { navigate } from "raviger"; +import { parsePhoneNumberFromString } from "libphonenumber-js"; import useAppHistory from "../../Common/hooks/useAppHistory"; +import useConfig from "../../Common/hooks/useConfig"; +import { useDispatch } from "react-redux"; +import { useTranslation } from "react-i18next"; + const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); diff --git a/src/Components/Form/FormFields/PhoneNumberFormField.tsx b/src/Components/Form/FormFields/PhoneNumberFormField.tsx index 352a1efefbf..14cd66af4bf 100644 --- a/src/Components/Form/FormFields/PhoneNumberFormField.tsx +++ b/src/Components/Form/FormFields/PhoneNumberFormField.tsx @@ -1,7 +1,8 @@ -import { LegacyPhoneNumberField } from "../../Common/HelperInputFields"; -import FormField from "./FormField"; import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils"; +import FormField from "./FormField"; +import { LegacyPhoneNumberField } from "../../Common/HelperInputFields"; + type Props = FormFieldBaseProps & { placeholder?: string; autoComplete?: string; @@ -15,6 +16,7 @@ const PhoneNumberFormField = (props: Props) => { return (