Skip to content

Commit

Permalink
Merge branch 'develop' into add-more-symptoms
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Jan 18, 2024
2 parents 9efc06f + df758d2 commit be4fa7d
Show file tree
Hide file tree
Showing 96 changed files with 1,599 additions and 1,800 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
104 changes: 104 additions & 0 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import FacilityManage from "../../pageobject/Facility/FacilityManage";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import { v4 as uuidv4 } from "uuid";

describe("Facility Manage Functions", () => {
const loginPage = new LoginPage();
const facilityManage = new FacilityManage();
const facilityPage = new FacilityPage();
const facilityMiddlewareUpdateButton = "Update";
const facilityMiddleware = "dev-middleware.coronasafe.live";
const facilityUpdatedMiddleware = "updated.coronasafe.live";
const facilityMiddlewareSuccessfullNotification =
"Facility updated successfully";
const facilityHrfidUpdateButton = "Link Health Facility";
const facilityHrfidSuccessfullNotification =
"Health Facility config updated successfully";
const facilityHrfId = uuidv4();
const facilityUpdatedHrfId = uuidv4();

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

beforeEach(() => {
cy.viewport(1280, 720);
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
facilityPage.visitAlreadyCreatedFacility();
});

it("Facility Cover Image button functionality", () => {
// It's only button functionality because we can't access S3 bucket in local
facilityManage.clickCoverImage();
facilityManage.verifyUploadButtonVisible();
facilityManage.uploadCoverImage("facilitycoverimage.jpg");
facilityManage.clickSaveCoverImage();
});

it("Configure Facility Middleware", () => {
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyMiddlewareAddressVisible();
// verify mandatory field error message
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.checkErrorMessageVisibility(
"Middleware Address is required"
);
// add middleware and verify the notification
facilityManage.typeMiddlewareAddress(facilityMiddleware);
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityMiddlewareSuccessfullNotification
);
// update the existing middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyMiddlewareAddressVisible();
facilityManage.typeMiddlewareAddress(facilityUpdatedMiddleware);
facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityMiddlewareSuccessfullNotification
);
// verify the updated middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyMiddlewareAddressValue(facilityUpdatedMiddleware);
});

