diff --git a/cypress/e2e/users_spec/user_creation.cy.ts b/cypress/e2e/users_spec/user_creation.cy.ts new file mode 100644 index 00000000000..498697566c5 --- /dev/null +++ b/cypress/e2e/users_spec/user_creation.cy.ts @@ -0,0 +1,43 @@ +import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch"; +import FacilityPage from "../../pageobject/Facility/FacilityCreation"; +import { UserPage } from "../../pageobject/Users/UserSearch"; + +describe("User Creation", () => { + const userPage = new UserPage(); + const loginPage = new LoginPage(); + const facilityPage = new FacilityPage(); + const assetSearchPage = new AssetSearchPage(); + const fillFacilityName = "Dummy Facility 1"; + const alreadylinkedusersviews = [ + "devdoctor", + "devstaff2", + "devdistrictadmin", + ]; + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.awaitUrl("/users"); + }); + + it("view user redirection from facility page", () => { + cy.visit("/facility"); + assetSearchPage.typeSearchKeyword(fillFacilityName); + assetSearchPage.pressEnter(); + facilityPage.verifyFacilityBadgeContent(fillFacilityName); + facilityPage.visitAlreadyCreatedFacility(); + facilityPage.clickManageFacilityDropdown(); + facilityPage.clickViewUsersOption(); + userPage.verifyMultipleBadgesWithSameId(alreadylinkedusersviews); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index e0a572ccaec..d27433f04e7 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -129,6 +129,10 @@ class FacilityPage { cy.get("#view-assets").contains("View Assets").click(); } + clickViewUsersOption() { + cy.get("#view-users").click(); + } + clickInventoryManagementOption() { cy.get("#inventory-management", { timeout: 10000 }).should("be.visible"); cy.get("#inventory-management").click(); diff --git a/cypress/pageobject/Users/UserSearch.ts b/cypress/pageobject/Users/UserSearch.ts index 6be0603be43..4956532277f 100644 --- a/cypress/pageobject/Users/UserSearch.ts +++ b/cypress/pageobject/Users/UserSearch.ts @@ -103,4 +103,10 @@ export class UserPage { verifyCurrentPageNumber(pageNumber: number) { cy.url().should("include", `page=${pageNumber}`); } + + verifyMultipleBadgesWithSameId(expectedContents: string[]) { + cy.get("#user-view-name").each((el, index) => { + expect(el.text().trim()).to.equal(expectedContents[index]); + }); + } } diff --git a/src/Components/Facility/FacilityUsers.tsx b/src/Components/Facility/FacilityUsers.tsx index 3008e54f830..caff279ad7e 100644 --- a/src/Components/Facility/FacilityUsers.tsx +++ b/src/Components/Facility/FacilityUsers.tsx @@ -308,7 +308,10 @@ export default function FacilityUsers(props: any) {