Skip to content

Commit

Permalink
Asset page redirection (ohcnetwork#6308)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Sep 19, 2023
1 parent 856a7e9 commit 8946529
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cypress/e2e/assets_spec/assets_manage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import { AssetPage } from "../../pageobject/Asset/AssetCreation";
import LoginPage from "../../pageobject/Login/LoginPage";
import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import { AssetFilters } from "../../pageobject/Asset/AssetFilters";

describe("Asset", () => {
const assetPage = new AssetPage();
const loginPage = new LoginPage();
const facilityPage = new FacilityPage();
const assetSearchPage = new AssetSearchPage();
const assetFilters = new AssetFilters();
const fillFacilityName = "Dummy Facility 1";

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand All @@ -23,6 +30,23 @@ describe("Asset", () => {
assetPage.verifyDeleteStatus();
});

it("Verify Facility Asset Page Redirection", () => {
cy.visit("/facility");
assetSearchPage.typeSearchKeyword(fillFacilityName);
assetSearchPage.pressEnter();
facilityPage.verifyFacilityBadgeContent(fillFacilityName);
facilityPage.visitAlreadyCreatedFacility();
facilityPage.clickManageFacilityDropdown();
facilityPage.clickCreateAssetFacilityOption();
facilityPage.verifyfacilitycreateassetredirection();
facilityPage.verifyassetfacilitybackredirection();
facilityPage.clickManageFacilityDropdown();
facilityPage.clickviewAssetFacilityOption();
facilityPage.verifyfacilityviewassetredirection();
assetFilters.assertFacilityText(fillFacilityName);
facilityPage.verifyassetfacilitybackredirection();
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
35 changes: 35 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ class FacilityPage {
cy.get("#configure-facility").contains("Configure Facility").click();
}

clickCreateAssetFacilityOption() {
cy.get("#create-assets").contains("Create Asset").click();
}

clickviewAssetFacilityOption() {
cy.get("#view-assets").contains("View Assets").click();
}

clickInventoryManagementOption() {
cy.get("#inventory-management", { timeout: 10000 }).should("be.visible");
cy.get("#inventory-management").click();
Expand Down Expand Up @@ -175,6 +183,33 @@ class FacilityPage {
cy.wait("@getFacilities").its("response.statusCode").should("eq", 200);
}

verifyFacilityBadgeContent(expectedText: string) {
cy.get("[data-testid='Facility/District Name']").should(
"contain",
expectedText
);
}

verifyfacilitycreateassetredirection() {
cy.intercept("GET", "**/api/v1/facility/**").as("getNewAssets");
cy.url().should("include", "/assets/new");
cy.wait("@getNewAssets").its("response.statusCode").should("eq", 200);
}

verifyassetfacilitybackredirection() {
cy.intercept("GET", "**/api/v1/facility/**").as("getManagePage");
cy.go("back");
cy.wait("@getManagePage").its("response.statusCode").should("eq", 200);
cy.get("#manage-facility-dropdown").scrollIntoView();
cy.get("#manage-facility-dropdown").should("exist");
}

verifyfacilityviewassetredirection() {
cy.intercept("GET", "**api/v1/getallfacilities/**").as("getViewAssets");
cy.url().should("include", "/assets?facility=");
cy.wait("@getViewAssets").its("response.statusCode").should("eq", 200);
}

clickManageInventory() {
cy.contains("Manage Inventory").click();
}
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -575,19 +575,22 @@ export const FacilityHome = (props: any) => {
Resource Request
</DropdownItem>
<DropdownItem
id="create-assets"
onClick={() => navigate(`/facility/${facilityId}/assets/new`)}
authorizeFor={NonReadOnlyUsers}
icon={<CareIcon className="care-l-plus-circle text-lg" />}
>
Create Asset
</DropdownItem>
<DropdownItem
id="view-assets"
onClick={() => navigate(`/assets?facility=${facilityId}`)}
icon={<CareIcon className="care-l-medkit text-lg" />}
>
View Assets
</DropdownItem>
<DropdownItem
id="view-users"
onClick={() => navigate(`/facility/${facilityId}/users`)}
icon={<CareIcon className="care-l-users-alt text-lg" />}
>
Expand Down

0 comments on commit 8946529

Please sign in to comment.