diff --git a/cypress/e2e/users_spec/user_manage.cy.ts b/cypress/e2e/users_spec/user_manage.cy.ts index 384a88ceab3..b7e1e8b53e9 100644 --- a/cypress/e2e/users_spec/user_manage.cy.ts +++ b/cypress/e2e/users_spec/user_manage.cy.ts @@ -10,8 +10,10 @@ describe("Manage User", () => { const usernametolinkfacilitydoc1 = "dummydoctor4"; const usernametolinkfacilitydoc2 = "dummydoctor5"; const usernametolinkfacilitydoc3 = "dummydoctor6"; + const usernametolinkskill = "devdistrictadmin"; const usernamerealname = "Dummy Doctor"; const facilitytolinkusername = "Dummy Shifting Center"; + const workinghour = "23"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -23,6 +25,22 @@ describe("Manage User", () => { cy.awaitUrl("/users"); }); + it("add working hour for a user and verify its reflection in card and user profile", () => { + // verify mandatory field error and select working hour for a user + userPage.typeInSearchInput(usernametolinkskill); + userPage.checkUsernameText(usernametolinkskill); + manageUserPage.clicksetaveragehourbutton(); + manageUserPage.clearweeklyhourfield(); + manageUserPage.clickSubmit(); + manageUserPage.verifyErrorText("Value should be between 0 and 168"); + // verify the data is reflected in user card and profile page + manageUserPage.typeInWeeklyWorkingHours(workinghour); + manageUserPage.clickSubmit(); + manageUserPage.verifyWorkingHours(workinghour); + manageUserPage.navigateToProfile(); + manageUserPage.verifyProfileWorkingHours(workinghour); + }); + it("linking and unlinking facility for multiple users, and confirm reflection in user cards and doctor connect", () => { // verify the user doesn't have any home facility userPage.typeInSearchInput(usernametolinkfacilitydoc1); diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index 0775408abb4..70e617f7e35 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -56,6 +56,37 @@ export class ManageUserPage { cy.get("#submit").click(); } + clicksetaveragehourbutton() { + cy.get("#avg-workinghour").click(); + } + + clearweeklyhourfield() { + cy.get("#weekly_working_hours").click().clear(); + } + + verifyErrorText(expectedError: string) { + cy.get(".error-text").should("contain", expectedError).and("be.visible"); + } + + typeInWeeklyWorkingHours(hours: string) { + cy.get("#weekly_working_hours").click().type(hours); + } + + navigateToProfile() { + cy.get("#profilenamelink").click(); + } + + verifyWorkingHours(expectedHours: string) { + cy.get("#working-hours").should("contain", `${expectedHours} hours`); + } + + verifyProfileWorkingHours(expectedHours: string) { + cy.get("#averageworkinghour-profile-details").should( + "contain", + expectedHours + ); + } + navigateToFacility() { cy.visit("/facility"); } diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index dcbaf98a9b0..8d412aef7b8 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -442,7 +442,7 @@ export default function ManageUsers() { ) && (
{ setExpandWorkingHours(true);