Skip to content

Commit

Permalink
Merge pull request #7047 from coronasafe/develop
Browse files Browse the repository at this point in the history
Production Release | January Week 3
  • Loading branch information
gigincg committed Jan 16, 2024
2 parents 4ea00ba + 51b02c2 commit d55143d
Show file tree
Hide file tree
Showing 52 changed files with 796 additions and 618 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Authenticate to staging API with any of the following credentials

- username: staffdev
password: Coronasafe@123
role: Staff
role: Nurse

- username: doctordev
password: Coronasafe@123
Expand Down
85 changes: 85 additions & 0 deletions cypress/e2e/users_spec/user_profile.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import UserProfilePage from "../../pageobject/Users/UserProfilePage";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";

describe("Manage User Profile", () => {
const loginPage = new LoginPage();
const userProfilePage = new UserProfilePage();
const manageUserPage = new ManageUserPage();

const age = "30";
const gender = "Male";
const email = "test@example.com";
const phone = "+918899887788";
const workinghours = "8";
const doctorQualification = "MBBS";
const doctorYoE = "10";
const medicalCouncilRegistration = "1234567890";

const facilitySearch = "Dummy Facility 1";

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

beforeEach(() => {
cy.restoreLocalStorage();
console.log(localStorage);
cy.clearLocalStorage(/filters--.+/);
console.log(localStorage);
cy.awaitUrl("/user/profile");
});

it("Set Age, Gender, Email, Phone and Working Hours for a user and verify its reflection in user profile", () => {
userProfilePage.clickEditProfileButton();

userProfilePage.typeAge(age);
userProfilePage.selectGender(gender);
userProfilePage.typeEmail(email);
userProfilePage.typePhone(phone);
userProfilePage.typeWhatsApp(phone);
userProfilePage.typeWorkingHours(workinghours);
userProfilePage.typeDoctorQualification(doctorQualification);
userProfilePage.typeDoctorYoE(doctorYoE);
userProfilePage.typeMedicalCouncilRegistration(medicalCouncilRegistration);

userProfilePage.clickUpdateButton();

cy.verifyNotification("Details updated successfully");

userProfilePage.assertAge(age);
userProfilePage.assertGender(gender);
userProfilePage.assertEmail(email);
userProfilePage.assertPhone(phone);
userProfilePage.assertWhatsApp(phone);
userProfilePage.assertWorkingHours(workinghours);
});

it("Adding video connect link for a user and verify its reflection in user profile and doctor connect", () => {
// verify the user doesn't have any video connect link
userProfilePage.assertVideoConnectLink("-");
// Link a new video connect link and ensure it is under video connect link
userProfilePage.clickEditProfileButton();
userProfilePage.typeVideoConnectLink("https://www.example.com");
userProfilePage.clickUpdateButton();
userProfilePage.assertVideoConnectLink("https://www.example.com");
// Edit the video connect link and ensure it is updated
userProfilePage.clickEditProfileButton();
userProfilePage.typeVideoConnectLink("https://www.test.com");
userProfilePage.clickUpdateButton();
userProfilePage.assertVideoConnectLink("https://www.test.com");
// Go to particular facility doctor connect and verify the video connect link is present
manageUserPage.navigateToFacility();
manageUserPage.typeFacilitySearch(facilitySearch);
manageUserPage.assertFacilityInCard(facilitySearch);
manageUserPage.clickFacilityPatients();
manageUserPage.clickDoctorConnectButton();
manageUserPage.assertVideoConnectLink("Dev Doctor", "https://www.test.com");
});

afterEach(() => {
cy.saveLocalStorage();
});
});
4 changes: 4 additions & 0 deletions cypress/pageobject/Login/LoginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class LoginPage {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
}

loginAsDevDoctor(): void {
cy.loginByApi("devdoctor", "Coronasafe@123");
}

login(username: string, password: string): void {
cy.loginByApi(username, password);
}
Expand Down
12 changes: 12 additions & 0 deletions cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ export class ManageUserPage {
cy.get("#doctor-connect-home-doctor").should("contain.text", realName);
cy.get("#doctor-connect-remote-doctor").should("contain.text", realName);
}

assertVideoConnectLink(docName: string, link: string) {
cy.get("ul#options")
.find("li")
.contains(docName)
.within(() => {
cy.get("a").should(($a) => {
const hrefs = $a.map((i, el) => Cypress.$(el).attr("href")).get();
expect(hrefs).to.include(link);
});
});
}
}

