Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6771
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevildude authored Jan 13, 2024
2 parents 25bfea0 + 51b02c2 commit a61ae30
Show file tree
Hide file tree
Showing 65 changed files with 979 additions and 709 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
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
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();
});
});
50 changes: 50 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,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 +386,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 +453,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;
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
);
}
}
Loading

0 comments on commit a61ae30

Please sign in to comment.