Skip to content

Commit

Permalink
Merge branch 'develop' into issues/8470/config-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Alok authored Nov 12, 2024
2 parents 24cdde9 + c0ffd4a commit b78b9b6
Show file tree
Hide file tree
Showing 38 changed files with 642 additions and 3,629 deletions.
17 changes: 0 additions & 17 deletions cypress/e2e/auth_spec/ForgotPassword.cy.ts

This file was deleted.

23 changes: 0 additions & 23 deletions cypress/e2e/auth_spec/auth.cy.ts

This file was deleted.

72 changes: 35 additions & 37 deletions cypress/e2e/facility_spec/FacilityManage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { v4 as uuidv4 } from "uuid";

import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import FacilityManage from "../../pageobject/Facility/FacilityManage";
import LoginPage from "../../pageobject/Login/LoginPage";
Expand All @@ -14,11 +12,10 @@ describe("Facility Manage Functions", () => {
const facilityUpdatedMiddleware = "updated.coronasafe.live";
const facilityMiddlewareSuccessfullNotification =
"Facility middleware updated successfully";
const facilityHfridUpdateButton = "Link Health Facility";
const facilityHfridToastNotificationText =
/Health Facility config updated successfully|Health ID registration failed/;
const facilityHfrId = "IN180000018";
const facilityUpdatedHfrId = uuidv4();
// const facilityHfridUpdateButton = "Link Health Facility";
// const facilityHfridToastNotificationText = /Health Facility config updated successfully|Health ID registration failed/;
// const facilityHfrId = "IN180000018";
// const facilityUpdatedHfrId = uuidv4();
const doctorCapacity = "5";
const doctorModifiedCapacity = "7";
const totalCapacity = "100";
Expand Down Expand Up @@ -79,36 +76,37 @@ describe("Facility Manage Functions", () => {
facilityManage.verifyMiddlewareAddressValue(facilityUpdatedMiddleware);
});

it("Configure Facility Health ID", () => {
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
// verify mandatory field error message
facilityManage.clearHfrId();
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.checkErrorMessageVisibility(
"Health Facility Id is required",
);
// add facility health ID and verify notification
facilityManage.typeHfrId(facilityHfrId);
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHfridToastNotificationText,
true,
);
// update the existing middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.typeHfrId(facilityUpdatedHfrId);
facilityManage.clickButtonWithText(facilityHfridUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHfridToastNotificationText,
true,
);
// verify its reflection
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyHfrIdValue(facilityUpdatedHfrId);
});
// TODO: enable this test after configuring testing specs for plugs
// it("Configure Facility Health ID", () => {
// facilityPage.clickManageFacilityDropdown();
// facilityManage.clickFacilityConfigureButton();
// // verify mandatory field error message
// facilityManage.clearHfrId();
// facilityManage.clickButtonWithText(facilityHfridUpdateButton);
// facilityManage.checkErrorMessageVisibility(
// "Health Facility Id is required",
// );
// // add facility health ID and verify notification
// facilityManage.typeHfrId(facilityHfrId);
// facilityManage.clickButtonWithText(facilityHfridUpdateButton);
// facilityManage.verifySuccessMessageVisibilityAndContent(
// facilityHfridToastNotificationText,
// true,
// );
// // update the existing middleware
// facilityPage.clickManageFacilityDropdown();
// facilityManage.clickFacilityConfigureButton();
// facilityManage.typeHfrId(facilityUpdatedHfrId);
// facilityManage.clickButtonWithText(facilityHfridUpdateButton);
// facilityManage.verifySuccessMessageVisibilityAndContent(
// facilityHfridToastNotificationText,
// true,
// );
// // verify its reflection
// facilityPage.clickManageFacilityDropdown();
// facilityManage.clickFacilityConfigureButton();
// facilityManage.verifyHfrIdValue(facilityUpdatedHfrId);
// });

it("Modify doctor capacity in Facility detail page", () => {
// Add a doctor capacity
Expand Down
48 changes: 48 additions & 0 deletions cypress/e2e/homepage_spec/UserLogin.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import LoginPage from "pageobject/Login/LoginPage";

const loginPage = new LoginPage();
const userName = "dummy_user_1";
const forgotPasswordHeading = "Forgot password?";

describe("User login workflow with correct and incorrect passwords", () => {
beforeEach(() => {
cy.awaitUrl("/", true);
});

it("Log in as admin with correct password", () => {
loginPage.loginManuallyAsDistrictAdmin();
loginPage.interceptFacilityReq();
loginPage.verifyFacilityReq();
loginPage.ensureLoggedIn();
loginPage.clickSignOutBtn();
loginPage.verifyLoginPageUrl();
});

it("Display an error when logging in as admin with incorrect password", () => {
loginPage.interceptLoginReq();
loginPage.loginManuallyAsDistrictAdmin(false);
loginPage.verifyLoginReq();
cy.verifyNotification("No active account found with the given credentials");
cy.closeNotification();
});
});

describe("Reset user's password using email", () => {
beforeEach(() => {
cy.awaitUrl("/", true);
});

it("Send a password reset link and navigate back to the login page", () => {
loginPage.clickForgotPasswordButton(forgotPasswordHeading);
loginPage.verifyForgotPasswordHeading([forgotPasswordHeading]);
loginPage.fillUserNameInForgotPasswordForm(userName);
loginPage.interceptResetLinkReq();
loginPage.clickSendResetLinkBtn();
loginPage.verifyResetLinkReq();
cy.verifyNotification("Password Reset Email Sent");
cy.closeNotification();
loginPage.clickBackButton();
loginPage.verifyLoginPageUrl();
loginPage.verifyLoginButtonPresence();
});
});
File renamed without changes.
2 changes: 1 addition & 1 deletion cypress/e2e/patient_spec/PatientInvestigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Patient Investigation Creation from Patient consultation page", () =>
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientInvestigation = new PatientInvestigation();
const patientName = "Dummy Patient 12";
const patientName = "Dummy Patient 14";

before(() => {
loginPage.loginAsDistrictAdmin();
Expand Down
33 changes: 19 additions & 14 deletions cypress/e2e/users_spec/UsersManage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ 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 = "devdoctor";
const usernameToLinkFacilitydoc1 = "dummydoctor4";
const usernameToLinkFacilitydoc2 = "dummydoctor5";
const usernameToLinkFacilitydoc3 = "dummydoctor6";
const usernameToLinkSkill = "devdoctor";
const firstNameUserSkill = "Dev";
const lastNameUserSkill = "Doctor";
const userCreationPage = new UserCreationPage();
const usernameforworkinghour = "devdistrictadmin";
const usernamerealname = "Dummy Doctor";
Expand Down Expand Up @@ -53,8 +55,11 @@ describe("Manage User", () => {

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);
userPage.clickAdvancedFilters();
userPage.typeInFirstName(firstNameUserSkill);
userPage.typeInLastName(lastNameUserSkill);
userPage.applyFilter();
userPage.checkUsernameText(usernameToLinkSkill);
manageUserPage.clicklinkedskillbutton();
manageUserPage.selectSkillFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
Expand Down Expand Up @@ -94,8 +99,8 @@ describe("Manage User", () => {

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);
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();
Expand All @@ -107,8 +112,8 @@ describe("Manage User", () => {
manageUserPage.clickCloseSlideOver();
// Link a new facility and ensure it is under home facility - doctor username (2)
userPage.clearSearchInput();
userPage.typeInSearchInput(usernametolinkfacilitydoc2);
userPage.checkUsernameText(usernametolinkfacilitydoc2);
userPage.typeInSearchInput(usernameToLinkFacilitydoc2);
userPage.checkUsernameText(usernameToLinkFacilitydoc2);
manageUserPage.clickFacilitiesTab();
manageUserPage.selectFacilityFromDropdown(facilitytolinkusername);
manageUserPage.clickLinkFacility();
Expand All @@ -118,13 +123,13 @@ describe("Manage User", () => {
manageUserPage.clickCloseSlideOver();
// verify the home facility doctor id have reflection in user card
userPage.clearSearchInput();
userPage.typeInSearchInput(usernametolinkfacilitydoc2);
userPage.checkUsernameText(usernametolinkfacilitydoc2);
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);
userPage.typeInSearchInput(usernameToLinkFacilitydoc3);
userPage.checkUsernameText(usernameToLinkFacilitydoc3);
manageUserPage.clickFacilitiesTab();
manageUserPage.selectFacilityFromDropdown(facilitytolinkusername);
manageUserPage.clickLinkFacility();
Expand Down
64 changes: 60 additions & 4 deletions cypress/pageobject/Login/LoginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ class LoginPage {
cy.loginByApi("staffdev", "Coronasafe@123");
}

loginManuallyAsDistrictAdmin(): void {
loginManuallyAsDistrictAdmin(isCorrectCredentials: boolean = true): void {
cy.get("input[id='username']").type("devdistrictadmin");
cy.get("input[id='password']").type("Coronasafe@123");
cy.get("button").contains("Login").click();
if (isCorrectCredentials) {
cy.get("input[id='password']").type("Coronasafe@123");
} else {
cy.get("input[id='password']").type("Corona");
}
cy.submitButton("Login");
}

loginManuallyAsNurse(): void {
cy.get("input[id='username']").click().type("dummynurse1");
cy.get("input[id='password']").click().type("Coronasafe@123");
cy.get("button").contains("Login").click();
cy.submitButton("Login");
}

login(username: string, password: string): void {
Expand All @@ -38,6 +42,58 @@ class LoginPage {
clickSignOutBtn(): void {
cy.verifyAndClickElement("#sign-out-button", "Sign Out");
}

fillUserNameInForgotPasswordForm(userName: string): void {
cy.get("#forgot_username").type(userName);
}

clickSendResetLinkBtn(): void {
cy.verifyAndClickElement("#send-reset-link-btn", "Send Reset Link");
}

verifyLoginPageUrl(): void {
cy.url().should("include", "/");
}

clickBackButton(): void {
cy.verifyAndClickElement("#back-to-login-btn", "Back to login");
}

clickForgotPasswordButton(text: string): void {
cy.verifyAndClickElement("#forgot-pass-btn", text);
}

interceptFacilityReq(): void {
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities");
}

verifyFacilityReq(): void {
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
}

interceptLoginReq(): void {
cy.intercept("POST", "**/api/v1/auth/login").as("userLogin");
}

verifyLoginReq(): void {
cy.wait("@userLogin").its("response.statusCode").should("eq", 401);
}

interceptResetLinkReq(): void {
cy.intercept("POST", "**/api/v1/password_reset").as("resetLink");
}

verifyResetLinkReq(): void {
cy.wait("@resetLink").its("response.statusCode").should("eq", 200);
}

verifyLoginButtonPresence(): void {
cy.verifyContentPresence("#login-button", ["Login"]);
}

verifyForgotPasswordHeading(text: string[]): void {
cy.verifyContentPresence("#forgot-password-heading", text);
}
}

export default LoginPage;
30 changes: 17 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ import HistoryAPIProvider from "@/Providers/HistoryAPIProvider";
import Routers from "@/Routers";
import { FeatureFlagsProvider } from "@/Utils/featureFlags";

import { PubSubProvider } from "./Utils/pubsubContext";

const App = () => {
return (
<Suspense fallback={<Loading />}>
<PluginEngine>
<HistoryAPIProvider>
<AuthUserProvider unauthorized={<Routers.SessionRouter />}>
<FeatureFlagsProvider>
<Routers.AppRouter />
</FeatureFlagsProvider>
</AuthUserProvider>
<PubSubProvider>
<PluginEngine>
<HistoryAPIProvider>
<AuthUserProvider unauthorized={<Routers.SessionRouter />}>
<FeatureFlagsProvider>
<Routers.AppRouter />
</FeatureFlagsProvider>
</AuthUserProvider>

{/* Integrations */}
<Integrations.Sentry disabled={!import.meta.env.PROD} />
<Integrations.Plausible />
</HistoryAPIProvider>
<Toaster />
</PluginEngine>
{/* Integrations */}
<Integrations.Sentry disabled={!import.meta.env.PROD} />
<Integrations.Plausible />
</HistoryAPIProvider>
<Toaster />
</PluginEngine>
</PubSubProvider>
</Suspense>
);
};
Expand Down
Loading

0 comments on commit b78b9b6

Please sign in to comment.