it("Configure Facility Health ID", () => {
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
// verify mandatory field error message
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.checkErrorMessageVisibility(
"Health Facility Id is required"
);
// add facility health ID and verify notification
facilityManage.typeHrfId(facilityHrfId);
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHrfidSuccessfullNotification
);
// update the existing middleware
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.typeHrfId(facilityUpdatedHrfId);
facilityManage.clickButtonWithText(facilityHrfidUpdateButton);
facilityManage.verifySuccessMessageVisibilityAndContent(
facilityHrfidSuccessfullNotification
);
// verify its reflection
facilityPage.clickManageFacilityDropdown();
facilityManage.clickFacilityConfigureButton();
facilityManage.verifyHrfIdValue(facilityUpdatedHrfId);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
56 changes: 52 additions & 4 deletions cypress/e2e/facility_spec/inventory.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import LoginPage from "../../pageobject/Login/LoginPage";
import FacilityHome from "../../pageobject/Facility/FacilityHome";

describe("Inventory Management Section", () => {
const facilityPage = new FacilityPage();
const loginPage = new LoginPage();
const facilityHome = new FacilityHome();

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand All @@ -16,18 +18,64 @@ describe("Inventory Management Section", () => {
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
cy.viewport(1280, 720);
});

it("Adds Inventory", () => {
facilityPage.visitAlreadyCreatedFacility();
facilityPage.clickManageFacilityDropdown();
facilityPage.clickInventoryManagementOption();
});

it("Add New Inventory | Modify data and delete last entry ", () => {
// add a new item
facilityPage.clickManageInventory();
facilityPage.fillInventoryDetails("Liquid Oxygen", "Add Stock", "120");
facilityPage.fillInventoryDetails("PPE", "Add Stock", "10");
facilityPage.clickAddInventory();
facilityPage.verifySuccessNotification("Inventory created successfully");
facilityPage.clickManageInventory();
// modify the new item
facilityPage.fillInventoryDetails("PPE", "Use Stock", "5");
facilityPage.clickAddInventory();
facilityPage.verifySuccessNotification("Inventory created successfully");
// verify the new modification
facilityPage.verifyPpeQuantity("PPE");
facilityPage.verifyPpeQuantity("5");
// delete the last Entry
facilityPage.clickPpeQuantity();
facilityPage.clickLastEntry();
// verify the last entry deletion
facilityPage.verifyStockInRow("#row-0", "Added Stock");
facilityPage.verifyStockInRow("#row-1", "Used Stock");
cy.wait(3000);
facilityHome.navigateBack();
facilityPage.verifyPpeQuantity("PPE");
});

it("Add New Inventory | Verify Backend and manual Minimum", () => {
// Add Inventory
facilityPage.clickManageInventory();
facilityPage.fillInventoryDetails("PPE", "Add Stock", "5");
facilityPage.clickAddInventory();
facilityPage.verifySuccessNotification("Inventory created successfully");
// Verify Backend minimum badge
facilityPage.verifyBadgeWithText(".badge-danger", "Low Stock");
// modify with manual minimum badge
facilityPage.clickAddMinimumQuanitity();
cy.wait(3000);
cy.get("body").then(($body) => {
if ($body.find("#update-minimum-quantity").is(":visible")) {
// If the 'update-minimum-quantity' element is visible, click it
facilityPage.clickUpdateMinimumQuantity();
facilityPage.setQuantity("5");
facilityPage.clickSaveUpdateMinimumQuantity();
} else {
// Otherwise, click the 'set-minimum-quantity' element
facilityPage.clickSetMinimumQuantity();
facilityPage.fillInventoryMinimumDetails("PPE", "1");
facilityPage.clickSetButton();
facilityPage.verifySuccessNotification(
"Minimum quantiy updated successfully"
);
}
});
});
afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
11 changes: 3 additions & 8 deletions cypress/e2e/facility_spec/locations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import FacilityLocation from "../../pageobject/Facility/FacilityLocation";
import { AssetPagination } from "../../pageobject/Asset/AssetPagination";
import FacilityHome from "../../pageobject/Facility/FacilityHome";


describe("Location Management Section", () => {
const assetPage = new AssetPage();
const userCreationPage = new UserCreationPage();
Expand Down Expand Up @@ -51,13 +50,9 @@ describe("Location Management Section", () => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities");
cy.get("[id='facility-details']").first().click();
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
cy.get("h1.text-3xl.font-bold", { timeout: 10000 }).should("be.visible");
cy.get("#manage-facility-dropdown button").should("be.visible");
cy.get("[id='manage-facility-dropdown']").scrollIntoView().click();
cy.get("[id=location-management]").click();
facilityPage.visitAlreadyCreatedFacility();
facilityPage.clickManageFacilityDropdown();
facilityLocation.clickFacilityLocationManagement();
});

it("Add a Bed to facility location along with duplication and deleting a bed", () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/patient_spec/patient_crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
emergency_phone_number,
phone_number,
} from "../../pageobject/constants";
const yearOfBirth = "2023";
const yearOfBirth = "2001";

const calculateAge = () => {
const currentYear = new Date().getFullYear();
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 = "[email protected]";
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();
});
});
Binary file added cypress/fixtures/facilitycoverimage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ class FacilityPage {
cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities");
cy.get("[id='facility-details']").first().click();
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
cy.get("h1.text-3xl.font-bold", { timeout: 10000 }).should("be.visible");
}

verifyFacilityBadgeContent(expectedText: string) {
Expand Down Expand Up @@ -372,6 +373,12 @@ class FacilityPage {
cy.get("[name='quantity']").type(quantity);
}

fillInventoryMinimumDetails(name: string, quantity: string) {
cy.get("div#id").click();
cy.get("div#id ul li").contains(name).click();
cy.get("[name='quantity']").type(quantity);
}

clickAddInventory() {
cy.intercept("POST", "**/api/v1/facility/*/inventory/").as(
"createInventory"
Expand All @@ -380,6 +387,10 @@ class FacilityPage {
cy.wait("@createInventory").its("response.statusCode").should("eq", 201);
}

clickSetButton() {
cy.get("#submit").contains("Set").click();
}

fillResourceRequestDetails(
name: string,
phone_number: string,
Expand Down Expand Up @@ -443,6 +454,46 @@ class FacilityPage {
}
});
}

verifyPpeQuantity(text: string) {
cy.get("#PPE").contains(text).should("be.visible");
}

clickPpeQuantity() {
cy.get("#PPE").click();
}

clickLastEntry() {
cy.get("#delete-last-entry").click();
}

verifyStockInRow(rowId: string, stockText: string) {
cy.get(rowId).contains(stockText).should("be.visible");
}

verifyBadgeWithText(badgeClass: string, text: string) {
cy.get(badgeClass).contains(text).should("exist");
}

clickAddMinimumQuanitity() {
cy.get("#add-minimum-quantity").click();
}

clickUpdateMinimumQuantity() {
cy.get("#update-minimum-quantity").first().click();
}

setQuantity(quantity: string) {
cy.get("#quantity").click().clear().click().type(quantity);
}

clickSaveUpdateMinimumQuantity() {
cy.get("#save-update-minimumquanitity").click();
}

clickSetMinimumQuantity() {
cy.get("#set-minimum-quantity").click();
}
}

export default FacilityPage;
Loading

0 comments on commit be4fa7d

Please sign in to comment.