From e98e99f4b7cb0ee3628344049a11f3da62ead4f5 Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Fri, 25 Oct 2024 23:53:55 +0530 Subject: [PATCH 01/23] removed ClickElementById function from UsersCreation.cy.ts --- .env | 1 + cypress/e2e/users_spec/UsersCreation.cy.ts | 27 +++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.env b/.env index ebc0ebd5be3..6d36d4959ad 100644 --- a/.env +++ b/.env @@ -15,3 +15,4 @@ CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3 REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn" REACT_ENABLED_APPS="ohcnetwork/care_livekit_fe@main" +REACT_CARE_API_URL=http://127.0.0.1:9000 diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index 392c9ff987d..a0aa9f9e403 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -1,11 +1,11 @@ -import LoginPage from "../../pageobject/Login/LoginPage"; import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; -import { UserPage } from "../../pageobject/Users/UserSearch"; +import LoginPage from "../../pageobject/Login/LoginPage"; import { UserCreationPage } from "../../pageobject/Users/UserCreation"; +import { UserPage } from "../../pageobject/Users/UserSearch"; import { - generatePhoneNumber, generateEmergencyPhoneNumber, + generatePhoneNumber, } from "../../pageobject/utils/constants"; describe("User Creation", () => { @@ -66,13 +66,13 @@ describe("User Creation", () => { }); it("Update the existing user profile and verify its reflection", () => { - userCreationPage.clickElementById("user-profile-name"); - userCreationPage.clickElementById("profile-button"); + cy.get("#user-profile-name").click(); + cy.get("#profile-button").click(); userCreationPage.verifyElementContainsText( "username-profile-details", "devdistrictadmin", ); - userCreationPage.clickElementById("edit-cancel-profile-button"); + cy.get("#edit-cancel-profile-button").click(); userCreationPage.typeIntoElementByIdPostClear( "firstName", "District Editted", @@ -90,7 +90,7 @@ describe("User Creation", () => { "date_of_birth", "01011998", ); - userCreationPage.clickElementById("submit"); + cy.submitButton("Update"); userCreationPage.verifyElementContainsText( "contactno-profile-details", "+91" + phone_number, @@ -126,15 +126,16 @@ describe("User Creation", () => { }); it("Update the existing user profile Form Mandatory File Error", () => { - userCreationPage.clickElementById("user-profile-name"); - userCreationPage.clickElementById("profile-button"); - userCreationPage.clickElementById("edit-cancel-profile-button"); + cy.get("#user-profile-name").click(); + cy.get("#profile-button").click(); + cy.get("#edit-cancel-profile-button").click(); + userCreationPage.clearIntoElementById("firstName"); userCreationPage.clearIntoElementById("lastName"); userCreationPage.clearIntoElementById("phoneNumber"); userCreationPage.clearIntoElementById("altPhoneNumber"); userCreationPage.clearIntoElementById("weekly_working_hours"); - userCreationPage.clickElementById("submit"); + cy.submitButton("Update"); userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES); }); @@ -180,8 +181,8 @@ describe("User Creation", () => { }); it("create new user form throwing mandatory field error", () => { - userCreationPage.clickElementById("addUserButton"); - userCreationPage.clickElementById("submit"); + cy.get("#addUserButton").click(); + cy.submitButton("Save User"); cy.wait(2000); userCreationPage.verifyErrorMessages(EXPECTED_ERROR_MESSAGES); }); From 547992139cada9ab283c9b67f6ea22d86984b562 Mon Sep 17 00:00:00 2001 From: Anvesh Nalimela <151531961+AnveshNalimela@users.noreply.github.com> Date: Sun, 27 Oct 2024 09:54:27 +0530 Subject: [PATCH 02/23] Update .env --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 6d36d4959ad..5bda12fcf71 100644 --- a/.env +++ b/.env @@ -15,4 +15,4 @@ CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3 REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn" REACT_ENABLED_APPS="ohcnetwork/care_livekit_fe@main" -REACT_CARE_API_URL=http://127.0.0.1:9000 + From d47a6767d52dbe4556f88e179cb1a296c97be0be Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Sun, 27 Oct 2024 10:25:14 +0530 Subject: [PATCH 03/23] Removed ClickELementById from userCreation.ts --- cypress/e2e/users_spec/UsersCreation.cy.ts | 4 ++-- cypress/pageobject/Users/UserCreation.ts | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index a0aa9f9e403..b25a8f16f62 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -140,7 +140,7 @@ describe("User Creation", () => { }); it("create new user and verify reflection", () => { - userCreationPage.clickElementById("addUserButton"); + cy.get("#addUserButton").click(); userCreationPage.selectFacility("Dummy Shifting Center"); userCreationPage.typeIntoElementById("username", username); userCreationPage.typeIntoElementById("password", "Test@123"); @@ -161,7 +161,7 @@ describe("User Creation", () => { userCreationPage.selectDropdownOption("gender", "Male"); userCreationPage.selectDropdownOption("state", "Kerala"); userCreationPage.selectDropdownOption("district", "Ernakulam"); - userCreationPage.clickElementById("submit"); + cy.get("#submit").click(); userCreationPage.verifyNotification("User added successfully"); userPage.typeInSearchInput(username); userPage.checkUsernameText(username); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 7503ea3fb07..a8b1a4d9585 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -1,9 +1,5 @@ // UserCreation.ts export class UserCreationPage { - clickElementById(elementId: string) { - cy.get("#" + elementId).click(); - } - typeIntoElementById(elementId: string, value: string) { cy.get("#" + elementId) .click() @@ -50,7 +46,7 @@ export class UserCreationPage { } selectHomeFacility(name: string) { - this.clickElementById("home_facility"); + cy.get("#home_facility").click(); this.selectOptionContainingText(name); } @@ -59,12 +55,12 @@ export class UserCreationPage { inputElementId: string, dateValue: string, ) { - this.clickElementById(dateElementId); + cy.get("#" + dateElementId).click(); this.typeIntoElementById(inputElementId, dateValue); } selectDropdownOption(dropdownId: string, optionText: string) { - this.clickElementById(dropdownId); + cy.get("#" + dropdownId).click(); this.selectOptionContainingText(optionText); } From a1ac783230155d020548b8f0964df52b52367efe Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Sun, 27 Oct 2024 10:25:48 +0530 Subject: [PATCH 04/23] updated .env --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 6d36d4959ad..5bda12fcf71 100644 --- a/.env +++ b/.env @@ -15,4 +15,4 @@ CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3 REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn" REACT_ENABLED_APPS="ohcnetwork/care_livekit_fe@main" -REACT_CARE_API_URL=http://127.0.0.1:9000 + From 2d81b26afb142df22ade72dc1c4b0682003560a9 Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Mon, 28 Oct 2024 00:51:19 +0530 Subject: [PATCH 05/23] Added functions in pageobject/usercreation.ts according to POM approch --- .env | 3 +-- cypress/e2e/users_spec/UsersCreation.cy.ts | 18 +++++++++--------- cypress/pageobject/Users/UserCreation.ts | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.env b/.env index 5bda12fcf71..d09f2f6c653 100644 --- a/.env +++ b/.env @@ -14,5 +14,4 @@ ESLINT_NO_DEV_ERRORS=true CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3-patient-data-10bedicu.s3.amazonaws.com http://localhost:4566" REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn" -REACT_ENABLED_APPS="ohcnetwork/care_livekit_fe@main" - +REACT_ENABLED_APPS="ohcnetwork/care_livekit_fe@main" \ No newline at end of file diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index b25a8f16f62..cfce8ba8675 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -66,13 +66,13 @@ describe("User Creation", () => { }); it("Update the existing user profile and verify its reflection", () => { - cy.get("#user-profile-name").click(); - cy.get("#profile-button").click(); + userCreationPage.clickProfileName(); + userCreationPage.clickProfileButton(); userCreationPage.verifyElementContainsText( "username-profile-details", "devdistrictadmin", ); - cy.get("#edit-cancel-profile-button").click(); + userCreationPage.clickEditCancelProfileButton(); userCreationPage.typeIntoElementByIdPostClear( "firstName", "District Editted", @@ -126,9 +126,9 @@ describe("User Creation", () => { }); it("Update the existing user profile Form Mandatory File Error", () => { - cy.get("#user-profile-name").click(); - cy.get("#profile-button").click(); - cy.get("#edit-cancel-profile-button").click(); + userCreationPage.clickProfileName(); + userCreationPage.clickProfileButton(); + userCreationPage.clickEditCancelProfileButton(); userCreationPage.clearIntoElementById("firstName"); userCreationPage.clearIntoElementById("lastName"); @@ -140,7 +140,7 @@ describe("User Creation", () => { }); it("create new user and verify reflection", () => { - cy.get("#addUserButton").click(); + userCreationPage.clickAddUserButton(); userCreationPage.selectFacility("Dummy Shifting Center"); userCreationPage.typeIntoElementById("username", username); userCreationPage.typeIntoElementById("password", "Test@123"); @@ -161,7 +161,7 @@ describe("User Creation", () => { userCreationPage.selectDropdownOption("gender", "Male"); userCreationPage.selectDropdownOption("state", "Kerala"); userCreationPage.selectDropdownOption("district", "Ernakulam"); - cy.get("#submit").click(); + userCreationPage.clickSubmit(); userCreationPage.verifyNotification("User added successfully"); userPage.typeInSearchInput(username); userPage.checkUsernameText(username); @@ -181,7 +181,7 @@ describe("User Creation", () => { }); it("create new user form throwing mandatory field error", () => { - cy.get("#addUserButton").click(); + userCreationPage.clickAddUserButton(); cy.submitButton("Save User"); cy.wait(2000); userCreationPage.verifyErrorMessages(EXPECTED_ERROR_MESSAGES); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index a8b1a4d9585..f8783546830 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -1,5 +1,24 @@ // UserCreation.ts export class UserCreationPage { + clickProfileName() { + cy.get("#user-profile-name").click(); + } + + clickProfileButton() { + cy.get("#profile-button").click(); + } + + clickEditCancelProfileButton() { + cy.get("#edit-cancel-profile-button").click(); + } + + clickAddUserButton() { + cy.get("#addUserButton").click(); + } + clickSubmit() { + cy.get("#submit").click(); + } + typeIntoElementById(elementId: string, value: string) { cy.get("#" + elementId) .click() From 086eb6bc261d7a3e0f19b4ff8086b942c8336b0b Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Mon, 28 Oct 2024 19:31:52 +0530 Subject: [PATCH 06/23] Rewrite user creation.cy.ts --- cypress/e2e/users_spec/UsersCreation.cy.ts | 143 +++++++++------------ cypress/pageobject/Users/UserCreation.ts | 101 ++++++++++----- 2 files changed, 126 insertions(+), 118 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index cfce8ba8675..cbcb01c0f32 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -68,61 +68,35 @@ describe("User Creation", () => { it("Update the existing user profile and verify its reflection", () => { userCreationPage.clickProfileName(); userCreationPage.clickProfileButton(); - userCreationPage.verifyElementContainsText( - "username-profile-details", - "devdistrictadmin", - ); + cy.verifyContentPresence("#username-profile-details", ["devdistrictadmin"]); + userCreationPage.clickEditCancelProfileButton(); - userCreationPage.typeIntoElementByIdPostClear( - "firstName", - "District Editted", - ); - userCreationPage.typeIntoElementByIdPostClear("lastName", "Cypress"); - userCreationPage.selectDropdownOption("gender", "Male"); - userCreationPage.typeIntoElementByIdPostClear("phoneNumber", phone_number); - userCreationPage.typeIntoElementByIdPostClear( - "altPhoneNumber", - emergency_phone_number, - ); - userCreationPage.typeIntoElementByIdPostClear("email", "test@test.com"); - userCreationPage.typeIntoElementByIdPostClear("weekly_working_hours", "14"); + userCreationPage.typeIntoFirstNameAndClear(); + userCreationPage.typeIntoLastNameAndClear(); + cy.get("#gender").click().get("[role='option']").contains("Male").click(); + userCreationPage.typeIntoPhoneNumberAndClear(phone_number); + userCreationPage.typeIntoAltPhoneumberAndClear(emergency_phone_number); + userCreationPage.typeIntoEmailAndClear(); + userCreationPage.typeIntoWeeklyWorkingHoursAndClear(); userCreationPage.typeIntoElementByIdPostClearDob( "date_of_birth", "01011998", ); cy.submitButton("Update"); - userCreationPage.verifyElementContainsText( - "contactno-profile-details", + cy.verifyContentPresence("#contactno-profile-details", [ "+91" + phone_number, - ); - userCreationPage.verifyElementContainsText( - "whatsapp-profile-details", + ]); + cy.verifyContentPresence("#whatsapp-profile-details", [ "+91" + emergency_phone_number, - ); - userCreationPage.verifyElementContainsText( - "firstname-profile-details", + ]); + cy.verifyContentPresence("#firstname-profile-details", [ "District Editted", - ); - userCreationPage.verifyElementContainsText( - "lastname-profile-details", - "Cypress", - ); - userCreationPage.verifyElementContainsText( - "date_of_birth-profile-details", - "01/01/1998", - ); - userCreationPage.verifyElementContainsText( - "emailid-profile-details", - "test@test.com", - ); - userCreationPage.verifyElementContainsText( - "gender-profile-details", - "Male", - ); - userCreationPage.verifyElementContainsText( - "averageworkinghour-profile-details", - "14", - ); + ]); + cy.verifyContentPresence("#lastname-profile-details", ["Cypress"]); + cy.verifyContentPresence("#date_of_birth-profile-details", ["01/01/1998"]); + cy.verifyContentPresence("#emailid-profile-details", ["test@test.com"]); + cy.verifyContentPresence("#gender-profile-details", ["Male"]); + cy.verifyContentPresence("#averageworkinghour-profile-details", ["14"]); }); it("Update the existing user profile Form Mandatory File Error", () => { @@ -130,11 +104,11 @@ describe("User Creation", () => { userCreationPage.clickProfileButton(); userCreationPage.clickEditCancelProfileButton(); - userCreationPage.clearIntoElementById("firstName"); - userCreationPage.clearIntoElementById("lastName"); - userCreationPage.clearIntoElementById("phoneNumber"); - userCreationPage.clearIntoElementById("altPhoneNumber"); - userCreationPage.clearIntoElementById("weekly_working_hours"); + userCreationPage.clearFirstName(); + userCreationPage.clearLastName(); + userCreationPage.clearPhoneNumber(); + userCreationPage.clearAltPhoneNumber(); + userCreationPage.clearWeeklyWorkingHours(); cy.submitButton("Update"); userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES); }); @@ -142,42 +116,45 @@ describe("User Creation", () => { it("create new user and verify reflection", () => { userCreationPage.clickAddUserButton(); userCreationPage.selectFacility("Dummy Shifting Center"); - userCreationPage.typeIntoElementById("username", username); - userCreationPage.typeIntoElementById("password", "Test@123"); + userCreationPage.typeUserName(username); + userCreationPage.typePassword(); userCreationPage.selectHomeFacility("Dummy Shifting Center"); - userCreationPage.typeIntoElementById("phone_number", phone_number); - userCreationPage.setInputDate("date_of_birth", "date-input", "25081999"); - userCreationPage.selectDropdownOption("user_type", "Doctor"); - userCreationPage.typeIntoElementById("c_password", "Test@123"); - userCreationPage.typeIntoElementById("qualification", "MBBS"); - userCreationPage.typeIntoElementById("doctor_experience_commenced_on", "2"); - userCreationPage.typeIntoElementById( - "doctor_medical_council_registration", - "123456789", - ); - userCreationPage.typeIntoElementById("first_name", "cypress test"); - userCreationPage.typeIntoElementById("last_name", "staff user"); - userCreationPage.typeIntoElementById("email", "test@test.com"); - userCreationPage.selectDropdownOption("gender", "Male"); - userCreationPage.selectDropdownOption("state", "Kerala"); - userCreationPage.selectDropdownOption("district", "Ernakulam"); + userCreationPage.typePhoneNumber(phone_number); + cy.get("#date_of_birth") + .click() + .get("#date-input") + .click() + .type("25081999"); + cy.get("#user_type") + .click() + .get("[role='option']") + .contains("Doctor") + .click(); + userCreationPage.typeConfirmPassword(); + userCreationPage.typeQualification(); + userCreationPage.typeDoctorExperience(); + userCreationPage.typeDoctorMedicalCouncilRegNo(); + userCreationPage.typeFirstName(); + userCreationPage.typeLastName(); + userCreationPage.typeEmail(); + cy.get("#gender").click().get("[role='option']").contains("Male").click(); + cy.get("#state").click().get("[role='option']").contains("Kerala").click(); + cy.get("#district") + .click() + .get("[role='option']") + .contains("Ernakulam") + .click(); userCreationPage.clickSubmit(); - userCreationPage.verifyNotification("User added successfully"); + cy.verifyNotification("User added successfully"); userPage.typeInSearchInput(username); userPage.checkUsernameText(username); - userCreationPage.verifyElementContainsText("name", "cypress test"); - userCreationPage.verifyElementContainsText("role", "Doctor"); - userCreationPage.verifyElementContainsText("district", "Ernakulam"); - userCreationPage.verifyElementContainsText( - "home_facility", - "Dummy Shifting Center", - ); - userCreationPage.verifyElementContainsText("qualification", "MBBS"); - userCreationPage.verifyElementContainsText("doctor-experience", "2"); - userCreationPage.verifyElementContainsText( - "medical-council-registration", - "123456789", - ); + cy.verifyContentPresence("#name", ["cypress test"]); + cy.verifyContentPresence("#role", ["Doctor"]); + cy.verifyContentPresence("#district", ["Ernakulam"]); + cy.verifyContentPresence("#home_facility", ["Dummy Shifting Center"]); + cy.verifyContentPresence("#qualification", ["MBBS"]); + cy.verifyContentPresence("#doctor-experience", ["2"]); + cy.verifyContentPresence("#medical-council-registration", ["123456789"]); }); it("create new user form throwing mandatory field error", () => { diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index f8783546830..5d4a95c6532 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -19,27 +19,82 @@ export class UserCreationPage { cy.get("#submit").click(); } - typeIntoElementById(elementId: string, value: string) { - cy.get("#" + elementId) - .click() - .type(value); + typeIntoFirstNameAndClear() { + cy.get("#firstName").click().clear().click().type("District Editted"); + } + typeIntoLastNameAndClear() { + cy.get("#lastName").click().clear().click().type("Cypress"); + } + typeIntoPhoneNumberAndClear(phone_number: string) { + cy.get("#phoneNumber").click().clear().click().type(phone_number); + } + typeIntoEmailAndClear() { + cy.get("#email").click().clear().click().type("test@test.com"); + } + typeIntoWeeklyWorkingHoursAndClear() { + cy.get("#weekly_working_hours").click().clear().click().type("14"); } - typeIntoElementByIdPostClear(elementId: string, value: string) { - cy.get("#" + elementId) + typeIntoAltPhoneumberAndClear(emergency_phone_number: string) { + cy.get("#altPhoneNumber") .click() .clear() .click() - .type(value); + .type(emergency_phone_number); } + typeIntoElementByIdPostClearDob(elementId: string, value: string) { cy.get("#" + elementId).click(); cy.get("#date-input").clear().type(value); } - clearIntoElementById(elementId: string) { - cy.get("#" + elementId) - .click() - .clear(); + + 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(); + } + + typeUserName(username: string) { + cy.get("#username").click().type(username); + } + typePassword() { + cy.get("#password").click().type("Test@123"); + } + typePhoneNumber(phone_number: string) { + cy.get("#phone_number").click().type(phone_number); + } + typeConfirmPassword() { + cy.get("#c_password").click().type("Test@123"); + } + typeQualification() { + cy.get("#qualification").click().type("MBBS"); + } + typeDoctorExperience() { + cy.get("#doctor_experience_commenced_on").click().type("2"); + } + + typeDoctorMedicalCouncilRegNo() { + cy.get("#doctor_medical_council_registration").click().type("123456789"); + } + + typeFirstName() { + cy.get("#first_name").click().type("cypress test"); + } + typeLastName() { + cy.get("#last_name").click().type("staff user"); + } + typeEmail() { + cy.get("#email").click().type("test@test.com"); } typeIntoInputByName(inputName: string, value: string) { @@ -47,15 +102,9 @@ export class UserCreationPage { .click() .type(value); } - selectOptionContainingText(text: string) { cy.get("[role='option']").contains(text).click(); } - - verifyNotification(message: string) { - cy.verifyNotification(message); - } - selectFacility(name: string) { this.typeIntoInputByName("facilities", name); this.selectOptionContainingText(name); @@ -69,24 +118,6 @@ export class UserCreationPage { this.selectOptionContainingText(name); } - setInputDate( - dateElementId: string, - inputElementId: string, - dateValue: string, - ) { - cy.get("#" + dateElementId).click(); - this.typeIntoElementById(inputElementId, dateValue); - } - - selectDropdownOption(dropdownId: string, optionText: string) { - cy.get("#" + dropdownId).click(); - this.selectOptionContainingText(optionText); - } - - verifyElementContainsText(elementId: string, expectedText: string) { - cy.get("#" + elementId).should("contain.text", expectedText); - } - verifyErrorMessages(errorMessages: string[]) { cy.get(".error-text").then(($errors) => { const displayedErrorMessages = $errors From 5ac2a1c18add1ba97e64aa594b83eb33bc9851ec Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Fri, 1 Nov 2024 19:16:59 +0530 Subject: [PATCH 07/23] Finsihed Writing UserCreation.cy.ts --- cypress/e2e/users_spec/UsersCreation.cy.ts | 25 ++++++---------------- cypress/pageobject/Users/UserCreation.ts | 3 +-- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index cbcb01c0f32..81be9733aa1 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -73,7 +73,7 @@ describe("User Creation", () => { userCreationPage.clickEditCancelProfileButton(); userCreationPage.typeIntoFirstNameAndClear(); userCreationPage.typeIntoLastNameAndClear(); - cy.get("#gender").click().get("[role='option']").contains("Male").click(); + cy.clickAndSelectOption("#gender", "Male"); userCreationPage.typeIntoPhoneNumberAndClear(phone_number); userCreationPage.typeIntoAltPhoneumberAndClear(emergency_phone_number); userCreationPage.typeIntoEmailAndClear(); @@ -103,7 +103,6 @@ describe("User Creation", () => { userCreationPage.clickProfileName(); userCreationPage.clickProfileButton(); userCreationPage.clickEditCancelProfileButton(); - userCreationPage.clearFirstName(); userCreationPage.clearLastName(); userCreationPage.clearPhoneNumber(); @@ -120,16 +119,8 @@ describe("User Creation", () => { userCreationPage.typePassword(); userCreationPage.selectHomeFacility("Dummy Shifting Center"); userCreationPage.typePhoneNumber(phone_number); - cy.get("#date_of_birth") - .click() - .get("#date-input") - .click() - .type("25081999"); - cy.get("#user_type") - .click() - .get("[role='option']") - .contains("Doctor") - .click(); + cy.clickAndTypeDate("#date_of_birth", "25081999"); + cy.clickAndSelectOption("#user_type", "Doctor"); userCreationPage.typeConfirmPassword(); userCreationPage.typeQualification(); userCreationPage.typeDoctorExperience(); @@ -137,13 +128,9 @@ describe("User Creation", () => { userCreationPage.typeFirstName(); userCreationPage.typeLastName(); userCreationPage.typeEmail(); - cy.get("#gender").click().get("[role='option']").contains("Male").click(); - cy.get("#state").click().get("[role='option']").contains("Kerala").click(); - cy.get("#district") - .click() - .get("[role='option']") - .contains("Ernakulam") - .click(); + cy.clickAndSelectOption("#gender", "Male"); + cy.clickAndSelectOption("#state", "Kerala"); + cy.clickAndSelectOption("#district", "Ernakulam"); userCreationPage.clickSubmit(); cy.verifyNotification("User added successfully"); userPage.typeInSearchInput(username); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 5d4a95c6532..24e46cd8a6b 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -44,8 +44,7 @@ export class UserCreationPage { } typeIntoElementByIdPostClearDob(elementId: string, value: string) { - cy.get("#" + elementId).click(); - cy.get("#date-input").clear().type(value); + cy.clickAndTypeDate("#" + elementId, value); } clearFirstName() { From 6e78b3086bad8caf684c3fa69fdf19549014bb6b Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Tue, 5 Nov 2024 15:02:33 +0530 Subject: [PATCH 08/23] clear and type functions are defined --- cypress/e2e/users_spec/UsersCreation.cy.ts | 118 ++++++++++++--------- cypress/pageobject/Users/UserCreation.ts | 115 ++++++++++---------- 2 files changed, 126 insertions(+), 107 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index 81be9733aa1..aeb96be219c 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -53,6 +53,27 @@ describe("User Creation", () => { "This field is required", "Please enter valid phone number", ]; + const userName = "devdistrictadmin"; + const firstName = "District Editted"; + const lastName = "Cypress"; + const gender = "Male"; + const email = "test@test.com"; + const password = "Test@123"; + const qualification = "MBBS"; + const experince = "2"; + const reg_no = "123456789"; + const firstName_ = "cypress test"; + const lastName_ = "staff user"; + const state = "Kerala"; + const district = "Ernakulam"; + const role = "Doctor"; + const home_facility = "Dummy Shifting Center"; + const weekly_working_hrs = "12"; + const dob_id = "date_of_birth"; + const dob = "01011998"; + const formatted_dob = "01/01/1998"; + const update_btn = "Update"; + const save_btn = "Save User"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -68,85 +89,86 @@ describe("User Creation", () => { it("Update the existing user profile and verify its reflection", () => { userCreationPage.clickProfileName(); userCreationPage.clickProfileButton(); - cy.verifyContentPresence("#username-profile-details", ["devdistrictadmin"]); - - userCreationPage.clickEditCancelProfileButton(); - userCreationPage.typeIntoFirstNameAndClear(); - userCreationPage.typeIntoLastNameAndClear(); - cy.clickAndSelectOption("#gender", "Male"); - userCreationPage.typeIntoPhoneNumberAndClear(phone_number); - userCreationPage.typeIntoAltPhoneumberAndClear(emergency_phone_number); - userCreationPage.typeIntoEmailAndClear(); - userCreationPage.typeIntoWeeklyWorkingHoursAndClear(); - userCreationPage.typeIntoElementByIdPostClearDob( - "date_of_birth", - "01011998", - ); - cy.submitButton("Update"); + cy.verifyContentPresence("#username-profile-details", [userName]); + userCreationPage.clickEditProfileButton(); + userCreationPage.clearFirstName(); + userCreationPage.typeFirstName(firstName); + userCreationPage.clearLastName(); + userCreationPage.typeLastName(lastName); + userCreationPage.selectGender(gender); + userCreationPage.clearPhoneNumber(); + userCreationPage.typePhoneNumber(phone_number); + userCreationPage.clearAltPhoneNumber(); + userCreationPage.typeAltPhoneumber(emergency_phone_number); + userCreationPage.clearEmail(); + userCreationPage.typeEmail(email); + userCreationPage.clearWeeklyWorkingHours(); + userCreationPage.typeWeeklyWorkingHours(weekly_working_hrs); + userCreationPage.typeIntoElementByIdPostClearDob(dob_id, dob); + cy.submitButton(update_btn); cy.verifyContentPresence("#contactno-profile-details", [ "+91" + phone_number, ]); cy.verifyContentPresence("#whatsapp-profile-details", [ "+91" + emergency_phone_number, ]); - cy.verifyContentPresence("#firstname-profile-details", [ - "District Editted", + cy.verifyContentPresence("#firstname-profile-details", [firstName]); + cy.verifyContentPresence("#lastname-profile-details", [lastName]); + cy.verifyContentPresence("#date_of_birth-profile-details", [formatted_dob]); + cy.verifyContentPresence("#emailid-profile-details", [email]); + cy.verifyContentPresence("#gender-profile-details", [gender]); + cy.verifyContentPresence("#averageworkinghour-profile-details", [ + weekly_working_hrs, ]); - cy.verifyContentPresence("#lastname-profile-details", ["Cypress"]); - cy.verifyContentPresence("#date_of_birth-profile-details", ["01/01/1998"]); - cy.verifyContentPresence("#emailid-profile-details", ["test@test.com"]); - cy.verifyContentPresence("#gender-profile-details", ["Male"]); - cy.verifyContentPresence("#averageworkinghour-profile-details", ["14"]); }); it("Update the existing user profile Form Mandatory File Error", () => { userCreationPage.clickProfileName(); userCreationPage.clickProfileButton(); - userCreationPage.clickEditCancelProfileButton(); + userCreationPage.clickEditProfileButton(); userCreationPage.clearFirstName(); userCreationPage.clearLastName(); userCreationPage.clearPhoneNumber(); userCreationPage.clearAltPhoneNumber(); userCreationPage.clearWeeklyWorkingHours(); - cy.submitButton("Update"); + cy.submitButton(update_btn); userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES); }); it("create new user and verify reflection", () => { userCreationPage.clickAddUserButton(); - userCreationPage.selectFacility("Dummy Shifting Center"); + userCreationPage.selectFacility(home_facility); userCreationPage.typeUserName(username); - userCreationPage.typePassword(); - userCreationPage.selectHomeFacility("Dummy Shifting Center"); + userCreationPage.typePassword(password); + userCreationPage.selectHomeFacility(home_facility); userCreationPage.typePhoneNumber(phone_number); - cy.clickAndTypeDate("#date_of_birth", "25081999"); - cy.clickAndSelectOption("#user_type", "Doctor"); - userCreationPage.typeConfirmPassword(); - userCreationPage.typeQualification(); - userCreationPage.typeDoctorExperience(); - userCreationPage.typeDoctorMedicalCouncilRegNo(); - userCreationPage.typeFirstName(); - userCreationPage.typeLastName(); - userCreationPage.typeEmail(); - cy.clickAndSelectOption("#gender", "Male"); - cy.clickAndSelectOption("#state", "Kerala"); - cy.clickAndSelectOption("#district", "Ernakulam"); - userCreationPage.clickSubmit(); + userCreationPage.selectUserType(role); + userCreationPage.typeConfirmPassword(password); + userCreationPage.typeQualification(qualification); + userCreationPage.typeDoctorExperience(experince); + userCreationPage.typeDoctorMedicalCouncilRegNo(reg_no); + userCreationPage.typeFirstName(firstName_); + userCreationPage.typeLastName(lastName_); + userCreationPage.typeEmail(email); + userCreationPage.selectGender(gender); + userCreationPage.selectState(state); + userCreationPage.selectDistrict(district); + cy.clickSubmit(); cy.verifyNotification("User added successfully"); userPage.typeInSearchInput(username); userPage.checkUsernameText(username); - cy.verifyContentPresence("#name", ["cypress test"]); - cy.verifyContentPresence("#role", ["Doctor"]); - cy.verifyContentPresence("#district", ["Ernakulam"]); - cy.verifyContentPresence("#home_facility", ["Dummy Shifting Center"]); - cy.verifyContentPresence("#qualification", ["MBBS"]); - cy.verifyContentPresence("#doctor-experience", ["2"]); - cy.verifyContentPresence("#medical-council-registration", ["123456789"]); + cy.verifyContentPresence("#name", [firstName_]); + cy.verifyContentPresence("#role", [role]); + cy.verifyContentPresence("#district", [district]); + cy.verifyContentPresence("#home_facility", [home_facility]); + cy.verifyContentPresence("#qualification", [qualification]); + cy.verifyContentPresence("#doctor-experience", [experince]); + cy.verifyContentPresence("#medical-council-registration", [reg_no]); }); it("create new user form throwing mandatory field error", () => { userCreationPage.clickAddUserButton(); - cy.submitButton("Save User"); + cy.submitButton(save_btn); cy.wait(2000); userCreationPage.verifyErrorMessages(EXPECTED_ERROR_MESSAGES); }); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 24e46cd8a6b..8c54a6f60ea 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -3,50 +3,69 @@ export class UserCreationPage { clickProfileName() { cy.get("#user-profile-name").click(); } - clickProfileButton() { cy.get("#profile-button").click(); } - - clickEditCancelProfileButton() { + clickEditProfileButton() { cy.get("#edit-cancel-profile-button").click(); } - clickAddUserButton() { cy.get("#addUserButton").click(); } - clickSubmit() { - cy.get("#submit").click(); + typeUserName(username: string) { + cy.get("#username").click().type(username); + } + typeFirstName(firstName: string) { + cy.get("#first_name").click().type(firstName); + } + typeLastName(lastName: string) { + cy.get("#last_name").click().type(lastName); + } + typeEmail(email: string) { + cy.get("#email").click().type(email); } - typeIntoFirstNameAndClear() { - cy.get("#firstName").click().clear().click().type("District Editted"); + typePassword(password: string) { + cy.get("#password").click().type(password); } - typeIntoLastNameAndClear() { - cy.get("#lastName").click().clear().click().type("Cypress"); + typePhoneNumber(phone_number: string) { + cy.get("#phone_number").click().type(phone_number); } - typeIntoPhoneNumberAndClear(phone_number: string) { - cy.get("#phoneNumber").click().clear().click().type(phone_number); + typeConfirmPassword(password: string) { + cy.get("#c_password").click().type(password); } - typeIntoEmailAndClear() { - cy.get("#email").click().clear().click().type("test@test.com"); + typeQualification(qualification: string) { + cy.get("#qualification").click().type(qualification); } - typeIntoWeeklyWorkingHoursAndClear() { - cy.get("#weekly_working_hours").click().clear().click().type("14"); + typeDoctorExperience(experince: string) { + cy.get("#doctor_experience_commenced_on").click().type(experince); } - typeIntoAltPhoneumberAndClear(emergency_phone_number: string) { - cy.get("#altPhoneNumber") - .click() - .clear() - .click() - .type(emergency_phone_number); + typeDoctorMedicalCouncilRegNo(reg_no: string) { + cy.get("#doctor_medical_council_registration").click().type(reg_no); + } + + typeWeeklyWorkingHours(working_hrs: string) { + cy.get("#weekly_working_hours").click().type(working_hrs); + } + + typeAltPhoneumber(emergency_phone_number: string) { + cy.get("#altPhoneNumber").click().type(emergency_phone_number); } typeIntoElementByIdPostClearDob(elementId: string, value: string) { cy.clickAndTypeDate("#" + elementId, value); } + typeIntoInputByName(inputName: string, value: string) { + cy.get("input[name='" + inputName + "']") + .click() + .type(value); + } + + typeDate(dob: string) { + cy.clickAndTypeDate("#date_of_birth", dob); + } clearFirstName() { cy.get("#firstName").click().clear(); } @@ -63,46 +82,25 @@ export class UserCreationPage { cy.get("#weekly_working_hours").click().clear(); } - typeUserName(username: string) { - cy.get("#username").click().type(username); + clearEmail() { + cy.get("#email").click().clear(); } - typePassword() { - cy.get("#password").click().type("Test@123"); - } - typePhoneNumber(phone_number: string) { - cy.get("#phone_number").click().type(phone_number); - } - typeConfirmPassword() { - cy.get("#c_password").click().type("Test@123"); - } - typeQualification() { - cy.get("#qualification").click().type("MBBS"); - } - typeDoctorExperience() { - cy.get("#doctor_experience_commenced_on").click().type("2"); + selectUserType(role: string) { + cy.clickAndSelectOption("#user_type", role); } - typeDoctorMedicalCouncilRegNo() { - cy.get("#doctor_medical_council_registration").click().type("123456789"); - } - - typeFirstName() { - cy.get("#first_name").click().type("cypress test"); - } - typeLastName() { - cy.get("#last_name").click().type("staff user"); + selectHomeFacility(name: string) { + cy.get("#home_facility").click(); + this.selectOptionContainingText(name); } - typeEmail() { - cy.get("#email").click().type("test@test.com"); + selectGender(gender: string) { + cy.clickAndSelectOption("#gender", gender); } - - typeIntoInputByName(inputName: string, value: string) { - cy.get("input[name='" + inputName + "']") - .click() - .type(value); + selectState(state: string) { + cy.clickAndSelectOption("#state", state); } - selectOptionContainingText(text: string) { - cy.get("[role='option']").contains(text).click(); + selectDistrict(district: string) { + cy.clickAndSelectOption("#district", district); } selectFacility(name: string) { this.typeIntoInputByName("facilities", name); @@ -112,9 +110,8 @@ export class UserCreationPage { .click(); } - selectHomeFacility(name: string) { - cy.get("#home_facility").click(); - this.selectOptionContainingText(name); + selectOptionContainingText(text: string) { + cy.get("[role='option']").contains(text).click(); } verifyErrorMessages(errorMessages: string[]) { From d2311026a726fdc910b7a183e76dfe954ac7ee7c Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Sun, 10 Nov 2024 08:49:47 +0530 Subject: [PATCH 09/23] made changes mentioned by coderrabit --- .env | 2 +- .husky/pre-commit | 2 +- cypress/e2e/users_spec/UsersCreation.cy.ts | 15 ++++---- cypress/pageobject/Users/UserCreation.ts | 45 ++++++++++++++-------- 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/.env b/.env index b5db3d0088f..77e4641b8b2 100644 --- a/.env +++ b/.env @@ -14,4 +14,4 @@ ESLINT_NO_DEV_ERRORS=true CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3-patient-data-10bedicu.s3.amazonaws.com http://localhost:4566" REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn" -REACT_ENABLED_APPS="" +REACT_ENABLED_APPS="" \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 2312dc587f6..d0a778429a3 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -npx lint-staged +npx lint-staged \ No newline at end of file diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index 15b0bcc0ad1..cf4c9ea67a3 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -68,12 +68,12 @@ describe("User Creation", () => { const district = "Ernakulam"; const role = "Doctor"; const home_facility = "Dummy Shifting Center"; - const weekly_working_hrs = "12"; - const dob_id = "date_of_birth"; + const weekly_working_hrs = "14"; const dob = "01011998"; const formatted_dob = "01/01/1998"; const update_btn = "Update"; const save_btn = "Save User"; + const new_user_dob = "25081999"; before(() => { loginPage.loginAsDistrictAdmin(); @@ -104,7 +104,7 @@ describe("User Creation", () => { userCreationPage.typeEmail(email); userCreationPage.clearWeeklyWorkingHours(); userCreationPage.typeWeeklyWorkingHours(weekly_working_hrs); - userCreationPage.typeIntoElementByIdPostClearDob(dob_id, dob); + userCreationPage.typeDateOfBirth(dob); cy.submitButton(update_btn); cy.verifyContentPresence("#contactno-profile-details", [ "+91" + phone_number, @@ -141,19 +141,20 @@ describe("User Creation", () => { userCreationPage.typeUserName(username); userCreationPage.typePassword(password); userCreationPage.selectHomeFacility(home_facility); - userCreationPage.typePhoneNumber(phone_number); + userCreationPage.typeNewUserPhoneNumber(phone_number); + userCreationPage.typeDateOfBirth(new_user_dob); userCreationPage.selectUserType(role); userCreationPage.typeConfirmPassword(password); userCreationPage.typeQualification(qualification); userCreationPage.typeDoctorExperience(experince); userCreationPage.typeDoctorMedicalCouncilRegNo(reg_no); - userCreationPage.typeFirstName(firstName_); - userCreationPage.typeLastName(lastName_); + userCreationPage.typeNewUserFirstName(firstName_); + userCreationPage.typeNewUserLastName(lastName_); userCreationPage.typeEmail(email); userCreationPage.selectGender(gender); userCreationPage.selectState(state); userCreationPage.selectDistrict(district); - cy.clickSubmit(); + userCreationPage.clickSubmitButton(); cy.verifyNotification("User added successfully"); userPage.typeInSearchInput(username); userPage.checkUsernameText(username); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 8c54a6f60ea..7057c2aaef1 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -12,14 +12,18 @@ export class UserCreationPage { clickAddUserButton() { cy.get("#addUserButton").click(); } + clickSubmitButton() { + cy.get("#submit").click(); + } + typeUserName(username: string) { cy.get("#username").click().type(username); } typeFirstName(firstName: string) { - cy.get("#first_name").click().type(firstName); + cy.get("#firstName").click().type(firstName); } typeLastName(lastName: string) { - cy.get("#last_name").click().type(lastName); + cy.get("#lastName").click().type(lastName); } typeEmail(email: string) { cy.get("#email").click().type(email); @@ -29,7 +33,7 @@ export class UserCreationPage { cy.get("#password").click().type(password); } typePhoneNumber(phone_number: string) { - cy.get("#phone_number").click().type(phone_number); + cy.get("#phoneNumber").click().type(phone_number); } typeConfirmPassword(password: string) { cy.get("#c_password").click().type(password); @@ -41,20 +45,16 @@ export class UserCreationPage { cy.get("#doctor_experience_commenced_on").click().type(experince); } - typeDoctorMedicalCouncilRegNo(reg_no: string) { - cy.get("#doctor_medical_council_registration").click().type(reg_no); + typeDoctorMedicalCouncilRegNo(regNo: string) { + cy.get("#doctor_medical_council_registration").click().type(regNo); } - typeWeeklyWorkingHours(working_hrs: string) { - cy.get("#weekly_working_hours").click().type(working_hrs); + typeWeeklyWorkingHours(workingHrs: string) { + cy.get("#weekly_working_hours").click().type(workingHrs); } - typeAltPhoneumber(emergency_phone_number: string) { - cy.get("#altPhoneNumber").click().type(emergency_phone_number); - } - - typeIntoElementByIdPostClearDob(elementId: string, value: string) { - cy.clickAndTypeDate("#" + elementId, value); + typeAltPhoneumber(emergencyPhoneNumber: string) { + cy.get("#altPhoneNumber").click().type(emergencyPhoneNumber); } typeIntoInputByName(inputName: string, value: string) { @@ -62,10 +62,19 @@ export class UserCreationPage { .click() .type(value); } - - typeDate(dob: string) { + 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(); } @@ -81,10 +90,10 @@ export class UserCreationPage { clearWeeklyWorkingHours() { cy.get("#weekly_working_hours").click().clear(); } - clearEmail() { cy.get("#email").click().clear(); } + selectUserType(role: string) { cy.clickAndSelectOption("#user_type", role); } @@ -114,6 +123,10 @@ export class UserCreationPage { cy.get("[role='option']").contains(text).click(); } + verifyElementContainsText(elementId: string, expectedText: string) { + cy.get("#" + elementId).should("contain.text", expectedText); + } + verifyErrorMessages(errorMessages: string[]) { cy.get(".error-text").then(($errors) => { const displayedErrorMessages = $errors From 4cdbdfadac8d5621c1b7b25d8090ae90aed71884 Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Sun, 10 Nov 2024 10:04:06 +0530 Subject: [PATCH 10/23] ALtPhoneNumber function crrrected --- cypress/e2e/users_spec/UsersCreation.cy.ts | 2 +- cypress/pageobject/Users/UserCreation.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index cf4c9ea67a3..3ae75a06c92 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -99,7 +99,7 @@ describe("User Creation", () => { userCreationPage.clearPhoneNumber(); userCreationPage.typePhoneNumber(phone_number); userCreationPage.clearAltPhoneNumber(); - userCreationPage.typeAltPhoneumber(emergency_phone_number); + userCreationPage.typeAltPhoneNumber(emergency_phone_number); userCreationPage.clearEmail(); userCreationPage.typeEmail(email); userCreationPage.clearWeeklyWorkingHours(); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 7057c2aaef1..109d4c5a058 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -1,5 +1,9 @@ // UserCreation.ts export class UserCreationPage { + private selectOptionContainingText(text: string) { + cy.get("[role='option']").contains(text).click(); + } + clickProfileName() { cy.get("#user-profile-name").click(); } @@ -53,7 +57,7 @@ export class UserCreationPage { cy.get("#weekly_working_hours").click().type(workingHrs); } - typeAltPhoneumber(emergencyPhoneNumber: string) { + typeAltPhoneNumber(emergencyPhoneNumber: string) { cy.get("#altPhoneNumber").click().type(emergencyPhoneNumber); } @@ -97,11 +101,10 @@ export class UserCreationPage { selectUserType(role: string) { cy.clickAndSelectOption("#user_type", role); } - selectHomeFacility(name: string) { - cy.get("#home_facility").click(); - this.selectOptionContainingText(name); + cy.clickAndSelectOption("#home_facility", name); } + selectGender(gender: string) { cy.clickAndSelectOption("#gender", gender); } @@ -119,10 +122,6 @@ export class UserCreationPage { .click(); } - selectOptionContainingText(text: string) { - cy.get("[role='option']").contains(text).click(); - } - verifyElementContainsText(elementId: string, expectedText: string) { cy.get("#" + elementId).should("contain.text", expectedText); } From fcceae4c034188fdc74b7ea8d549cd4bc8ccdc5f Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Mon, 11 Nov 2024 19:41:29 +0530 Subject: [PATCH 11/23] made few changes suggested by coderrabit --- cypress/pageobject/Users/UserCreation.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 109d4c5a058..1f706680b35 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -1,7 +1,10 @@ // UserCreation.ts export class UserCreationPage { private selectOptionContainingText(text: string) { - cy.get("[role='option']").contains(text).click(); + cy.get("[role='option']") + .contains(text) + .should("be.visible") + .click({ timeout: 10000 }); } clickProfileName() { @@ -45,8 +48,8 @@ export class UserCreationPage { typeQualification(qualification: string) { cy.get("#qualification").click().type(qualification); } - typeDoctorExperience(experince: string) { - cy.get("#doctor_experience_commenced_on").click().type(experince); + typeDoctorExperience(experience: string) { + cy.get("#doctor_experience_commenced_on").click().type(experience); } typeDoctorMedicalCouncilRegNo(regNo: string) { From 9ab927ae8f81811bd6309d31d76614cb9b657405 Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Wed, 13 Nov 2024 19:29:16 +0530 Subject: [PATCH 12/23] made requested changes --- cypress/e2e/users_spec/UsersCreation.cy.ts | 72 +++++++++++----------- cypress/pageobject/Users/UserCreation.ts | 32 ++-------- 2 files changed, 41 insertions(+), 63 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index 3ae75a06c92..d08e83a930f 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -14,10 +14,10 @@ describe("User Creation", () => { const userCreationPage = new UserCreationPage(); const facilityPage = new FacilityPage(); const assetSearchPage = new AssetSearchPage(); - const phone_number = generatePhoneNumber(); - const emergency_phone_number = generateEmergencyPhoneNumber(); + const phoneNumber = generatePhoneNumber(); + const emergencyPhoneNumber = generateEmergencyPhoneNumber(); const fillFacilityName = "Dummy Facility 40"; - const makeid = (length: number) => { + const makeId = (length: number) => { let result = ""; const characters = "abcdefghijklmnopqrstuvwxyz0123456789"; const charactersLength = characters.length; @@ -26,8 +26,8 @@ describe("User Creation", () => { } return result; }; - const username = makeid(8); - const alreadylinkedusersviews = [ + const username = makeId(8); + const alreadyLinkedUsersViews = [ "devdoctor", "devstaff2", "devdistrictadmin", @@ -61,19 +61,19 @@ describe("User Creation", () => { const password = "Test@123"; const qualification = "MBBS"; const experince = "2"; - const reg_no = "123456789"; - const firstName_ = "cypress test"; - const lastName_ = "staff user"; + const regNo = "123456789"; + const newUserFirstName = "cypress test"; + const newUserLastName = "staff user"; const state = "Kerala"; const district = "Ernakulam"; const role = "Doctor"; - const home_facility = "Dummy Shifting Center"; - const weekly_working_hrs = "14"; + const homeFacility = "Dummy Shifting Center"; + const weeklyWorkingHrs = "14"; const dob = "01011998"; - const formatted_dob = "01/01/1998"; - const update_btn = "Update"; - const save_btn = "Save User"; - const new_user_dob = "25081999"; + const formattedDob = "01/01/1998"; + const updateBtn = "Update"; + const saveBtn = "Save User"; + const newUserDob = "25081999"; before(() => { loginPage.loginAsDistrictAdmin(); @@ -97,28 +97,28 @@ describe("User Creation", () => { userCreationPage.typeLastName(lastName); userCreationPage.selectGender(gender); userCreationPage.clearPhoneNumber(); - userCreationPage.typePhoneNumber(phone_number); + userCreationPage.typePhoneNumber(phoneNumber); userCreationPage.clearAltPhoneNumber(); - userCreationPage.typeAltPhoneNumber(emergency_phone_number); + userCreationPage.typeAltPhoneNumber(emergencyPhoneNumber); userCreationPage.clearEmail(); userCreationPage.typeEmail(email); userCreationPage.clearWeeklyWorkingHours(); - userCreationPage.typeWeeklyWorkingHours(weekly_working_hrs); + userCreationPage.typeWeeklyWorkingHours(weeklyWorkingHrs); userCreationPage.typeDateOfBirth(dob); - cy.submitButton(update_btn); + cy.submitButton(updateBtn); cy.verifyContentPresence("#contactno-profile-details", [ - "+91" + phone_number, + "+91" + phoneNumber, ]); cy.verifyContentPresence("#whatsapp-profile-details", [ - "+91" + emergency_phone_number, + "+91" + emergencyPhoneNumber, ]); cy.verifyContentPresence("#firstname-profile-details", [firstName]); cy.verifyContentPresence("#lastname-profile-details", [lastName]); - cy.verifyContentPresence("#date_of_birth-profile-details", [formatted_dob]); + cy.verifyContentPresence("#date_of_birth-profile-details", [formattedDob]); cy.verifyContentPresence("#emailid-profile-details", [email]); cy.verifyContentPresence("#gender-profile-details", [gender]); cy.verifyContentPresence("#averageworkinghour-profile-details", [ - weekly_working_hrs, + weeklyWorkingHrs, ]); }); @@ -131,45 +131,45 @@ describe("User Creation", () => { userCreationPage.clearPhoneNumber(); userCreationPage.clearAltPhoneNumber(); userCreationPage.clearWeeklyWorkingHours(); - cy.submitButton(update_btn); + cy.submitButton(updateBtn); userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES); }); it("create new user and verify reflection", () => { userCreationPage.clickAddUserButton(); - userCreationPage.selectFacility(home_facility); + userCreationPage.selectFacility(homeFacility); userCreationPage.typeUserName(username); userCreationPage.typePassword(password); - userCreationPage.selectHomeFacility(home_facility); - userCreationPage.typeNewUserPhoneNumber(phone_number); - userCreationPage.typeDateOfBirth(new_user_dob); + userCreationPage.selectHomeFacility(homeFacility); + userCreationPage.typeNewUserPhoneNumber(phoneNumber); + userCreationPage.typeDateOfBirth(newUserDob); userCreationPage.selectUserType(role); userCreationPage.typeConfirmPassword(password); userCreationPage.typeQualification(qualification); userCreationPage.typeDoctorExperience(experince); - userCreationPage.typeDoctorMedicalCouncilRegNo(reg_no); - userCreationPage.typeNewUserFirstName(firstName_); - userCreationPage.typeNewUserLastName(lastName_); + userCreationPage.typeDoctorMedicalCouncilRegNo(regNo); + userCreationPage.typeNewUserFirstName(newUserFirstName); + userCreationPage.typeNewUserLastName(newUserLastName); userCreationPage.typeEmail(email); userCreationPage.selectGender(gender); userCreationPage.selectState(state); userCreationPage.selectDistrict(district); - userCreationPage.clickSubmitButton(); + cy.submitButton(saveBtn); cy.verifyNotification("User added successfully"); userPage.typeInSearchInput(username); userPage.checkUsernameText(username); - cy.verifyContentPresence("#name", [firstName_]); + cy.verifyContentPresence("#name", [newUserFirstName]); cy.verifyContentPresence("#role", [role]); cy.verifyContentPresence("#district", [district]); - cy.verifyContentPresence("#home_facility", [home_facility]); + cy.verifyContentPresence("#home_facility", [homeFacility]); cy.verifyContentPresence("#qualification", [qualification]); cy.verifyContentPresence("#doctor-experience", [experince]); - cy.verifyContentPresence("#medical-council-registration", [reg_no]); + cy.verifyContentPresence("#medical-council-registration", [regNo]); }); it("create new user form throwing mandatory field error", () => { userCreationPage.clickAddUserButton(); - cy.submitButton(save_btn); + cy.submitButton(saveBtn); cy.wait(2000); userCreationPage.verifyErrorMessages(EXPECTED_ERROR_MESSAGES); }); @@ -182,7 +182,7 @@ describe("User Creation", () => { facilityPage.visitAlreadyCreatedFacility(); facilityPage.clickManageFacilityDropdown(); facilityPage.clickViewUsersOption(); - userPage.verifyMultipleBadgesWithSameId(alreadylinkedusersviews); + userPage.verifyMultipleBadgesWithSameId(alreadyLinkedUsersViews); }); afterEach(() => { diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 1f706680b35..f4d16784e6d 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -1,28 +1,17 @@ // UserCreation.ts export class UserCreationPage { - private selectOptionContainingText(text: string) { - cy.get("[role='option']") - .contains(text) - .should("be.visible") - .click({ timeout: 10000 }); - } - clickProfileName() { cy.get("#user-profile-name").click(); } clickProfileButton() { - cy.get("#profile-button").click(); + cy.verifyAndClickElement("#profile-button", "Profile"); } clickEditProfileButton() { - cy.get("#edit-cancel-profile-button").click(); + cy.verifyAndClickElement("#edit-cancel-profile-button", "Edit Profile"); } clickAddUserButton() { - cy.get("#addUserButton").click(); - } - clickSubmitButton() { - cy.get("#submit").click(); + cy.verifyAndClickElement("#addUserButton", "Add New User"); } - typeUserName(username: string) { cy.get("#username").click().type(username); } @@ -35,7 +24,6 @@ export class UserCreationPage { typeEmail(email: string) { cy.get("#email").click().type(email); } - typePassword(password: string) { cy.get("#password").click().type(password); } @@ -51,24 +39,15 @@ export class UserCreationPage { 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); } - - typeIntoInputByName(inputName: string, value: string) { - cy.get("input[name='" + inputName + "']") - .click() - .type(value); - } typeDateOfBirth(dob: string) { cy.clickAndTypeDate("#date_of_birth", dob); } @@ -81,7 +60,6 @@ export class UserCreationPage { typeNewUserPhoneNumber(phoneNumber: string) { cy.get("#phone_number").click().type(phoneNumber); } - clearFirstName() { cy.get("#firstName").click().clear(); } @@ -117,9 +95,9 @@ export class UserCreationPage { selectDistrict(district: string) { cy.clickAndSelectOption("#district", district); } + selectFacility(name: string) { - this.typeIntoInputByName("facilities", name); - this.selectOptionContainingText(name); + cy.typeAndSelectOption("input[name='facilities']", name); cy.get("input[name='facilities'] + button") .find("#dropdown-toggle") .click(); From c021f4e269e463fd598580658888938202521467 Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Fri, 15 Nov 2024 11:01:06 +0530 Subject: [PATCH 13/23] PhoneNumber changes revered --- cypress/e2e/users_spec/UsersCreation.cy.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index d08e83a930f..d4fc2ff9e52 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -14,8 +14,8 @@ describe("User Creation", () => { const userCreationPage = new UserCreationPage(); const facilityPage = new FacilityPage(); const assetSearchPage = new AssetSearchPage(); - const phoneNumber = generatePhoneNumber(); - const emergencyPhoneNumber = generateEmergencyPhoneNumber(); + const phone_number = generatePhoneNumber(); + const emergency_phone_number = generateEmergencyPhoneNumber(); const fillFacilityName = "Dummy Facility 40"; const makeId = (length: number) => { let result = ""; @@ -97,9 +97,9 @@ describe("User Creation", () => { userCreationPage.typeLastName(lastName); userCreationPage.selectGender(gender); userCreationPage.clearPhoneNumber(); - userCreationPage.typePhoneNumber(phoneNumber); + userCreationPage.typePhoneNumber(phone_number); userCreationPage.clearAltPhoneNumber(); - userCreationPage.typeAltPhoneNumber(emergencyPhoneNumber); + userCreationPage.typeAltPhoneNumber(emergency_phone_number); userCreationPage.clearEmail(); userCreationPage.typeEmail(email); userCreationPage.clearWeeklyWorkingHours(); @@ -107,10 +107,10 @@ describe("User Creation", () => { userCreationPage.typeDateOfBirth(dob); cy.submitButton(updateBtn); cy.verifyContentPresence("#contactno-profile-details", [ - "+91" + phoneNumber, + "+91" + phone_number, ]); cy.verifyContentPresence("#whatsapp-profile-details", [ - "+91" + emergencyPhoneNumber, + "+91" + emergency_phone_number, ]); cy.verifyContentPresence("#firstname-profile-details", [firstName]); cy.verifyContentPresence("#lastname-profile-details", [lastName]); @@ -141,7 +141,7 @@ describe("User Creation", () => { userCreationPage.typeUserName(username); userCreationPage.typePassword(password); userCreationPage.selectHomeFacility(homeFacility); - userCreationPage.typeNewUserPhoneNumber(phoneNumber); + userCreationPage.typeNewUserPhoneNumber(phone_number); userCreationPage.typeDateOfBirth(newUserDob); userCreationPage.selectUserType(role); userCreationPage.typeConfirmPassword(password); @@ -170,7 +170,7 @@ describe("User Creation", () => { it("create new user form throwing mandatory field error", () => { userCreationPage.clickAddUserButton(); cy.submitButton(saveBtn); - cy.wait(2000); + cy.get(".error-text", { timeout: 10000 }).should("be.visible"); userCreationPage.verifyErrorMessages(EXPECTED_ERROR_MESSAGES); }); From 92fde8b49445a32cea47d477637fea7fc580f94e Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Tue, 26 Nov 2024 21:33:32 +0530 Subject: [PATCH 14/23] Made requested changes --- cypress/e2e/users_spec/UsersCreation.cy.ts | 72 ++++++++++++--------- cypress/e2e/users_spec/UsersProfile.cy.ts | 4 +- cypress/pageobject/Users/UserCreation.ts | 58 ----------------- cypress/pageobject/Users/UserProfilePage.ts | 17 ++++- 4 files changed, 57 insertions(+), 94 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index d4fc2ff9e52..e17dcf6666a 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -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"; @@ -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(); @@ -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, ]); @@ -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); }); @@ -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]); @@ -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); }); diff --git a/cypress/e2e/users_spec/UsersProfile.cy.ts b/cypress/e2e/users_spec/UsersProfile.cy.ts index 35771024180..07e93607532 100644 --- a/cypress/e2e/users_spec/UsersProfile.cy.ts +++ b/cypress/e2e/users_spec/UsersProfile.cy.ts @@ -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); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index f4d16784e6d..5b1515f4d0b 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -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"); } @@ -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); } @@ -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) { diff --git a/cypress/pageobject/Users/UserProfilePage.ts b/cypress/pageobject/Users/UserProfilePage.ts index 3744c5a5d82..de72fb51be0 100644 --- a/cypress/pageobject/Users/UserProfilePage.ts +++ b/cypress/pageobject/Users/UserProfilePage.ts @@ -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(); @@ -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); } From e735efa26d1b38107d06b6b024e75939ce25e810 Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Wed, 27 Nov 2024 00:19:48 +0530 Subject: [PATCH 15/23] made suggestions from the code rabbit --- cypress/e2e/users_spec/UsersCreation.cy.ts | 10 ++++----- cypress/e2e/users_spec/UsersProfile.cy.ts | 8 +++---- cypress/pageobject/Users/UserProfilePage.ts | 23 +++++++++------------ 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index e17dcf6666a..b29315582ed 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -65,7 +65,7 @@ describe("User Creation", () => { const email = "test@test.com"; const password = "Test@123"; const qualification = "MBBS"; - const experince = "2"; + const experience = "2"; const regNo = "123456789"; const newUserFirstName = "cypress test"; const newUserLastName = "staff user"; @@ -108,7 +108,7 @@ describe("User Creation", () => { userProfilePage.typeEmail(email); userProfilePage.clearWorkingHours(); userProfilePage.typeWorkingHours(weeklyWorkingHrs); - userProfilePage.typedate_of_birth(dob); + userProfilePage.typeDateOfBirth(dob); cy.intercept("PATCH", "/api/v1/users/*").as("updateUser"); cy.clickSubmitButton(updateBtn); cy.wait("@updateUser").its("response.statusCode").should("eq", 200); @@ -148,10 +148,10 @@ describe("User Creation", () => { userCreationPage.typeConfirmPassword(password); userCreationPage.selectHomeFacility(homeFacility); userPage.typeInPhoneNumber(phone_number); - userProfilePage.typedate_of_birth(newUserDob); + userProfilePage.typeDateOfBirth(newUserDob); userCreationPage.selectUserType(role); userProfilePage.typeQualification(qualification); - userProfilePage.typeDoctorYoE(experince); + userProfilePage.typeDoctorYoE(experience); userProfilePage.typeMedicalCouncilRegistration(regNo); userPage.typeInFirstName(newUserFirstName); userPage.typeInLastName(newUserLastName); @@ -171,7 +171,7 @@ describe("User Creation", () => { cy.verifyContentPresence("#district", [district]); cy.verifyContentPresence("#home_facility", [homeFacility]); cy.verifyContentPresence("#qualification", [qualification]); - cy.verifyContentPresence("#doctor-experience", [experince]); + cy.verifyContentPresence("#doctor-experience", [experience]); cy.verifyContentPresence("#medical-council-registration", [regNo]); }); diff --git a/cypress/e2e/users_spec/UsersProfile.cy.ts b/cypress/e2e/users_spec/UsersProfile.cy.ts index 07e93607532..e208d088489 100644 --- a/cypress/e2e/users_spec/UsersProfile.cy.ts +++ b/cypress/e2e/users_spec/UsersProfile.cy.ts @@ -32,7 +32,7 @@ describe("Manage User Profile", () => { it("Set Dob, Gender, Email, Phone and Working Hours for a user and verify its reflection in user profile", () => { userProfilePage.clickEditProfileButton(); - userProfilePage.typedate_of_birth(date_of_birth); + userProfilePage.typeDateOfBirth(date_of_birth); userProfilePage.selectGender(gender); userProfilePage.typeEmail(email); userProfilePage.typePhoneNumber(phone); @@ -46,11 +46,11 @@ describe("Manage User Profile", () => { cy.verifyNotification("Details updated successfully"); - userProfilePage.assertdate_of_birth("01/01/1999"); + userProfilePage.assertDateOfBirth("01/01/1999"); userProfilePage.assertGender(gender); userProfilePage.assertEmail(email); - userProfilePage.assertPhone(phone); - userProfilePage.assertWhatsApp(phone); + userProfilePage.assertPhoneNumber(phone); + userProfilePage.assertAltPhoneNumber(phone); userProfilePage.assertWorkingHours(workinghours); }); diff --git a/cypress/pageobject/Users/UserProfilePage.ts b/cypress/pageobject/Users/UserProfilePage.ts index de72fb51be0..1d0c5ccc25a 100644 --- a/cypress/pageobject/Users/UserProfilePage.ts +++ b/cypress/pageobject/Users/UserProfilePage.ts @@ -15,8 +15,8 @@ export default class UserProfilePage { cy.get("#submit").click(); } - typedate_of_birth(date_of_birth: string) { - cy.clickAndTypeDate("#date_of_birth", date_of_birth); + typeDateOfBirth(dob: string) { + cy.clickAndTypeDate("#date_of_birth", dob); } clearPhoneNumber() { @@ -49,8 +49,8 @@ export default class UserProfilePage { cy.get("#altPhoneNumber").click().clear().type(phone); } - typeWorkingHours(workinghours: string) { - cy.get("#weekly_working_hours").click().clear().type(workinghours); + typeWorkingHours(workingHours: string) { + cy.get("#weekly_working_hours").click().clear().type(workingHours); } typeQualification = (qualification: string) => { @@ -68,11 +68,8 @@ export default class UserProfilePage { .type(medicalCouncilRegistration); }; - assertdate_of_birth(date_of_birth: string) { - cy.get("#date_of_birth-profile-details").should( - "contain.text", - date_of_birth, - ); + assertDateOfBirth(dob: string) { + cy.get("#date_of_birth-profile-details").should("contain.text", dob); } assertGender(gender: string) { @@ -83,18 +80,18 @@ export default class UserProfilePage { cy.get("#emailid-profile-details").should("contain.text", email); } - assertPhone(phone: string) { + assertPhoneNumber(phone: string) { cy.get("#contactno-profile-details").should("contain.text", phone); } - assertWhatsApp(phone: string) { + assertAltPhoneNumber(phone: string) { cy.get("#whatsapp-profile-details").should("contain.text", phone); } - assertWorkingHours(workinghours: string) { + assertWorkingHours(workingHours: string) { cy.get("#averageworkinghour-profile-details").should( "contain.text", - workinghours, + workingHours, ); } } From b51a349add91f15ac6857abdddbd0cac875af5da Mon Sep 17 00:00:00 2001 From: AnveshNalimela Date: Wed, 27 Nov 2024 00:45:49 +0530 Subject: [PATCH 16/23] updated package-lock.json --- package-lock.json | 81 ++--------------------------------------------- 1 file changed, 3 insertions(+), 78 deletions(-) diff --git a/package-lock.json b/package-lock.json index cad8abc1b79..5c703af8fe1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -117,6 +117,7 @@ "apps/care_livekit_fe": { "name": "care-livekit", "version": "0.0.1", + "extraneous": true, "license": "ISC", "dependencies": { "@livekit/components-react": "^2.6.2", @@ -1955,11 +1956,6 @@ "node": ">=6.9.0" } }, - "node_modules/@bufbuild/protobuf": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.10.0.tgz", - "integrity": "sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==" - }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -7108,10 +7104,6 @@ "node": ">=6" } }, - "node_modules/care-livekit": { - "resolved": "apps/care_livekit_fe", - "link": true - }, "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -12232,27 +12224,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/livekit-client": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/livekit-client/-/livekit-client-2.6.0.tgz", - "integrity": "sha512-hpxNBtyWIFCefoHjHoSjqPCw3m7AfSJVcVZw6rMsqds4u+dSpWLfYkglWP8JuPGUIssyOsZm/+bV3gBWfuOGGQ==", - "dependencies": { - "@livekit/mutex": "1.0.0", - "@livekit/protocol": "1.24.0", - "events": "^3.3.0", - "loglevel": "^1.8.0", - "sdp-transform": "^2.14.1", - "ts-debounce": "^4.0.0", - "tslib": "2.7.0", - "typed-emitter": "^2.1.0", - "webrtc-adapter": "^9.0.0" - } - }, - "node_modules/livekit-client/node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" - }, "node_modules/load-plugin": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/load-plugin/-/load-plugin-6.0.3.tgz", @@ -12364,6 +12335,7 @@ "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true, "license": "MIT" }, "node_modules/lodash.isplainobject": { @@ -12458,18 +12430,6 @@ "node": ">=8" } }, - "node_modules/loglevel": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.1.tgz", - "integrity": "sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==", - "engines": { - "node": ">= 0.6.0" - }, - "funding": { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/loglevel" - } - }, "node_modules/long": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", @@ -16786,14 +16746,6 @@ "integrity": "sha512-d7wDPgDV3DDiqulJjKiV2865wKsJ34YI+NDREbm+FySq6WuKOikwyNQcm+doLAZ1O6ltdO0SeKle2xMpN3Brgw==", "license": "MIT" }, - "node_modules/sdp-transform": { - "version": "2.14.2", - "resolved": "https://registry.npmjs.org/sdp-transform/-/sdp-transform-2.14.2.tgz", - "integrity": "sha512-icY6jVao7MfKCieyo1AyxFYm1baiM+fA00qW/KrNNVlkxHAd34riEKuEkUe4bBb3gJwLJZM+xT60Yj1QL8rHiA==", - "bin": { - "sdp-verify": "checker.js" - } - }, "node_modules/semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", @@ -18130,11 +18082,6 @@ "typescript": ">=4.2.0" } }, - "node_modules/ts-debounce": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/ts-debounce/-/ts-debounce-4.0.0.tgz", - "integrity": "sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==" - }, "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", @@ -18313,14 +18260,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/typed-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-2.1.0.tgz", - "integrity": "sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==", - "optionalDependencies": { - "rxjs": "*" - } - }, "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -18875,20 +18814,6 @@ "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/usehooks-ts": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-3.1.0.tgz", - "integrity": "sha512-bBIa7yUyPhE1BCc0GmR96VU/15l/9gP1Ch5mYdLcFBaFGQsdmXkvjV0TtOqW1yUd6VjIwDunm+flSciCQXujiw==", - "dependencies": { - "lodash.debounce": "^4.0.8" - }, - "engines": { - "node": ">=16.15.0" - }, - "peerDependencies": { - "react": "^16.8.0 || ^17 || ^18" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -20937,4 +20862,4 @@ } } } -} \ No newline at end of file +} From 0c5135fb04185931af24e210de9d7f7c6af4e230 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Thu, 28 Nov 2024 15:06:49 +0530 Subject: [PATCH 17/23] fix line endings --- .husky/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index d0a778429a3..2312dc587f6 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -npx lint-staged \ No newline at end of file +npx lint-staged From ad5da79faa6f272615841a518a6dc1895dca50e6 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Sat, 30 Nov 2024 02:03:24 +0530 Subject: [PATCH 18/23] coderabbit suggestions --- cypress/e2e/users_spec/UsersCreation.cy.ts | 14 +++++++------- cypress/pageobject/Users/UserProfilePage.ts | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index b29315582ed..9fe3efde5ff 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -19,8 +19,8 @@ describe("User Creation", () => { const userCreationPage = new UserCreationPage(); const facilityPage = new FacilityPage(); const assetSearchPage = new AssetSearchPage(); - const phone_number = generatePhoneNumber(); - const emergency_phone_number = generateEmergencyPhoneNumber(); + const phoneNumber = generatePhoneNumber(); + const emergencyPhoneNumber = generateEmergencyPhoneNumber(); const fillFacilityName = "Dummy Facility 40"; const makeId = (length: number) => { let result = ""; @@ -101,9 +101,9 @@ describe("User Creation", () => { userCreationPage.typeLastName(lastName); userProfilePage.selectGender(gender); userProfilePage.clearPhoneNumber(); - userProfilePage.typePhoneNumber(phone_number); + userProfilePage.typePhoneNumber(phoneNumber); userProfilePage.clearAltPhoneNumber(); - userProfilePage.typeAltPhoneNumber(emergency_phone_number); + userProfilePage.typeWhatsappNumber(emergencyPhoneNumber); userProfilePage.clearEmail(); userProfilePage.typeEmail(email); userProfilePage.clearWorkingHours(); @@ -113,10 +113,10 @@ describe("User Creation", () => { cy.clickSubmitButton(updateBtn); cy.wait("@updateUser").its("response.statusCode").should("eq", 200); cy.verifyContentPresence("#contactno-profile-details", [ - "+91" + phone_number, + "+91" + phoneNumber, ]); cy.verifyContentPresence("#whatsapp-profile-details", [ - "+91" + emergency_phone_number, + "+91" + emergencyPhoneNumber, ]); cy.verifyContentPresence("#firstname-profile-details", [firstName]); cy.verifyContentPresence("#lastname-profile-details", [lastName]); @@ -147,7 +147,7 @@ describe("User Creation", () => { userCreationPage.typePassword(password); userCreationPage.typeConfirmPassword(password); userCreationPage.selectHomeFacility(homeFacility); - userPage.typeInPhoneNumber(phone_number); + userPage.typeInPhoneNumber(phoneNumber); userProfilePage.typeDateOfBirth(newUserDob); userCreationPage.selectUserType(role); userProfilePage.typeQualification(qualification); diff --git a/cypress/pageobject/Users/UserProfilePage.ts b/cypress/pageobject/Users/UserProfilePage.ts index 1d0c5ccc25a..93777abf921 100644 --- a/cypress/pageobject/Users/UserProfilePage.ts +++ b/cypress/pageobject/Users/UserProfilePage.ts @@ -45,7 +45,7 @@ export default class UserProfilePage { cy.get("#phoneNumber").click().clear().type(phone); } - typeAltPhoneNumber(phone: string) { + typeWhatsappNumber(phone: string) { cy.get("#altPhoneNumber").click().clear().type(phone); } From 66c80648acbfb450e3196a9a5e227ba1eb821466 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Sat, 30 Nov 2024 02:12:28 +0530 Subject: [PATCH 19/23] number variable modified --- cypress/e2e/users_spec/UsersProfile.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/users_spec/UsersProfile.cy.ts b/cypress/e2e/users_spec/UsersProfile.cy.ts index e208d088489..fba07e526fd 100644 --- a/cypress/e2e/users_spec/UsersProfile.cy.ts +++ b/cypress/e2e/users_spec/UsersProfile.cy.ts @@ -36,7 +36,7 @@ describe("Manage User Profile", () => { userProfilePage.selectGender(gender); userProfilePage.typeEmail(email); userProfilePage.typePhoneNumber(phone); - userProfilePage.typeAltPhoneNumber(phone); + userProfilePage.typeWhatsappNumber(phone); userProfilePage.typeWorkingHours(workinghours); userProfilePage.typeQualification(qualification); userProfilePage.typeDoctorYoE(doctorYoE); From cd7c5516fa69cf1b27f1e7e98c9dd1f6f7090fb7 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Sat, 30 Nov 2024 02:39:13 +0530 Subject: [PATCH 20/23] removed hard code --- cypress/e2e/users_spec/UsersCreation.cy.ts | 11 ++++------- cypress/e2e/users_spec/UsersManage.cy.ts | 7 ++----- cypress/e2e/users_spec/UsersProfile.cy.ts | 3 --- cypress/pageobject/Users/UserCreation.ts | 4 ++-- cypress/pageobject/Users/UserProfilePage.ts | 2 +- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index 9fe3efde5ff..96b953a3e17 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -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(() => { @@ -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, @@ -136,7 +134,7 @@ describe("User Creation", () => { userProfilePage.clearPhoneNumber(); userProfilePage.clearAltPhoneNumber(); userProfilePage.clearWorkingHours(); - cy.clickSubmitButton(updateBtn); + userProfilePage.clickUpdateButton(); userCreationPage.verifyErrorMessages(EXPECTED_PROFILE_ERROR_MESSAGES); }); @@ -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]); @@ -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); }); diff --git a/cypress/e2e/users_spec/UsersManage.cy.ts b/cypress/e2e/users_spec/UsersManage.cy.ts index 40d436be0a6..3a9f9b32aef 100644 --- a/cypress/e2e/users_spec/UsersManage.cy.ts +++ b/cypress/e2e/users_spec/UsersManage.cy.ts @@ -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", () => { @@ -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"; @@ -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); }); diff --git a/cypress/e2e/users_spec/UsersProfile.cy.ts b/cypress/e2e/users_spec/UsersProfile.cy.ts index fba07e526fd..32b812a188f 100644 --- a/cypress/e2e/users_spec/UsersProfile.cy.ts +++ b/cypress/e2e/users_spec/UsersProfile.cy.ts @@ -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); diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 5b1515f4d0b..72157861f2c 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -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[]) { diff --git a/cypress/pageobject/Users/UserProfilePage.ts b/cypress/pageobject/Users/UserProfilePage.ts index 93777abf921..882be0b7b9b 100644 --- a/cypress/pageobject/Users/UserProfilePage.ts +++ b/cypress/pageobject/Users/UserProfilePage.ts @@ -12,7 +12,7 @@ export default class UserProfilePage { } clickUpdateButton() { - cy.get("#submit").click(); + cy.clickSubmitButton("Update"); } typeDateOfBirth(dob: string) { From 360c540b0f48dd0e2500ed156e5ac20aaeffe6c7 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Sat, 30 Nov 2024 02:48:03 +0530 Subject: [PATCH 21/23] secure the phone number generation --- cypress/pageobject/utils/constants.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cypress/pageobject/utils/constants.ts b/cypress/pageobject/utils/constants.ts index 08411e84b6a..053d0561ce8 100644 --- a/cypress/pageobject/utils/constants.ts +++ b/cypress/pageobject/utils/constants.ts @@ -1,7 +1,10 @@ -export function generatePhoneNumber() { - return "9" + Math.floor(100000000 + Math.random() * 900000000).toString(); +export function generatePhoneNumber(): string { + const array = new Uint32Array(1); + window.crypto.getRandomValues(array); + const randomNum = (array[0] % 900000000) + 100000000; + return "9" + randomNum.toString(); } -export function generateEmergencyPhoneNumber() { - return "9" + Math.floor(100000000 + Math.random() * 900000000).toString(); +export function generateEmergencyPhoneNumber(): string { + return generatePhoneNumber(); } From e24c032af742ba1b395ab2853742f81f77d02082 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Sat, 30 Nov 2024 02:52:03 +0530 Subject: [PATCH 22/23] add missing # to id --- cypress/e2e/users_spec/UsersManage.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/users_spec/UsersManage.cy.ts b/cypress/e2e/users_spec/UsersManage.cy.ts index 3a9f9b32aef..74baee3deac 100644 --- a/cypress/e2e/users_spec/UsersManage.cy.ts +++ b/cypress/e2e/users_spec/UsersManage.cy.ts @@ -46,7 +46,7 @@ describe("Manage User", () => { manageUserPage.clickCloseSlideOver(); cy.wait(5000); manageUserPage.navigateToProfile(); - cy.verifyContentPresence("username-profile-details", [ + cy.verifyContentPresence("#username-profile-details", [ usernameforworkinghour, ]); manageUserPage.assertSkillInAlreadyLinkedSkills(linkedskill); From 185e6f36ef333e6685dbdb592b84b774fb440788 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Sat, 30 Nov 2024 04:32:37 +0530 Subject: [PATCH 23/23] modified the bed name --- cypress/e2e/facility_spec/FacilityLocation.cy.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/facility_spec/FacilityLocation.cy.ts b/cypress/e2e/facility_spec/FacilityLocation.cy.ts index 9ac85e9ba4c..19c43d4dcf4 100644 --- a/cypress/e2e/facility_spec/FacilityLocation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityLocation.cy.ts @@ -36,6 +36,7 @@ describe("Location Management Section", () => { const bedType = "ICU"; const bedStatus = "Vacant"; const bedModifiedName = "test modified bed"; + const duplicateBedName = "ICCU"; const bedModifiedDescrption = "test modified description"; const bedModifiedType = "Isolation"; const numberOfBeds = 10; @@ -96,12 +97,12 @@ describe("Location Management Section", () => { facilityHome.verifyAndCloseNotifyModal(); // edit the created bed facilityLocation.clickEditBedButton(); - facilityLocation.enterBedName(bedModifiedName); + facilityLocation.enterBedName(duplicateBedName); facilityLocation.enterBedDescription(bedModifiedDescrption); facilityLocation.selectBedType(bedModifiedType); assetPage.clickassetupdatebutton(); // verify the modification - facilityLocation.verifyBedNameBadge(bedModifiedName); + facilityLocation.verifyBedNameBadge(duplicateBedName); facilityLocation.verifyBedBadge(bedModifiedType); facilityLocation.verifyBedBadge(bedStatus); facilityLocation.closeNotification();