Skip to content

Commit

Permalink
New Cypress Test | Facility Redirection to view user page | User Tab (#…
Browse files Browse the repository at this point in the history
…6513)

* cypress new test for advance filter

* convert navigation to POM

* facility redirection

* minor change

* revert package-lock
  • Loading branch information
nihal467 authored Oct 30, 2023
1 parent 23bdb1f commit fa3b4a7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
43 changes: 43 additions & 0 deletions cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
4 changes: 4 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions cypress/pageobject/Users/UserSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
}
}
5 changes: 4 additions & 1 deletion src/Components/Facility/FacilityUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ export default function FacilityUsers(props: any) {
<div className="px-6 py-4">
<div className="flex flex-col justify-between lg:flex-row">
{user.username && (
<div className="inline-flex w-fit items-center rounded-md bg-blue-100 px-2.5 py-0.5 text-sm font-medium leading-5 text-blue-800">
<div
id="user-view-name"
className="inline-flex w-fit items-center rounded-md bg-blue-100 px-2.5 py-0.5 text-sm font-medium leading-5 text-blue-800"
>
{user.username}
</div>
)}
Expand Down

0 comments on commit fa3b4a7

Please sign in to comment.