Skip to content

Commit

Permalink
fixed facility_spec/facility
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed May 19, 2023
1 parent 1616ab2 commit fd83fad
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 147 deletions.
8 changes: 6 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -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)) {
Expand All @@ -17,6 +19,8 @@ export default defineConfig({
return null;
},
});

return config;
},
baseUrl: "http://localhost:4000",
retries: 2,
Expand Down
46 changes: 23 additions & 23 deletions cypress/e2e/facility_spec/facility.cy.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -31,7 +31,7 @@ class facility {
features,
address,
pincode,
tel,
phone,
state,
district,
localbody,
Expand All @@ -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);
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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) => {
Expand All @@ -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",
Expand Down
178 changes: 92 additions & 86 deletions src/Components/Common/HelperInputFields.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import DateFnsUtils from "@date-io/date-fns";
import "react-phone-input-2/lib/high-res.css";

import {
Checkbox,
Chip,
Expand All @@ -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<SelectProps, "onChange"> {
options: Array<any>;
Expand Down Expand Up @@ -578,6 +580,7 @@ export const LegacyPhoneNumberField = (props: any) => {
disabled,
countryCodeEditable = false,
className,
id,
name,
requiredError = false,
} = props;
Expand Down Expand Up @@ -662,83 +665,86 @@ export const LegacyPhoneNumberField = (props: any) => {
requiredError && "border border-red-500 rounded"
} relative flex flex-col`}
>
<div
className={`flex flex-row ${enableTollFree ? "visible" : "hidden"}`}
>
<div className="h-full w-[67px] items-center flex justify-center rounded-md border-gray-500 border py-2">
<CareIcon className="care-l-phone w-5 h-5" />
{enableTollFree ? (
<div className="flex flex-row">
<div className="h-full w-[67px] items-center flex justify-center rounded-md border-gray-500 border py-2">
<CareIcon className="care-l-phone w-5 h-5" />
</div>
<PhoneInput
inputClass="cui-input-base pl-4 pr-10 py-5 tracking-widest"
containerClass={className}
value={value}
onChange={handleChange}
disableCountryGuess
disableCountryCode
disableInitialCountryGuess
disableSearchIcon
disableDropdown
placeholder="(1800)... / 91 ..."
alwaysDefaultMask
country={undefined}
enableLongNumbers={true}
buttonClass="hidden"
inputProps={{
id,
name,
maxLength,
autoFocus: true,
}}
/>
<ButtonV2
className="mt-[2px]"
variant="secondary"
type="button"
ghost
disabled={disabled}
onClick={() => {
onChange("+91");
setEnableTollFree(false);
setFocus();
}}
>
{" "}
<CareIcon className="care-l-multiply" />
</ButtonV2>
</div>
<PhoneInput
inputClass="cui-input-base pl-4 pr-10 py-5 tracking-widest"
containerClass={className}
value={value}
onChange={handleChange}
disableCountryGuess
disableCountryCode
disableInitialCountryGuess
disableSearchIcon
disableDropdown
placeholder="(1800)... / 91 ..."
alwaysDefaultMask
country={undefined}
enableLongNumbers={true}
buttonClass="hidden"
inputProps={{
name,
maxLength,
}}
/>
<ButtonV2
className="mt-[2px]"
variant="secondary"
type="button"
ghost
disabled={disabled}
onClick={() => {
onChange("+91");
setEnableTollFree(false);
setFocus();
}}
>
{" "}
<CareIcon className="care-l-multiply" />
</ButtonV2>
</div>
<div
className={`flex flex-row ${enableTollFree ? "hidden" : "visible"}`}
>
<PhoneInput
inputClass="cui-input-base pl-14 pr-10 py-5 tracking-widest"
containerClass={className}
countryCodeEditable={countryCodeEditable}
value={value}
placeholder={placeholder}
onChange={handleChange}
country="in"
disabled={disabled}
autoFormat={!turnOffAutoFormat}
enableLongNumbers={true}
inputProps={{
name,
maxLength,
}}
{...countryRestriction}
/>
<ButtonV2
className="mt-[2px]"
variant="secondary"
type="button"
ghost
disabled={disabled}
onClick={() => {
onChange("+91");
setEnableTollFree(false);
setFocus();
}}
>
<CareIcon className="care-l-multiply" />
</ButtonV2>
</div>
) : (
<div className="flex flex-row">
<PhoneInput
inputClass="cui-input-base pl-14 pr-10 py-5 tracking-widest"
containerClass={className}
countryCodeEditable={countryCodeEditable}
value={value}
placeholder={placeholder}
onChange={handleChange}
country="in"
disabled={disabled}
autoFormat={!turnOffAutoFormat}
enableLongNumbers={true}
inputProps={{
id,
name,
maxLength,
autoFocus: true,
}}
{...countryRestriction}
/>
<ButtonV2
className="mt-[2px]"
variant="secondary"
type="button"
ghost
disabled={disabled}
onClick={() => {
onChange("+91");
setEnableTollFree(false);
setFocus();
}}
>
<CareIcon className="care-l-multiply" />
</ButtonV2>
</div>
)}
</div>
{errors && <LegacyErrorHelperText error={errors} />}
</>
Expand Down
Loading

0 comments on commit fd83fad

Please sign in to comment.