Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6560
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Nov 10, 2023
2 parents 9c2530c + f7ac211 commit 20fb542
Show file tree
Hide file tree
Showing 31 changed files with 1,040 additions and 424 deletions.
17 changes: 0 additions & 17 deletions cypress/e2e/assets_spec/assets_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,6 @@ describe("Asset", () => {
assetPage.verifyDeleteStatus();
});

it("Verify Facility Asset Page Redirection", () => {
cy.visit("/facility");
assetSearchPage.typeSearchKeyword(fillFacilityName);
assetSearchPage.pressEnter();
facilityPage.verifyFacilityBadgeContent(fillFacilityName);
facilityPage.visitAlreadyCreatedFacility();
facilityPage.clickManageFacilityDropdown();
facilityPage.clickCreateAssetFacilityOption();
facilityPage.verifyfacilitycreateassetredirection();
facilityPage.verifyassetfacilitybackredirection();
facilityPage.clickManageFacilityDropdown();
facilityPage.clickviewAssetFacilityOption();
facilityPage.verifyfacilityviewassetredirection();
assetFilters.assertFacilityText(fillFacilityName);
facilityPage.verifyassetfacilitybackredirection();
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
49 changes: 46 additions & 3 deletions cypress/e2e/users_spec/user_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ describe("Manage User", () => {
const usernametolinkfacilitydoc1 = "dummydoctor4";
const usernametolinkfacilitydoc2 = "dummydoctor5";
const usernametolinkfacilitydoc3 = "dummydoctor6";
const usernametolinkskill = "devdistrictadmin";
const usernametolinkskill = "devdoctor";
const usernameforworkinghour = "devdistrictadmin";
const usernamerealname = "Dummy Doctor";
const facilitytolinkusername = "Dummy Shifting Center";
const facilitytolinkskill = "Dummy Facility 1";
const workinghour = "23";
const linkedskill = "General Medicine";

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand All @@ -25,10 +28,50 @@ describe("Manage User", () => {
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
it("linking skills for a users and verify its reflection in profile", () => {
// select the district user and select one skill link and verify its profile reflection
userPage.typeInSearchInput(usernameforworkinghour);
userPage.checkUsernameText(usernameforworkinghour);
manageUserPage.clicklinkedskillbutton();
manageUserPage.typeSkill(linkedskill);
manageUserPage.selectFacilityFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
manageUserPage.clickCloseSlideOver();
manageUserPage.navigateToProfile();
manageUserPage.assertSkillInAlreadyLinkedSkills(linkedskill);
});

it("linking skills for a doctor users and verify its reflection in doctor connect", () => {
// select a doctor user and link and unlink same skill twice and verify the badge is only shown once in doctor connect
userPage.typeInSearchInput(usernametolinkskill);
userPage.checkUsernameText(usernametolinkskill);
manageUserPage.clicklinkedskillbutton();
manageUserPage.typeSkill(linkedskill);
manageUserPage.selectFacilityFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
manageUserPage.clickCloseSlideOver();
cy.wait(5000); // temporary hack to fix the failure
manageUserPage.clicklinkedskillbutton();
manageUserPage.assertSkillInAddedUserSkills(linkedskill);
manageUserPage.clickUnlinkSkill();
manageUserPage.clickSubmit();
manageUserPage.typeSkill(linkedskill);
manageUserPage.selectFacilityFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
manageUserPage.clickCloseSlideOver();
// verifying the doctor connect
manageUserPage.navigateToFacility();
manageUserPage.typeFacilitySearch(facilitytolinkskill);
manageUserPage.assertFacilityInCard(facilitytolinkskill);
manageUserPage.clickFacilityPatients();
manageUserPage.clickDoctorConnectButton();
manageUserPage.assertSkillIndoctorconnect(linkedskill);
});

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(usernameforworkinghour);
userPage.checkUsernameText(usernameforworkinghour);
manageUserPage.clicksetaveragehourbutton();
manageUserPage.clearweeklyhourfield();
manageUserPage.clickSubmit();
Expand Down
15 changes: 6 additions & 9 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,20 @@ export class PatientConsultationPage {
cy.get("#height").click().type(weight);
cy.get("#patient_no").type(ipNumber);
cy.intercept("GET", "**/icd/**").as("getIcdResults");
cy.get(
"#icd11_diagnoses_object input[placeholder='Select'][role='combobox']"
)
cy.get("#icd11-search input[role='combobox']")
.scrollIntoView()
.click()
.type("1A");
cy.get("#icd11_diagnoses_object [role='option']")
cy.get("#icd11-search [role='option']")
.contains("1A00 Cholera")
.scrollIntoView()
.click();
cy.get("label[for='icd11_diagnoses_object']").click();
cy.get("#condition-verification-status-menu").click();
cy.get("#add-icd11-diagnosis-as-confirmed").click();
cy.wait("@getIcdResults").its("response.statusCode").should("eq", 200);

cy.get("#icd11_principal_diagnosis [role='combobox']").click().type("1A");
cy.get("#icd11_principal_diagnosis [role='option']")
.contains("1A00 Cholera")
.click();
cy.get("#principal-diagnosis-select").click();
cy.get("#principal-diagnosis-select [role='option']").first().click();

cy.get("#consultation_notes").click().type(consulationNotes);
cy.get("#verified_by")
Expand Down
34 changes: 34 additions & 0 deletions cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,44 @@ export class ManageUserPage {
cy.get("#facility-patients").click();
}

clicklinkedskillbutton() {
cy.get("#skills").click();
}

clickAddSkillButton() {
cy.intercept("GET", "**/api/v1/skill/**").as("getSkills");
cy.get("#add-skill-button").click();
cy.wait("@getSkills").its("response.statusCode").should("eq", 200);
}

assertSkillInAlreadyLinkedSkills(skillName) {
cy.get("#already-linked-skills")
.contains(skillName)
.should("have.length", 1);
}

assertSkillIndoctorconnect(skillName) {
cy.get("#doctor-connect-home-doctor")
.contains(skillName)
.should("have.length", 1);
}

typeSkill(skillName) {
cy.get("#select-skill").click().type(skillName);
}

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

clickUnlinkSkill() {
cy.get("#unlink-skill").click();
}

assertSkillInAddedUserSkills(skillName) {
cy.get("#added-user-skills").should("contain", skillName);
}

assertDoctorConnectVisibility(realName) {
cy.get("#doctor-connect-home-doctor").should("contain.text", realName);
cy.get("#doctor-connect-remote-doctor").should("contain.text", realName);
Expand Down
10 changes: 5 additions & 5 deletions src/Common/hooks/useSlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { usePath } from "raviger";
* // Current path: /consultation/94b9a
* const consultation = useSlug("consultation"); // consultation = "94b9a"
*/
export default function useSlug(prefix: string) {
export default function useSlug(prefix: string, fallback?: string) {
const path = usePath() ?? "";
return findSlug(path.split("/"), prefix);
return findSlug(path.split("/"), prefix, fallback);
}

/**
Expand All @@ -28,16 +28,16 @@ export const useSlugs = (...prefix: string[]) => {
return prefix.map((p) => findSlug(path.split("/"), p));
};

const findSlug = (segments: string[], prefix: string) => {
const findSlug = (segments: string[], prefix: string, fallback?: string) => {
const index = segments.findIndex((segment) => segment === prefix);
if (index === -1) {
throw new Error(
`Prefix "${prefix}" not found in path "${segments.join("/")}"`
);
}

const slug = segments[index + 1];
if (!slug) {
const slug = segments[index + 1] ?? fallback;
if (slug === undefined) {
throw new Error(`Slug not found in path "${segments.join("/")}"`);
}

Expand Down
45 changes: 0 additions & 45 deletions src/Components/Common/DiagnosisSelectFormField.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions src/Components/Common/SkillSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AutoCompleteAsync from "../Form/AutoCompleteAsync";
import { SkillObjectModel } from "../Users/models";

interface SkillSelectProps {
id?: string;
name: string;
errors?: string | undefined;
className?: string;
Expand All @@ -20,6 +21,7 @@ interface SkillSelectProps {

export const SkillSelect = (props: SkillSelectProps) => {
const {
id,
name,
multiple,
selected,
Expand Down Expand Up @@ -64,6 +66,7 @@ export const SkillSelect = (props: SkillSelectProps) => {

return (
<AutoCompleteAsync
id={id}
name={name}
multiple={multiple}
selected={selected}
Expand Down
18 changes: 14 additions & 4 deletions src/Components/Common/components/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Anyone, AuthorizedElementProps } from "../../../Utils/AuthorizeFor";

import { ButtonVariant } from "./ButtonV2";
import { ButtonSize, ButtonVariant } from "./ButtonV2";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import { DropdownTransition } from "./HelperComponents";
import { Menu } from "@headlessui/react";
Expand All @@ -12,6 +12,7 @@ interface DropdownMenuProps {
id?: string;
title: string;
variant?: ButtonVariant;
size?: ButtonSize;
icon?: JSX.Element | undefined;
children: JSX.Element | JSX.Element[];
disabled?: boolean | undefined;
Expand All @@ -21,20 +22,29 @@ interface DropdownMenuProps {

export default function DropdownMenu({
variant = "primary",
size = "default",
...props
}: DropdownMenuProps) {
return (
<div id={props.id} className="text-right">
<Menu as="div" className="relative inline-block w-full text-left">
<Menu.Button
disabled={props.disabled}
className={`button-size-default button-${variant}-default button-shape-square flex w-full cursor-pointer items-center justify-center gap-2 font-medium outline-offset-1 transition-all duration-200 ease-in-out disabled:cursor-not-allowed disabled:bg-gray-200 disabled:text-gray-500 lg:justify-between ${props.className}`}
className={`button-size-${size} button-${variant}-default button-shape-square flex w-full cursor-pointer items-center justify-center gap-2 font-medium outline-offset-1 transition-all duration-200 ease-in-out disabled:cursor-not-allowed disabled:bg-gray-200 disabled:text-gray-500 lg:justify-between ${props.className}`}
>
<div className="flex h-6 items-center gap-2">
<div
className={classNames(
"flex items-center gap-2 whitespace-nowrap",
size === "small" ? "h-5" : "h-6"
)}
>
{props.icon}
{props.title || "Dropdown"}
</div>
<CareIcon className="care-l-angle-down -mr-1 ml-2 text-lg" />
<CareIcon
icon="l-angle-down"
className={size === "small" ? "text-base" : "text-lg"}
/>
</Menu.Button>
<DropdownTransition>
<Menu.Items
Expand Down
Loading

0 comments on commit 20fb542

Please sign in to comment.