Skip to content

Commit

Permalink
Made requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnveshNalimela committed Nov 26, 2024
1 parent 54b420f commit 92fde8b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 94 deletions.
72 changes: 40 additions & 32 deletions cypress/e2e/users_spec/UsersCreation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import ManageUserPage from "pageobject/Users/ManageUserPage";
import UserProfilePage from "pageobject/Users/UserProfilePage";

import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import LoginPage from "../../pageobject/Login/LoginPage";
Expand All @@ -11,6 +14,8 @@ import {
describe("User Creation", () => {
const userPage = new UserPage();
const loginPage = new LoginPage();
const userProfilePage = new UserProfilePage();
const manageUserPage = new ManageUserPage();
const userCreationPage = new UserCreationPage();
const facilityPage = new FacilityPage();
const assetSearchPage = new AssetSearchPage();
Expand Down Expand Up @@ -87,25 +92,26 @@ describe("User Creation", () => {
});

it("Update the existing user profile and verify its reflection", () => {
userCreationPage.clickProfileName();
userCreationPage.clickProfileButton();
manageUserPage.navigateToProfile();
cy.verifyContentPresence("#username-profile-details", [userName]);
userCreationPage.clickEditProfileButton();
userProfilePage.clickEditProfileButton();
userCreationPage.clearFirstName();
userCreationPage.typeFirstName(firstName);
userCreationPage.clearLastName();
userCreationPage.typeLastName(lastName);
userCreationPage.selectGender(gender);
userCreationPage.clearPhoneNumber();
userCreationPage.typePhoneNumber(phone_number);
userCreationPage.clearAltPhoneNumber();
userCreationPage.typeAltPhoneNumber(emergency_phone_number);
userCreationPage.clearEmail();
userCreationPage.typeEmail(email);
userCreationPage.clearWeeklyWorkingHours();
userCreationPage.typeWeeklyWorkingHours(weeklyWorkingHrs);
userCreationPage.typeDateOfBirth(dob);
cy.submitButton(updateBtn);
userProfilePage.selectGender(gender);
userProfilePage.clearPhoneNumber();
userProfilePage.typePhoneNumber(phone_number);
userProfilePage.clearAltPhoneNumber();
userProfilePage.typeAltPhoneNumber(emergency_phone_number);
userProfilePage.clearEmail();
userProfilePage.typeEmail(email);
userProfilePage.clearWorkingHours();
userProfilePage.typeWorkingHours(weeklyWorkingHrs);
userProfilePage.typedate_of_birth(dob);
cy.intercept("PATCH", "/api/v1/users/*").as("updateUser");
cy.clickSubmitButton(updateBtn);
cy.wait("@updateUser").its("response.statusCode").should("eq", 200);
cy.verifyContentPresence("#contactno-profile-details", [
"+91" + phone_number,
]);
Expand All @@ -123,15 +129,14 @@ describe("User Creation", () => {
});

it("Update the existing user profile Form Mandatory File Error", () => {
userCreationPage.clickProfileName();
userCreationPage.clickProfileButton();
userCreationPage.clickEditProfileButton();
manageUserPage.navigateToProfile();
userProfilePage.clickEditProfileButton();
userCreationPage.clearFirstName();
userCreationPage.clearLastName();
userCreationPage.clearPhoneNumber();
userCreationPage.clearAltPhoneNumber();
userCreationPage.clearWeeklyWorkingHours();
cy.submitButton(updateBtn);
userProfilePage.clearPhoneNumber();
userProfilePage.clearAltPhoneNumber();
userProfilePage.clearWorkingHours();
cy.clickSubmitButton(updateBtn);
userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES);
});

Expand All @@ -140,22 +145,25 @@ describe("User Creation", () => {
userCreationPage.selectFacility(homeFacility);
userCreationPage.typeUserName(username);
userCreationPage.typePassword(password);
userCreationPage.typeConfirmPassword(password);
userCreationPage.selectHomeFacility(homeFacility);
userCreationPage.typeNewUserPhoneNumber(phone_number);
userCreationPage.typeDateOfBirth(newUserDob);
userPage.typeInPhoneNumber(phone_number);
userProfilePage.typedate_of_birth(newUserDob);
userCreationPage.selectUserType(role);
userCreationPage.typeConfirmPassword(password);
userCreationPage.typeQualification(qualification);
userCreationPage.typeDoctorExperience(experince);
userCreationPage.typeDoctorMedicalCouncilRegNo(regNo);
userCreationPage.typeNewUserFirstName(newUserFirstName);
userCreationPage.typeNewUserLastName(newUserLastName);
userCreationPage.typeEmail(email);
userProfilePage.typeQualification(qualification);
userProfilePage.typeDoctorYoE(experince);
userProfilePage.typeMedicalCouncilRegistration(regNo);
userPage.typeInFirstName(newUserFirstName);
userPage.typeInLastName(newUserLastName);
userProfilePage.typeEmail(email);
userCreationPage.selectGender(gender);
userCreationPage.selectState(state);
userCreationPage.selectDistrict(district);
cy.submitButton(saveBtn);
cy.intercept("POST", "/api/v1/users/add_user/").as("createUser");
cy.clickSubmitButton(saveBtn);
cy.wait("@createUser").its("response.statusCode").should("eq", 201);
cy.verifyNotification("User added successfully");

userPage.typeInSearchInput(username);
userPage.checkUsernameText(username);
cy.verifyContentPresence("#name", [newUserFirstName]);
Expand All @@ -169,7 +177,7 @@ describe("User Creation", () => {

it("create new user form throwing mandatory field error", () => {
userCreationPage.clickAddUserButton();
cy.submitButton(saveBtn);
cy.clickSubmitButton(saveBtn);
cy.get(".error-text", { timeout: 10000 }).should("be.visible");
userCreationPage.verifyErrorMessages(EXPECTED_ERROR_MESSAGES);
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/users_spec/UsersProfile.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ describe("Manage User Profile", () => {
userProfilePage.typedate_of_birth(date_of_birth);
userProfilePage.selectGender(gender);
userProfilePage.typeEmail(email);
userProfilePage.typePhone(phone);
userProfilePage.typeWhatsApp(phone);
userProfilePage.typePhoneNumber(phone);
userProfilePage.typeAltPhoneNumber(phone);
userProfilePage.typeWorkingHours(workinghours);
userProfilePage.typeQualification(qualification);
userProfilePage.typeDoctorYoE(doctorYoE);
Expand Down
58 changes: 0 additions & 58 deletions cypress/pageobject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
// UserCreation.ts
export class UserCreationPage {
clickProfileName() {
cy.get("#user-profile-name").click();
}
clickProfileButton() {
cy.verifyAndClickElement("#profile-button", "Profile");
}
clickEditProfileButton() {
cy.verifyAndClickElement("#edit-cancel-profile-button", "Edit Profile");
}
clickAddUserButton() {
cy.verifyAndClickElement("#addUserButton", "Add New User");
}
Expand All @@ -21,64 +12,18 @@ export class UserCreationPage {
typeLastName(lastName: string) {
cy.get("#lastName").click().type(lastName);
}
typeEmail(email: string) {
cy.get("#email").click().type(email);
}
typePassword(password: string) {
cy.get("#password").click().type(password);
}
typePhoneNumber(phone_number: string) {
cy.get("#phoneNumber").click().type(phone_number);
}
typeConfirmPassword(password: string) {
cy.get("#c_password").click().type(password);
}
typeQualification(qualification: string) {
cy.get("#qualification").click().type(qualification);
}
typeDoctorExperience(experience: string) {
cy.get("#doctor_experience_commenced_on").click().type(experience);
}
typeDoctorMedicalCouncilRegNo(regNo: string) {
cy.get("#doctor_medical_council_registration").click().type(regNo);
}
typeWeeklyWorkingHours(workingHrs: string) {
cy.get("#weekly_working_hours").click().type(workingHrs);
}
typeAltPhoneNumber(emergencyPhoneNumber: string) {
cy.get("#altPhoneNumber").click().type(emergencyPhoneNumber);
}
typeDateOfBirth(dob: string) {
cy.clickAndTypeDate("#date_of_birth", dob);
}
typeNewUserFirstName(firstName: string) {
cy.get("#first_name").click().type(firstName);
}
typeNewUserLastName(lastName: string) {
cy.get("#last_name").click().type(lastName);
}
typeNewUserPhoneNumber(phoneNumber: string) {
cy.get("#phone_number").click().type(phoneNumber);
}
clearFirstName() {
cy.get("#firstName").click().clear();
}
clearLastName() {
cy.get("#lastName").click().clear();
}
clearPhoneNumber() {
cy.get("#phoneNumber").click().clear();
}
clearAltPhoneNumber() {
cy.get("#altPhoneNumber").click().clear();
}
clearWeeklyWorkingHours() {
cy.get("#weekly_working_hours").click().clear();
}
clearEmail() {
cy.get("#email").click().clear();
}

selectUserType(role: string) {
cy.clickAndSelectOption("#user_type", role);
}
Expand All @@ -98,9 +43,6 @@ export class UserCreationPage {

selectFacility(name: string) {
cy.typeAndSelectOption("input[name='facilities']", name);
cy.get("input[name='facilities'] + button")
.find("#dropdown-toggle")
.click();
}

verifyElementContainsText(elementId: string, expectedText: string) {
Expand Down
17 changes: 15 additions & 2 deletions cypress/pageobject/Users/UserProfilePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ export default class UserProfilePage {
cy.clickAndTypeDate("#date_of_birth", date_of_birth);
}

clearPhoneNumber() {
cy.get("#phoneNumber").click().clear();
}
clearAltPhoneNumber() {
cy.get("#altPhoneNumber").click().clear();
}
clearWorkingHours() {
cy.get("#weekly_working_hours").click().clear();
}
clearEmail() {
cy.get("#email").click().clear();
}

selectGender(gender: string) {
cy.get("#gender").click();
cy.get("#gender-option-" + gender).click();
Expand All @@ -28,11 +41,11 @@ export default class UserProfilePage {
cy.get("#email").click().clear().type(email);
}

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

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

Expand Down

0 comments on commit 92fde8b

Please sign in to comment.