Skip to content

Commit

Permalink
New Cypress Test | Functionality test of Linking Skill to a User | Us…
Browse files Browse the repository at this point in the history
…er Tab (ohcnetwork#6568)

* linking skill to a user

* fixed failure

* removed duplicate code in asset module

* minor-fix-assertion
  • Loading branch information
nihal467 authored Nov 9, 2023
1 parent f575710 commit f7ac211
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 22 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
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
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
3 changes: 3 additions & 0 deletions src/Components/Form/AutoCompleteAsync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { useTranslation } from "react-i18next";

interface Props {
id?: string;
name?: string;
selected: any | any[];
fetchData: (search: string) => Promise<any> | undefined;
Expand All @@ -31,6 +32,7 @@ interface Props {

const AutoCompleteAsync = (props: Props) => {
const {
id,
name,
selected,
fetchData,
Expand Down Expand Up @@ -82,6 +84,7 @@ const AutoCompleteAsync = (props: Props) => {
<div className="relative mt-1">
<div className="flex">
<Combobox.Input
id={id}
name={name}
className="cui-input-base truncate pr-16"
placeholder={
Expand Down
4 changes: 3 additions & 1 deletion src/Components/Users/SkillsSlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default ({ show, setShow, username }: IProps) => {
{!isLoading && (
<div className="tooltip flex items-center gap-2">
<SkillSelect
id="select-skill"
multiple={false}
name="skill"
disabled={!authorizeForAddSkill}
Expand All @@ -128,6 +129,7 @@ export default ({ show, setShow, username }: IProps) => {
username={username}
/>
<ButtonV2
id="add-skill-button"
disabled={!authorizeForAddSkill}
onClick={() => addSkill(username, selectedSkill)}
className="w-6rem"
Expand All @@ -146,7 +148,7 @@ export default ({ show, setShow, username }: IProps) => {
<CircularProgress />
</div>
) : (
<div className="mb-2 mt-4">
<div className="mb-2 mt-4" id="added-user-skills">
{hasSkills ? (
<SkillsArray
isLoading={isLoading}
Expand Down
1 change: 1 addition & 0 deletions src/Components/Users/SkillsSlideOverComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const SkillsArray = ({
<div className="text-lg font-bold">{skill.skill_object.name}</div>
<div>
<ButtonV2
id="unlink-skill"
size="small"
variant="danger"
ghost={true}
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Users/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,10 @@ export default function UserProfile() {
Skills
</dt>
<dd className="mt-1 text-sm leading-5 text-gray-900">
<div className="flex flex-wrap gap-2">
<div
className="flex flex-wrap gap-2"
id="already-linked-skills"
>
{details.skills && details.skills.length
? details.skills?.map((skill: SkillObjectModel) => {
return (
Expand Down

0 comments on commit f7ac211

Please sign in to comment.