Skip to content

Commit

Permalink
Merge branch 'develop' into fix-issue-6432
Browse files Browse the repository at this point in the history
  • Loading branch information
GokulramGHV authored Nov 8, 2023
2 parents aade406 + 05df8c0 commit 3391b1e
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 84 deletions.
12 changes: 0 additions & 12 deletions cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,6 @@ describe("User Creation", () => {
userPage.verifyMultipleBadgesWithSameId(alreadylinkedusersviews);
});

// the below commented out codes, will be used in the upcoming refactoring of this module, since it is a inter-dependent of partially converted code, currently taking it down

// it("link facility for user", () => {
// cy.contains("Linked Facilities").click();
// cy.intercept(/\/api\/v1\/facility/).as("getFacilities");
// cy.get("[name='facility']")
// .click()
// .type("Dummy Facility 1")
// .wait("@getFacilities");
// cy.get("li[role='option']").should("not.exist");
// });

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
101 changes: 101 additions & 0 deletions cypress/e2e/users_spec/user_manage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import { UserPage } from "../../pageobject/Users/UserSearch";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";

describe("Manage User", () => {
const loginPage = new LoginPage();
const userPage = new UserPage();
const manageUserPage = new ManageUserPage();
const usernametolinkfacilitydoc1 = "dummydoctor4";
const usernametolinkfacilitydoc2 = "dummydoctor5";
const usernametolinkfacilitydoc3 = "dummydoctor6";
const usernametolinkskill = "devdistrictadmin";
const usernamerealname = "Dummy Doctor";
const facilitytolinkusername = "Dummy Shifting Center";
const workinghour = "23";

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

beforeEach(() => {
cy.restoreLocalStorage();
cy.awaitUrl("/users");
});

it("add working hour for a user and verify its reflection in card and user profile", () => {
// verify mandatory field error and select working hour for a user
userPage.typeInSearchInput(usernametolinkskill);
userPage.checkUsernameText(usernametolinkskill);
manageUserPage.clicksetaveragehourbutton();
manageUserPage.clearweeklyhourfield();
manageUserPage.clickSubmit();
manageUserPage.verifyErrorText("Value should be between 0 and 168");
// verify the data is reflected in user card and profile page
manageUserPage.typeInWeeklyWorkingHours(workinghour);
manageUserPage.clickSubmit();
manageUserPage.verifyWorkingHours(workinghour);
manageUserPage.navigateToProfile();
manageUserPage.verifyProfileWorkingHours(workinghour);
});

it("linking and unlinking facility for multiple users, and confirm reflection in user cards and doctor connect", () => {
// verify the user doesn't have any home facility
userPage.typeInSearchInput(usernametolinkfacilitydoc1);
userPage.checkUsernameText(usernametolinkfacilitydoc1);
manageUserPage.assertHomeFacility("No Home Facility");
// Link a new facility and ensure it is under linked facility - doctor username (1)
manageUserPage.clickFacilitiesTab();
manageUserPage.typeFacilityName(facilitytolinkusername);
manageUserPage.selectFacilityFromDropdown(facilitytolinkusername);
manageUserPage.clickLinkFacility();
manageUserPage.assertLinkedFacility(facilitytolinkusername);
// Verify in the already linked facility are not present in droplist
manageUserPage.assertFacilityNotInDropdown(facilitytolinkusername);
manageUserPage.clickCloseSlideOver();
// Link a new facility and ensure it is under home facility - doctor username (2)
userPage.clearSearchInput();
userPage.typeInSearchInput(usernametolinkfacilitydoc2);
userPage.checkUsernameText(usernametolinkfacilitydoc2);
manageUserPage.clickFacilitiesTab();
manageUserPage.typeFacilityName(facilitytolinkusername);
manageUserPage.selectFacilityFromDropdown(facilitytolinkusername);
manageUserPage.clickLinkFacility();
manageUserPage.clickHomeFacilityIcon();
manageUserPage.assertnotLinkedFacility(facilitytolinkusername);
manageUserPage.assertHomeFacilitylink(facilitytolinkusername);
manageUserPage.clickCloseSlideOver();
// verify the home facility doctor id have reflection in user card
userPage.clearSearchInput();
userPage.typeInSearchInput(usernametolinkfacilitydoc2);
userPage.checkUsernameText(usernametolinkfacilitydoc2);
manageUserPage.assertHomeFacility(facilitytolinkusername);
// Link a new facility and unlink the facility from the doctor username (3)
userPage.clearSearchInput();
userPage.typeInSearchInput(usernametolinkfacilitydoc3);
userPage.checkUsernameText(usernametolinkfacilitydoc3);
manageUserPage.clickFacilitiesTab();
manageUserPage.typeFacilityName(facilitytolinkusername);
manageUserPage.selectFacilityFromDropdown(facilitytolinkusername);
manageUserPage.clickLinkFacility();
manageUserPage.clickUnlinkFacilityButton();
manageUserPage.clickSubmit();
manageUserPage.assertnotLinkedFacility;
manageUserPage.linkedfacilitylistnotvisible();
manageUserPage.clickCloseSlideOver();
// Go to particular facility doctor connect and all user-id are reflected based on there access
// Path will be facility page to patient page then doctor connect button
manageUserPage.navigateToFacility();
manageUserPage.typeFacilitySearch(facilitytolinkusername);
manageUserPage.assertFacilityInCard(facilitytolinkusername);
manageUserPage.clickFacilityPatients();
manageUserPage.clickDoctorConnectButton();
manageUserPage.assertDoctorConnectVisibility(usernamerealname);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
116 changes: 116 additions & 0 deletions cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
export class ManageUserPage {
assertHomeFacility(expectedText) {
cy.get("#home_facility").should("contain.text", expectedText);
}

clickFacilitiesTab() {
cy.get("#facilities").click();
}

typeFacilityName(facilityName) {
cy.get("input[name='facility']").click().type(facilityName);
}

selectFacilityFromDropdown(facilityName) {
cy.get("[role='option']").contains(facilityName).click();
}

clickLinkFacility() {
cy.get("#link-facility").click();
}

assertLinkedFacility(facilityName) {
cy.get("#linked-facility-list").should("contain.text", facilityName);
}

assertnotLinkedFacility(facilityName) {
cy.get("#linked-facility-list").should("not.contain", facilityName);
}

linkedfacilitylistnotvisible() {
cy.get("#linked-facility-list").should("not.exist");
}

assertHomeFacilitylink(facilityName) {
cy.get("#home-facility").should("contain.text", facilityName);
}

assertFacilityNotInDropdown(facilityName) {
this.typeFacilityName(facilityName);
cy.get("[role='option']").should("not.exist");
}

clickCloseSlideOver() {
cy.get("#close-slide-over").click();
}

clickHomeFacilityIcon() {
cy.get("#home-facility-icon").click();
}

clickUnlinkFacilityButton() {
cy.get("#unlink-facility-button").click();
}

clickSubmit() {
cy.get("#submit").click();
}

clicksetaveragehourbutton() {
cy.get("#avg-workinghour").click();
}

clearweeklyhourfield() {
cy.get("#weekly_working_hours").click().clear();
}

verifyErrorText(expectedError: string) {
cy.get(".error-text").should("contain", expectedError).and("be.visible");
}

typeInWeeklyWorkingHours(hours: string) {
cy.get("#weekly_working_hours").click().type(hours);
}

navigateToProfile() {
cy.get("#profilenamelink").click();
}

verifyWorkingHours(expectedHours: string) {
cy.get("#working-hours").should("contain", `${expectedHours} hours`);
}

verifyProfileWorkingHours(expectedHours: string) {
cy.get("#averageworkinghour-profile-details").should(
"contain",
expectedHours
);
}

navigateToFacility() {
cy.visit("/facility");
}

typeFacilitySearch(facilityName) {
cy.get("#search").click().type(facilityName);
}

assertFacilityInCard(facilityName) {
cy.get("#facility-name-card").should("contain", facilityName);
}

clickFacilityPatients() {
cy.get("#facility-patients").click();
}

clickDoctorConnectButton() {
cy.get("#doctor-connect-patient-button").click();
}

assertDoctorConnectVisibility(realName) {
cy.get("#doctor-connect-home-doctor").should("contain.text", realName);
cy.get("#doctor-connect-remote-doctor").should("contain.text", realName);
}
}

export default ManageUserPage;
4 changes: 2 additions & 2 deletions src/Components/Common/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const StatelessSidebar = ({

return (
<nav
className={`group flex h-screen flex-col bg-primary-800 py-3 md:py-5 ${
className={`group flex h-full flex-col bg-primary-800 py-3 md:py-5 ${
shrinked ? "w-14" : "w-60"
} transition-all duration-300 ease-in-out ${
isOverflowVisible && shrinked
Expand All @@ -134,7 +134,7 @@ const StatelessSidebar = ({
/>
</Link>
<div className="h-3" /> {/* flexible spacing */}
<div className="relative mb-4 flex h-full flex-col md:mb-0">
<div className="relative flex h-full flex-col">
<div className="relative flex flex-1 flex-col md:flex-none">
<div
ref={indicatorRef}
Expand Down
8 changes: 7 additions & 1 deletion src/Components/Facility/DoctorVideoSlideover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ export default function DoctorVideoSlideover(props: {
home: false,
},
].map((type, i) => (
<div key={i} className="mb-4">
<div
key={i}
className="mb-4"
id={`doctor-connect-${
type.home ? "home" : "remote"
}-${type.user_type.toLowerCase()}`}
>
<div>
<span className="text-lg font-semibold">{type.title}</span>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Facility/FacilityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
{kasp_string}
</div>
)}
<div className="flex flex-wrap items-center justify-between">
<div
className="flex flex-wrap items-center justify-between"
id="facility-name-card"
>
<Link
href={`/facility/${facility.id}`}
className="float-left text-xl font-bold capitalize text-inherit hover:text-inherit"
Expand Down
42 changes: 22 additions & 20 deletions src/Components/Facility/FacilityConfigure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,30 @@ export const FacilityConfigure = (props: IProps) => {
}}
className="w-full overflow-x-hidden"
>
<div className="cui-card mt-4">
<form onSubmit={handleSubmit}>
<div className="mt-2 grid grid-cols-1 gap-4">
<div>
<TextFormField
name="middleware_address"
label="Facility Middleware Address"
required
value={state.form.middleware_address}
onChange={handleChange}
error={state.errors?.middleware_address}
/>
<div className="mx-auto max-w-3xl">
<div className="cui-card mt-4">
<form onSubmit={handleSubmit}>
<div className="mt-2 grid grid-cols-1 gap-4">
<div>
<TextFormField
name="middleware_address"
label="Facility Middleware Address"
required
value={state.form.middleware_address}
onChange={handleChange}
error={state.errors?.middleware_address}
/>
</div>
</div>
</div>
<div className="flex flex-col gap-3 sm:flex-row sm:justify-end">
<Cancel onClick={() => navigate(`/facility/${facilityId}`)} />
<Submit onClick={handleSubmit} label="Update" />
</div>
</form>
</div>
<div className="flex flex-col gap-3 sm:flex-row sm:justify-end">
<Cancel onClick={() => navigate(`/facility/${facilityId}`)} />
<Submit onClick={handleSubmit} label="Update" />
</div>
</form>
</div>

<ConfigureHealthFacility facilityId={facilityId} />
<ConfigureHealthFacility facilityId={facilityId} />
</div>
</Page>
);
};
1 change: 1 addition & 0 deletions src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ export const FacilityHome = (props: any) => {
<span className="text-sm">Add Details of a Patient</span>
</ButtonV2>
<ButtonV2
id="view-patient-facility-list"
variant="primary"
ghost
border
Expand Down
1 change: 1 addition & 0 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ export const PatientManager = () => {
/>
{showDoctorConnect && (
<ButtonV2
id="doctor-connect-patient-button"
onClick={() => {
triggerGoal("Doctor Connect Clicked", {
facilityId: qParams.facility,
Expand Down
Loading

0 comments on commit 3391b1e

Please sign in to comment.