Skip to content

Commit

Permalink
Merge branch 'coronasafe:develop' into Fix-ohcnetwork#6525
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 authored Oct 31, 2023
2 parents 382c351 + ed3a547 commit 07301e6
Show file tree
Hide file tree
Showing 25 changed files with 620 additions and 606 deletions.
154 changes: 84 additions & 70 deletions cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import { UserPage } from "../../pageobject/Users/UserSearch";
import { UserCreationPage } from "../../pageobject/Users/UserCreation";
import {
emergency_phone_number,
phone_number,
} from "../../pageobject/constants";

describe("User Creation", () => {
const userPage = new UserPage();
Expand Down Expand Up @@ -43,6 +47,15 @@ describe("User Creation", () => {
"Please select the local body",
];

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(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
Expand All @@ -53,13 +66,82 @@ describe("User Creation", () => {
cy.awaitUrl("/users");
});

it("Update the existing user profile and verify its reflection", () => {
userCreationPage.clickElementById("profilenamelink");
userCreationPage.verifyElementContainsText(
"username-profile-details",
"devdistrictadmin"
);
userCreationPage.clickElementById("edit-cancel-profile-button");
userCreationPage.typeIntoElementByIdPostClear(
"firstName",
"District Editted"
);
userCreationPage.typeIntoElementByIdPostClear("lastName", "Cypress");
userCreationPage.typeIntoElementByIdPostClear("age", "22");
userCreationPage.selectDropdownOption("gender", "Male");
userCreationPage.typeIntoElementByIdPostClear(
"phoneNumber",
"+91" + phone_number
);
userCreationPage.typeIntoElementByIdPostClear(
"altPhoneNumber",
"+91" + emergency_phone_number
);
userCreationPage.typeIntoElementByIdPostClear("email", "[email protected]");
userCreationPage.typeIntoElementByIdPostClear("weekly_working_hours", "14");
userCreationPage.clickElementById("submit");
userCreationPage.verifyElementContainsText(
"contactno-profile-details",
"+91" + phone_number
);
userCreationPage.verifyElementContainsText(
"whatsapp-profile-details",
"+91" + emergency_phone_number
);
userCreationPage.verifyElementContainsText(
"firstname-profile-details",
"District Editted"
);
userCreationPage.verifyElementContainsText(
"lastname-profile-details",
"Cypress"
);
userCreationPage.verifyElementContainsText("age-profile-details", "22");
userCreationPage.verifyElementContainsText(
"emailid-profile-details",
"[email protected]"
);
userCreationPage.verifyElementContainsText(
"gender-profile-details",
"Male"
);
userCreationPage.verifyElementContainsText(
"averageworkinghour-profile-details",
"14"
);
});

it("Update the existing user profile Form Mandatory File Error", () => {
userCreationPage.clickElementById("profilenamelink");
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");
userCreationPage.clickElementById("submit");
userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES);
});

it("create new user and verify reflection", () => {
userCreationPage.clickElementById("addUserButton");
userCreationPage.selectFacility("Dummy Shifting Center");
userCreationPage.typeIntoElementById("username", username);
userCreationPage.typeIntoElementById("password", "Test@123");
userCreationPage.selectHomeFacility("Dummy Shifting Center");
userCreationPage.typeIntoElementById("phone_number", "9999999999");
userCreationPage.typeIntoElementById("phone_number", phone_number);
userCreationPage.setInputDate("date_of_birth", "date-input", "25081999");
userCreationPage.selectDropdownOption("user_type", "Doctor");
userCreationPage.typeIntoElementById("c_password", "Test@123");
Expand Down Expand Up @@ -120,75 +202,7 @@ describe("User Creation", () => {
// .click()
// .type("Dummy Facility 1")
// .wait("@getFacilities");
// cy.get("li[role='option']").first().click();
// cy.intercept(/\/api\/v1\/users\/\w+\/add_facility\//).as("addFacility");
// cy.get("button[id='link-facility']").click();
// cy.wait("@addFacility")
// // .its("response.statusCode")
// // .should("eq", 201)
// .get("span")
// .contains("Facility - User Already has permission to this facility");
// });

// describe("Edit User Profile & Error Validation", () => {
// before(() => {
// cy.loginByApi(username, "#@Cypress_test123");
// cy.saveLocalStorage();
// });

// beforeEach(() => {
// cy.restoreLocalStorage();
// cy.awaitUrl("/user/profile");
// cy.contains("button", "Edit User Profile").click();
// });

// it("First name Field Updation " + username, () => {
// cy.get("input[name=firstName]").clear();
// cy.contains("button[type='submit']", "Update").click();
// cy.get("span.error-text").should("contain", "Field is required");
// cy.get("input[name=firstName]").type("firstName updated");
// cy.contains("button[type='submit']", "Update").click();
// });

// it("Last name Field Updation " + username, () => {
// cy.get("input[name=lastName]").clear();
// cy.contains("button[type='submit']", "Update").click();
// cy.get("span.error-text").should("contain", "Field is required");
// cy.get("input[name=lastName]").type("lastName updated");
// cy.contains("button[type='submit']", "Update").click();
// });

// it("Age Field Updation " + username, () => {
// cy.get("input[name=age]").clear();
// cy.contains("button[type='submit']", "Update").click();
// cy.get("span.error-text").should("contain", "This field is required");
// cy.get("input[name=age]").type("11");
// cy.contains("button[type='submit']", "Update").click();
// });

// it("Phone number Field Updation " + username, () => {
// cy.get("input[name=phoneNumber]").clear();
// cy.contains("button[type='submit']", "Update").click();
// cy.get("span.error-text").should(
// "contain",
// "Please enter valid phone number"
// );
// cy.get("input[name=phoneNumber]").type("+919999999999");
// cy.contains("button[type='submit']", "Update").click();
// });

// it("Whatsapp number Field Updation " + username, () => {
// cy.get("input[name=altPhoneNumber]").clear();
// cy.get("input[name=altPhoneNumber]").type("+919999999999");
// cy.contains("button[type='submit']", "Update").click();
// });

// it("Email Field Updation " + username, () => {
// cy.get("input[name=email]").clear();
// cy.contains("button[type='submit']", "Update").click();
// cy.get("span.error-text").should("contain", "This field is required");
// cy.get("input[name=email]").type("[email protected]");
// cy.contains("button[type='submit']", "Update").click();
// cy.get("li[role='option']").should("not.exist");
// });

afterEach(() => {
Expand Down
14 changes: 14 additions & 0 deletions cypress/pageobject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ export class UserCreationPage {
.type(value);
}

typeIntoElementByIdPostClear(elementId: string, value: string) {
cy.get("#" + elementId)
.click()
.clear()
.click()
.type(value);
}

clearIntoElementById(elementId: string) {
cy.get("#" + elementId)
.click()
.clear();
}

typeIntoInputByName(inputName: string, value: string) {
cy.get("input[name='" + inputName + "']")
.click()
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Common/FacilitySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FacilityModel } from "../Facility/models";

interface FacilitySelectProps {
name: string;
exclude_user: string;
errors?: string | undefined;
className?: string;
searchAll?: boolean;
Expand All @@ -22,6 +23,7 @@ interface FacilitySelectProps {
export const FacilitySelect = (props: FacilitySelectProps) => {
const {
name,
exclude_user,
multiple,
selected,
setSelected,
Expand All @@ -45,6 +47,7 @@ export const FacilitySelect = (props: FacilitySelectProps) => {
search_text: text,
all: searchAll,
facility_type: facilityType,
exclude_user: exclude_user,
district,
};

Expand Down
5 changes: 5 additions & 0 deletions src/Components/Common/LocationSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AutocompleteFormField from "../Form/FormFields/Autocomplete";
import AutocompleteMultiSelectFormField from "../Form/FormFields/AutocompleteMultiselect";
interface LocationSelectProps {
name: string;
disabled?: boolean;
margin?: string;
errors: string;
className?: string;
Expand All @@ -26,6 +27,7 @@ export const LocationSelect = (props: LocationSelectProps) => {
errors,
className = "",
facilityId,
disabled = false,
} = props;
const [locations, setLocations] = useState<{ name: string; id: string }[]>(
[]
Expand All @@ -40,6 +42,7 @@ export const LocationSelect = (props: LocationSelectProps) => {
};

useEffect(() => {
if (!facilityId) return;
const params = {
limit: 14,
search_text: query,
Expand All @@ -56,6 +59,7 @@ export const LocationSelect = (props: LocationSelectProps) => {
return props.multiple ? (
<AutocompleteMultiSelectFormField
name={name}
disabled={disabled}
value={selected as unknown as string[]}
options={locations}
onChange={({ value }) => handleValueChange(value as unknown as string[])}
Expand All @@ -72,6 +76,7 @@ export const LocationSelect = (props: LocationSelectProps) => {
) : (
<AutocompleteFormField
name={name}
disabled={disabled}
value={selected as string}
options={locations}
onChange={({ value }) => handleValueChange([value])}
Expand Down
1 change: 1 addition & 0 deletions src/Components/Common/Sidebar/SidebarUserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SidebarUserCard = ({ shrinked }: { shrinked: boolean }) => {
<Link
href="/user/profile"
className="flex-nowrap overflow-hidden break-words font-semibold text-white"
id="profilenamelink"
>
{profileName}
</Link>
Expand Down
40 changes: 19 additions & 21 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const ConsultationDetails = (props: any) => {
/>

<div className="px-2 pb-2">
<nav className="relative flex flex-wrap justify-between">
<nav className="relative flex flex-wrap items-start justify-between">
<PageTitle
title="Patient Dashboard"
className="sm:m-0 sm:p-0"
Expand All @@ -290,9 +290,9 @@ export const ConsultationDetails = (props: any) => {
breadcrumbs={true}
backUrl="/patients"
/>
<div className="-right-6 top-0 flex w-full flex-col space-y-1 sm:w-min sm:flex-row sm:items-center sm:space-y-0 sm:divide-x-2 lg:absolute xl:right-0">
<div className="flex w-full flex-col min-[1150px]:w-min min-[1150px]:flex-row min-[1150px]:items-center">
{!consultationData.discharge_date && (
<div className="flex w-full flex-col px-2 sm:flex-row">
<>
{hasActiveShiftingRequest() ? (
<ButtonV2
onClick={() =>
Expand All @@ -302,7 +302,7 @@ export const ConsultationDetails = (props: any) => {
}`
)
}
className="btn btn-primary m-1 w-full hover:text-white"
className="btn btn-primary mx-1 w-full p-1.5 px-4 hover:text-white"
>
<CareIcon className="care-l-ambulance h-5 w-5" />
Track Shifting
Expand All @@ -315,7 +315,7 @@ export const ConsultationDetails = (props: any) => {
`/facility/${patientData.facility}/patient/${patientData.id}/shift/new`
)
}
className="btn btn-primary m-1 w-full hover:text-white"
className="btn btn-primary mx-1 w-full p-1.5 px-4 hover:text-white"
>
<CareIcon className="care-l-ambulance h-5 w-5" />
Shift Patient
Expand Down Expand Up @@ -343,23 +343,21 @@ export const ConsultationDetails = (props: any) => {
Camera Feed
</Link>
)}
</div>
</>
)}
<div className="flex w-full flex-col px-2 sm:flex-row">
<Link
href={`/facility/${patientData.facility}/patient/${patientData.id}`}
className="btn btn-primary m-1 w-full hover:text-white"
>
Patient Details
</Link>
<Link
id="patient_doctor_notes"
href={`/facility/${patientData.facility}/patient/${patientData.id}/notes`}
className="btn btn-primary m-1 w-full hover:text-white"
>
Doctor&apos;s Notes
</Link>
</div>
<Link
href={`/facility/${patientData.facility}/patient/${patientData.id}`}
className="btn btn-primary m-1 w-full hover:text-white"
>
Patient Details
</Link>
<Link
id="patient_doctor_notes"
href={`/facility/${patientData.facility}/patient/${patientData.id}/notes`}
className="btn btn-primary m-1 w-full hover:text-white"
>
Doctor&apos;s Notes
</Link>
</div>
</nav>
<div className="mt-2 flex w-full flex-col md:flex-row">
Expand Down
Loading

0 comments on commit 07301e6

Please sign in to comment.