Skip to content

Commit

Permalink
working hour cypress test (#6566)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Nov 8, 2023
1 parent 6c4f151 commit f0db72e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
18 changes: 18 additions & 0 deletions cypress/e2e/users_spec/user_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
31 changes: 31 additions & 0 deletions cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export default function ManageUsers() {
) && (
<div className="flex-col md:flex-row">
<ButtonV2
id="skills"
id="avg-workinghour"
className="flex w-full items-center md:w-full"
onClick={() => {
setExpandWorkingHours(true);
Expand Down

0 comments on commit f0db72e

Please sign in to comment.