export default ManageUserPage;
84 changes: 84 additions & 0 deletions cypress/pageobject/Users/UserProfilePage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
export default class UserProfilePage {
assertVideoConnectLink(link: string) {
cy.get("#videoconnectlink-profile-details").should("contain.text", link);
}

clickEditProfileButton() {
cy.get("#edit-cancel-profile-button").click();
}

typeVideoConnectLink(link: string) {
cy.get("#video_connect_link").click().clear().type(link);
}

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

typeAge(age: string) {
cy.get("#age").click().clear().type(age);
}

selectGender(gender: string) {
cy.get("#gender").click();
cy.get("#gender-option-" + gender).click();
}

typeEmail(email: string) {
cy.get("#email").click().clear().type(email);
}

typePhone(phone: string) {
cy.get("#phoneNumber").click().clear().type(phone);
}

typeWhatsApp(phone: string) {
cy.get("#altPhoneNumber").click().clear().type(phone);
}

typeWorkingHours(workinghours: string) {
cy.get("#weekly_working_hours").click().clear().type(workinghours);
}

typeDoctorQualification = (doctorQualification: string) => {
cy.get("#doctor_qualification").click().clear().type(doctorQualification);
};

typeDoctorYoE = (doctorYoE: string) => {
cy.get("#doctor_experience_commenced_on").click().clear().type(doctorYoE);
};

typeMedicalCouncilRegistration = (medicalCouncilRegistration: string) => {
cy.get("#doctor_medical_council_registration")
.click()
.clear()
.type(medicalCouncilRegistration);
};

assertAge(age: string) {
cy.get("#age-profile-details").should("contain.text", age);
}

assertGender(gender: string) {
cy.get("#gender-profile-details").should("contain.text", gender);
}

assertEmail(email: string) {
cy.get("#emailid-profile-details").should("contain.text", email);
}

assertPhone(phone: string) {
cy.get("#contactno-profile-details").should("contain.text", phone);
}

assertWhatsApp(phone: string) {
cy.get("#whatsapp-profile-details").should("contain.text", phone);
}

assertWorkingHours(workinghours: string) {
cy.get("#averageworkinghour-profile-details").should(
"contain.text",
workinghours
);
}
}
34 changes: 11 additions & 23 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export type UserRole =
| "Volunteer"
| "StaffReadOnly"
| "Staff"
| "NurseReadOnly"
| "Nurse"
| "Doctor"
| "WardAdmin"
| "LocalBodyAdmin"
Expand All @@ -47,6 +49,8 @@ export const USER_TYPE_OPTIONS: {
{ id: "Volunteer", role: "Volunteer", readOnly: false },
{ id: "StaffReadOnly", role: "Staff", readOnly: true },
{ id: "Staff", role: "Staff", readOnly: false },
{ id: "NurseReadOnly", role: "Nurse", readOnly: true },
{ id: "Nurse", role: "Nurse", readOnly: false },
{ id: "Doctor", role: "Doctor", readOnly: false },
{ id: "WardAdmin", role: "Ward Admin", readOnly: false },
{ id: "LocalBodyAdmin", role: "Local Body Admin", readOnly: false },
Expand Down Expand Up @@ -294,10 +298,10 @@ export const SYMPTOM_CHOICES = [
];

export const DISCHARGE_REASONS = [
{ id: "REC", text: "Recovered" },
{ id: "EXP", text: "Expired" },
{ id: "REF", text: "Referred" },
{ id: "LAMA", text: "LAMA" },
{ id: 1, text: "Recovered" },
{ id: 2, text: "Referred" },
{ id: 3, text: "Expired" },
{ id: 4, text: "LAMA" },
];

export const CONSCIOUSNESS_LEVEL = [
Expand Down Expand Up @@ -418,24 +422,6 @@ export const SAMPLE_FLOW_RULES = {
RECEIVED_AT_LAB: ["COMPLETED"],
};

export const ROLE_STATUS_MAP = {
Staff: ["SENT_TO_COLLECTON_CENTRE"],
DistrictAdmin: [
"APPROVED",
"DENIED",
"SENT_TO_COLLECTON_CENTRE",
"RECEIVED_AND_FORWARED",
],
StateLabAdmin: [
"APPROVED",
"DENIED",
"SENT_TO_COLLECTON_CENTRE",
"RECEIVED_AND_FORWARED",
"RECEIVED_AT_LAB",
"COMPLETED",
],
};

export const DISEASE_STATUS = [
"POSITIVE",
"SUSPECTED",
Expand Down Expand Up @@ -1042,6 +1028,8 @@ export const USER_TYPES_MAP = {
StaffReadOnly: "Staff",
Staff: "Staff",
Doctor: "Doctor",
Nurse: "Nurse",
NurseReadOnly: "Nurse",
WardAdmin: "Ward Admin",
LocalBodyAdmin: "Local Body Admin",
DistrictLabAdmin: "District Lab Admin",
Expand All @@ -1051,7 +1039,7 @@ export const USER_TYPES_MAP = {
StateReadOnlyAdmin: "State Admin",
StateAdmin: "State Admin",
RemoteSpecialist: "Remote Specialist",
};
} as const;

export const AREACODES: Record<string, string[]> = {
CA: [
Expand Down
14 changes: 10 additions & 4 deletions src/Common/hooks/useFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useQueryParams } from "raviger";
import { QueryParam, setQueryParamsOptions, useQueryParams } from "raviger";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import GenericFilterBadge from "../../CAREUI/display/FilterBadge";
Expand All @@ -23,7 +23,15 @@ export default function useFilters({ limit = 14 }: { limit?: number }) {
const { kasp_string } = useConfig();
const hasPagination = limit > 0;
const [showFilters, setShowFilters] = useState(false);
const [qParams, setQueryParams] = useQueryParams();
const [qParams, _setQueryParams] = useQueryParams();

const setQueryParams = (
query: QueryParam,
options?: setQueryParamsOptions
) => {
_setQueryParams(query, options);
updateFiltersCache(query);
};

const updateQuery = (filter: FilterState) => {
filter = hasPagination ? { page: 1, limit, ...filter } : filter;
Expand All @@ -38,8 +46,6 @@ export default function useFilters({ limit = 14 }: { limit?: number }) {
};
const removeFilter = (param: string) => removeFilters([param]);

useEffect(() => updateFiltersCache(qParams), [qParams]);

useEffect(() => {
const cache = getFiltersCache();
const qParamKeys = Object.keys(qParams);
Expand Down
10 changes: 5 additions & 5 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getDate = (value: any) =>

function AssetFilter(props: any) {
const { filter, onChange, closeFilter, removeFilters } = props;
const [facility, setFacility] = useState<FacilityModel>({ name: "" });
const [facility, setFacility] = useState<FacilityModel | null>(null);
const [asset_type, setAssetType] = useState<string>(
filter.asset_type ? filter.asset_type : ""
);
Expand Down Expand Up @@ -51,7 +51,7 @@ function AssetFilter(props: any) {
setLocationId(
facility?.id === qParams.facility ? qParams.location ?? "" : ""
);
}, [facility.id, qParams.facility, qParams.location]);
}, [facility?.id, qParams.facility, qParams.location]);

const clearFilter = useCallback(() => {
removeFilters([
Expand Down Expand Up @@ -81,8 +81,8 @@ function AssetFilter(props: any) {
onChange(data);
};

const handleFacilitySelect = (selected: FacilityModel) => {
setFacility(selected ? selected : facility);
const handleFacilitySelect = (selected: FacilityModel | null) => {
setFacility(selected);
handleLocationSelect("");
};
const handleLocationSelect = (selectedId: string) => {
Expand All @@ -107,7 +107,7 @@ function AssetFilter(props: any) {
<FacilitySelect
name="Facilities"
setSelected={(selected) =>
handleFacilitySelect(selected as FacilityModel)
handleFacilitySelect(selected as FacilityModel | null)
}
selected={facility}
errors=""
Expand Down
9 changes: 4 additions & 5 deletions src/Components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,14 @@ export const Login = (props: { forgot?: boolean }) => {

const handleSubmit = async (e: any) => {
e.preventDefault();

setLoading(true);
invalidateFiltersCache();

const validated = validateData();
if (!validated) return;

if (!validated) {
setLoading(false);
return;
}
const { res } = await signIn(validated);

setCaptcha(res?.status === 429);
setLoading(false);
};
Expand Down

1 comment on commit d55143d

@vercel
Copy link

@vercel vercel bot commented on d55143d Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

care-storybook – ./

care-storybook-ohcnetwork.vercel.app
care-storybook-git-master-ohcnetwork.vercel.app

Please sign in to comment.