Skip to content

Commit

Permalink
removed hard code
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Nov 29, 2024
1 parent 66c8064 commit cd7c551
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
11 changes: 4 additions & 7 deletions cypress/e2e/users_spec/UsersCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ describe("User Creation", () => {
const weeklyWorkingHrs = "14";
const dob = "01011998";
const formattedDob = "01/01/1998";
const updateBtn = "Update";
const saveBtn = "Save User";
const newUserDob = "25081999";

before(() => {
Expand Down Expand Up @@ -110,7 +108,7 @@ describe("User Creation", () => {
userProfilePage.typeWorkingHours(weeklyWorkingHrs);
userProfilePage.typeDateOfBirth(dob);
cy.intercept("PATCH", "/api/v1/users/*").as("updateUser");
cy.clickSubmitButton(updateBtn);
userProfilePage.clickUpdateButton();
cy.wait("@updateUser").its("response.statusCode").should("eq", 200);
cy.verifyContentPresence("#contactno-profile-details", [
"+91" + phoneNumber,
Expand All @@ -136,7 +134,7 @@ describe("User Creation", () => {
userProfilePage.clearPhoneNumber();
userProfilePage.clearAltPhoneNumber();
userProfilePage.clearWorkingHours();
cy.clickSubmitButton(updateBtn);
userProfilePage.clickUpdateButton();
userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES);
});

Expand All @@ -160,10 +158,9 @@ describe("User Creation", () => {
userCreationPage.selectState(state);
userCreationPage.selectDistrict(district);
cy.intercept("POST", "/api/v1/users/add_user/").as("createUser");
cy.clickSubmitButton(saveBtn);
userCreationPage.clickSaveUserButton();
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 @@ -177,7 +174,7 @@ describe("User Creation", () => {

it("create new user form throwing mandatory field error", () => {
userCreationPage.clickAddUserButton();
cy.clickSubmitButton(saveBtn);
userCreationPage.clickSaveUserButton();
cy.get(".error-text", { timeout: 10000 }).should("be.visible");
userCreationPage.verifyErrorMessages(EXPECTED_ERROR_MESSAGES);
});
Expand Down
7 changes: 2 additions & 5 deletions cypress/e2e/users_spec/UsersManage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { advanceFilters } from "pageobject/utils/advanceFilterHelpers";

import LoginPage from "../../pageobject/Login/LoginPage";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";
import { UserCreationPage } from "../../pageobject/Users/UserCreation";
import { UserPage } from "../../pageobject/Users/UserSearch";

describe("Manage User", () => {
Expand All @@ -15,7 +14,6 @@ describe("Manage User", () => {
const usernameToLinkSkill = "devdoctor";
const firstNameUserSkill = "Dev";
const lastNameUserSkill = "Doctor";
const userCreationPage = new UserCreationPage();
const usernameforworkinghour = "devdistrictadmin";
const usernamerealname = "Dummy Doctor";
const facilitytolinkusername = "Dummy Shifting Center";
Expand Down Expand Up @@ -48,10 +46,9 @@ describe("Manage User", () => {
manageUserPage.clickCloseSlideOver();
cy.wait(5000);
manageUserPage.navigateToProfile();
userCreationPage.verifyElementContainsText(
"username-profile-details",
cy.verifyContentPresence("username-profile-details", [
usernameforworkinghour,
);
]);
manageUserPage.assertSkillInAlreadyLinkedSkills(linkedskill);
});

Expand Down
3 changes: 0 additions & 3 deletions cypress/e2e/users_spec/UsersProfile.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ describe("Manage User Profile", () => {
userProfilePage.typeQualification(qualification);
userProfilePage.typeDoctorYoE(doctorYoE);
userProfilePage.typeMedicalCouncilRegistration(medicalCouncilRegistration);

userProfilePage.clickUpdateButton();

cy.verifyNotification("Details updated successfully");

userProfilePage.assertDateOfBirth("01/01/1999");
userProfilePage.assertGender(gender);
userProfilePage.assertEmail(email);
Expand Down
4 changes: 2 additions & 2 deletions cypress/pageobject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export class UserCreationPage {
cy.typeAndSelectOption("input[name='facilities']", name);
}

verifyElementContainsText(elementId: string, expectedText: string) {
cy.get("#" + elementId).should("contain.text", expectedText);
clickSaveUserButton() {
cy.clickSubmitButton("Save User");
}

verifyErrorMessages(errorMessages: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Users/UserProfilePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class UserProfilePage {
}

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

typeDateOfBirth(dob: string) {
Expand Down

0 comments on commit cd7c551

Please sign in to comment.