Skip to content

Commit

Permalink
verify asset filter (ohcnetwork#6275)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Sep 13, 2023
1 parent 8a704af commit f72a1cf
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
12 changes: 11 additions & 1 deletion cypress/e2e/assets_spec/asset_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,18 @@ describe("Asset Tab", () => {
"Dummy Facility 1",
"INTERNAL",
"ACTIVE",
"ONVIF Camera"
"ONVIF Camera",
"Camera Loc"
);
assetFilters.clickadvancefilter();
assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters
assetFilters.assertFacilityText("Dummy Facility 1");
assetFilters.assertAssetTypeText("INTERNAL");
assetFilters.assertAssetClassText("ONVIF");
assetFilters.assertStatusText("ACTIVE");
assetFilters.assertLocationText("Camera Locations");
assetFilters.clickadvancefilter();
assetFilters.clearFilters();
});

// Verify the pagination in the page
Expand Down
39 changes: 38 additions & 1 deletion cypress/pageobject/Asset/AssetFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export class AssetFilters {
facilityName: string,
assetType: string,
assetStatus: string,
assetClass: string
assetClass: string,
assetLocation: string
) {
cy.contains("Advanced Filters").click();
cy.get("input[name='Facilities']")
Expand All @@ -27,6 +28,42 @@ export class AssetFilters {
.then(() => {
cy.get("[role='option']").contains(assetClass).click();
});
cy.get("#Facilities-location")
.click()
.type(assetLocation)
.then(() => {
cy.get("[role='option']").contains(assetLocation).click();
});
cy.contains("Apply").click();
}
clearFilters() {
cy.intercept("GET", "**/api/v1/asset/**").as("clearAssets");
cy.get("#clear-filter").click();
cy.wait("@clearAssets").its("response.statusCode").should("eq", 200);
cy.url().should("match", /\/assets$/);
}
clickadvancefilter() {
cy.intercept("GET", "**/api/v1/getallfacilities/**").as("advancefilter");
cy.get("#advanced-filter").click();
cy.wait("@advancefilter").its("response.statusCode").should("eq", 200);
}
clickslideoverbackbutton() {
cy.get("#close-slide-over").click();
}
// Assertions
assertFacilityText(text) {
cy.get("[data-testid=Facility]").should("contain", text);
}
assertAssetTypeText(text) {
cy.get("[data-testid='Asset Type']").should("contain", text);
}
assertAssetClassText(text) {
cy.get("[data-testid='Asset Class']").should("contain", text);
}
assertStatusText(text) {
cy.get("[data-testid=Status]").should("contain", text);
}
assertLocationText(text) {
cy.get("[data-testid=Location]").should("contain", text);
}
}
4 changes: 3 additions & 1 deletion cypress/pageobject/Asset/AssetSearch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class AssetSearchPage {
typeSearchKeyword(keyword: string) {
cy.get("#search").clear();
cy.get("#search").click().clear();
cy.get("#search").click().type(keyword);
}

Expand All @@ -9,7 +9,9 @@ export class AssetSearchPage {
}

clickAssetByName(assetName: string) {
cy.intercept("GET", "**/api/v1/asset/**").as("clearAssets");
cy.get("[data-testid='created-asset-list']").contains(assetName).click();
cy.wait("@clearAssets").its("response.statusCode").should("eq", 200);
}

verifyBadgeContent(expectedText: string) {
Expand Down
1 change: 1 addition & 0 deletions src/CAREUI/interactive/SlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default function SlideOver({
>
<div className="flex items-center gap-2 p-2 pt-4">
<button
id="close-slide-over"
className="flex h-8 w-8 items-center justify-center rounded-lg text-2xl hover:bg-black/20"
onClick={() => {
setOpen(false);
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function AssetFilter(props: any) {
<div className="w-full flex-none">
<FieldLabel>Location</FieldLabel>
<LocationSelect
name="Facilities"
name="Facilities-location"
setSelected={(selectedId) =>
handleLocationSelect((selectedId as string) || "")
}
Expand Down

0 comments on commit f72a1cf

Please sign in to comment.