diff --git a/cypress/e2e/assets_spec/asset_homepage.cy.ts b/cypress/e2e/assets_spec/asset_homepage.cy.ts index fa24adf5b21..7b002a7c9bd 100644 --- a/cypress/e2e/assets_spec/asset_homepage.cy.ts +++ b/cypress/e2e/assets_spec/asset_homepage.cy.ts @@ -5,6 +5,7 @@ import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch"; import { AssetQRScanPage } from "../../pageobject/Asset/AssetQRScan"; import { AssetPagination } from "../../pageobject/Asset/AssetPagination"; import { AssetFilters } from "../../pageobject/Asset/AssetFilters"; +import { AssetPage } from "../../pageobject/Asset/AssetCreation"; import LoginPage from "../../pageobject/Login/LoginPage"; import { v4 as uuidv4 } from "uuid"; @@ -13,6 +14,7 @@ describe("Asset Tab", () => { const assetQRScanPage = new AssetQRScanPage(); const assetPagination = new AssetPagination(); const assetFilters = new AssetFilters(); + const assetPage = new AssetPage(); const loginPage = new LoginPage(); const assetName = "Dummy Camera 10"; const qrCode = uuidv4(); @@ -83,6 +85,28 @@ describe("Asset Tab", () => { assetPagination.navigateToPreviousPage(); }); + it("Import new asset", () => { + assetPage.selectassetimportbutton(); + assetPage.selectImportOption(); + assetPage.selectImportFacility("Dummy Facility 1"); + assetPage.importAssetFile(); + assetPage.selectImportLocation("Camera Locations"); + assetPage.clickImportAsset(); + assetPage.verifySuccessNotification("Assets imported successfully"); + }); + + it("verify imported asset", () => { + assetSearchPage.typeSearchKeyword("New Test Asset"); + assetSearchPage.pressEnter(); + assetSearchPage.verifyAssetIsPresent("New Test Asset"); + }); + + it("Export asset", () => { + assetPage.selectassetimportbutton(); + assetPage.selectjsonexportbutton(); + assetPage.selectcsvexportbutton(); + }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/assets_spec/assets_creation.cy.ts b/cypress/e2e/assets_spec/assets_creation.cy.ts new file mode 100644 index 00000000000..3e7b24eeca6 --- /dev/null +++ b/cypress/e2e/assets_spec/assets_creation.cy.ts @@ -0,0 +1,178 @@ +/// +import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; +import { AssetPage } from "../../pageobject/Asset/AssetCreation"; +import { v4 as uuidv4 } from "uuid"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch"; + +describe("Asset", () => { + const assetPage = new AssetPage(); + const assetSearchPage = new AssetSearchPage(); + const loginPage = new LoginPage(); + const phone_number = "9999999999"; + const serialNumber = Math.floor(Math.random() * 10 ** 10).toString(); + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.awaitUrl("/assets"); + }); + + it("Verify asset creation fields throws error if empty", () => { + assetPage.createAsset(); + assetPage.selectFacility("Dummy Facility 1"); + assetPage.clickCreateAsset(); + + assetPage.verifyEmptyAssetNameError(); + assetPage.verifyEmptyAssetTypeError(); + assetPage.verifyEmptyLocationError(); + assetPage.verifyEmptyStatusError(); + assetPage.verifyEmptyPhoneError(); + }); + + //Create an asset + + it("Create an Asset", () => { + assetPage.createAsset(); + assetPage.selectFacility("Dummy Facility 1"); + assetPage.selectLocation("Camera Loc"); + assetPage.selectAssetType("Internal"); + assetPage.selectAssetClass("ONVIF Camera"); + + const qr_id_1 = uuidv4(); + + assetPage.enterAssetDetails( + "New Test Asset 1", + "Test Description", + "Working", + qr_id_1, + "Manufacturer's Name", + "2025-12-25", + "Customer Support's Name", + phone_number, + "email@support.com", + "Vendor's Name", + serialNumber, + "25122021", + "Test note for asset creation!" + ); + + assetPage.clickCreateAddMore(); + assetPage.verifySuccessNotification("Asset created successfully"); + + const qr_id_2 = uuidv4(); + + assetPage.selectLocation("Camera Loc"); + assetPage.selectAssetType("Internal"); + assetPage.selectAssetClass("ONVIF Camera"); + assetPage.enterAssetDetails( + "New Test Asset 2", + "Test Description", + "Working", + qr_id_2, + "Manufacturer's Name", + "2025-12-25", + "Customer Support's Name", + phone_number, + "email@support.com", + "Vendor's Name", + serialNumber, + "25122021", + "Test note for asset creation!" + ); + + assetPage.interceptAssetCreation(); + assetPage.clickCreateAsset(); + assetPage.verifyAssetCreation(); + assetPage.verifySuccessNotification("Asset created successfully"); + + assetSearchPage.typeSearchKeyword("New Test Asset 2"); + assetSearchPage.pressEnter(); + assetSearchPage.verifyAssetIsPresent("New Test Asset 2"); + }); + + it("Edit an Asset", () => { + assetPage.openCreatedAsset(); + + const qr_id = uuidv4(); + + assetPage.editAssetDetails( + "New Test Asset Edited", + "Test Description Edited", + qr_id, + "Manufacturer's Name Edited", + "Customer Support's Name Edited", + "Vendor's Name Edited", + "Test note for asset creation edited!", + "25122021" + ); + + assetPage.clickUpdateAsset(); + + assetPage.verifySuccessNotification("Asset updated successfully"); + }); + + it("Verify Editted Asset", () => { + assetSearchPage.typeSearchKeyword("New Test Asset Edited"); + assetSearchPage.pressEnter(); + assetSearchPage.verifyAssetIsPresent("New Test Asset Edited"); + }); + + it("Configure an asset", () => { + assetPage.openCreatedAsset(); + assetPage.spyAssetConfigureApi(); + assetPage.configureAsset( + "Host name", + "192.168.1.64", + "remote_user", + "2jCkrCRSeahzKEU", + "d5694af2-21e2-4a39-9bad-2fb98d9818bd" + ); + assetPage.clickConfigureAsset(); + assetPage.verifyAssetConfiguration(200); + }); + + it("Add an vital monitor asset and configure it", () => { + assetPage.createAsset(); + assetPage.selectFacility("Dummy Facility 1"); + assetPage.selectLocation("Camera Loc"); + assetPage.selectAssetType("Internal"); + assetPage.selectAssetClass("HL7 Vitals Monitor"); + + const qr_id_1 = uuidv4(); + + assetPage.enterAssetDetails( + "New Test Asset Vital", + "Test Description", + "Working", + qr_id_1, + "Manufacturer's Name", + "2025-12-25", + "Customer Support's Name", + phone_number, + "email@support.com", + "Vendor's Name", + serialNumber, + "25122021", + "Test note for asset creation!" + ); + assetPage.interceptAssetCreation(); + assetPage.clickCreateAsset(); + assetPage.verifyAssetCreation(); + + assetSearchPage.typeSearchKeyword("New Test Asset Vital"); + assetSearchPage.pressEnter(); + + assetPage.openCreatedAsset(); + assetPage.configureVitalAsset("Host name", "192.168.1.64"); + assetPage.clickConfigureVital(); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/e2e/assets_spec/assets_manage.cy.ts b/cypress/e2e/assets_spec/assets_manage.cy.ts index af3efb917dd..f27fd302a0c 100644 --- a/cypress/e2e/assets_spec/assets_manage.cy.ts +++ b/cypress/e2e/assets_spec/assets_manage.cy.ts @@ -1,16 +1,10 @@ -/// import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; import { AssetPage } from "../../pageobject/Asset/AssetCreation"; -import { v4 as uuidv4 } from "uuid"; import LoginPage from "../../pageobject/Login/LoginPage"; -import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch"; describe("Asset", () => { const assetPage = new AssetPage(); - const assetSearchPage = new AssetSearchPage(); const loginPage = new LoginPage(); - const phone_number = "9999999999"; - const serialNumber = Math.floor(Math.random() * 10 ** 10).toString(); before(() => { loginPage.loginAsDisctrictAdmin(); @@ -22,150 +16,6 @@ describe("Asset", () => { cy.awaitUrl("/assets"); }); - it("Verify asset creation fields throws error if empty", () => { - assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); - assetPage.clickCreateAsset(); - - assetPage.verifyEmptyAssetNameError(); - assetPage.verifyEmptyAssetTypeError(); - assetPage.verifyEmptyLocationError(); - assetPage.verifyEmptyStatusError(); - assetPage.verifyEmptyPhoneError(); - }); - - //Create an asset - - it("Create an Asset", () => { - assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); - assetPage.selectLocation("Camera Loc"); - assetPage.selectAssetType("Internal"); - assetPage.selectAssetClass("ONVIF Camera"); - - const qr_id_1 = uuidv4(); - - assetPage.enterAssetDetails( - "New Test Asset 1", - "Test Description", - "Working", - qr_id_1, - "Manufacturer's Name", - "2025-12-25", - "Customer Support's Name", - phone_number, - "email@support.com", - "Vendor's Name", - serialNumber, - "25122021", - "Test note for asset creation!" - ); - - assetPage.clickCreateAddMore(); - assetPage.verifySuccessNotification("Asset created successfully"); - - const qr_id_2 = uuidv4(); - - assetPage.selectLocation("Camera Loc"); - assetPage.selectAssetType("Internal"); - assetPage.selectAssetClass("ONVIF Camera"); - assetPage.enterAssetDetails( - "New Test Asset 2", - "Test Description", - "Working", - qr_id_2, - "Manufacturer's Name", - "2025-12-25", - "Customer Support's Name", - phone_number, - "email@support.com", - "Vendor's Name", - serialNumber, - "25122021", - "Test note for asset creation!" - ); - - assetPage.interceptAssetCreation(); - assetPage.clickCreateAsset(); - assetPage.verifyAssetCreation(); - assetPage.verifySuccessNotification("Asset created successfully"); - - assetSearchPage.typeSearchKeyword("New Test Asset 2"); - assetSearchPage.pressEnter(); - assetSearchPage.verifyAssetIsPresent("New Test Asset 2"); - }); - - it("Edit an Asset", () => { - assetPage.openCreatedAsset(); - - const qr_id = uuidv4(); - - assetPage.editAssetDetails( - "New Test Asset Edited", - "Test Description Edited", - qr_id, - "Manufacturer's Name Edited", - "Customer Support's Name Edited", - "Vendor's Name Edited", - "Test note for asset creation edited!", - "25122021" - ); - - assetPage.clickUpdateAsset(); - - assetPage.verifySuccessNotification("Asset updated successfully"); - }); - - it("Configure an asset", () => { - assetPage.openCreatedAsset(); - assetPage.spyAssetConfigureApi(); - assetPage.configureAsset( - "Host name", - "192.168.1.64", - "remote_user", - "2jCkrCRSeahzKEU", - "d5694af2-21e2-4a39-9bad-2fb98d9818bd" - ); - assetPage.clickConfigureAsset(); - assetPage.verifyAssetConfiguration(200); - }); - - it("Add an vital monitor asset and configure it", () => { - assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); - assetPage.selectLocation("Camera Loc"); - assetPage.selectAssetType("Internal"); - assetPage.selectAssetClass("HL7 Vitals Monitor"); - - const qr_id_1 = uuidv4(); - - assetPage.enterAssetDetails( - "New Test Asset Vital", - "Test Description", - "Working", - qr_id_1, - "Manufacturer's Name", - "2025-12-25", - "Customer Support's Name", - phone_number, - "email@support.com", - "Vendor's Name", - serialNumber, - "25122021", - "Test note for asset creation!" - ); - assetPage.interceptAssetCreation(); - assetPage.clickCreateAsset(); - assetPage.verifyAssetCreation(); - - assetSearchPage.typeSearchKeyword("New Test Asset Vital"); - assetSearchPage.pressEnter(); - - assetPage.openCreatedAsset(); - assetPage.configureVitalAsset("Host name", "192.168.1.64"); - assetPage.clickConfigureVital(); - }); - it("Delete an Asset", () => { assetPage.openCreatedAsset(); assetPage.interceptDeleteAssetApi(); @@ -173,16 +23,6 @@ describe("Asset", () => { assetPage.verifyDeleteStatus(); }); - it("Import new asset", () => { - assetPage.selectImportOption(); - assetPage.selectImportFacility("Dummy Facility 1"); - assetPage.importAssetFile(); - assetPage.selectImportLocation("Camera Locations"); - assetPage.clickImportAsset(); - - assetPage.verifySuccessNotification("Assets imported successfully"); - }); - afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/pageobject/Asset/AssetCreation.ts b/cypress/pageobject/Asset/AssetCreation.ts index fdaf802d4b7..b939c31405f 100644 --- a/cypress/pageobject/Asset/AssetCreation.ts +++ b/cypress/pageobject/Asset/AssetCreation.ts @@ -234,8 +234,29 @@ export class AssetPage { }); } - selectImportOption() { + selectassetimportbutton() { cy.get("[data-testid=import-asset-button]").click(); + } + + selectjsonexportbutton() { + cy.intercept("GET", "**/api/v1/asset/?json=true**").as("getJsonexport"); + cy.get("#export-json-option").click(); + cy.wait("@getJsonexport").then(({ request, response }) => { + expect(response.statusCode).to.eq(200); + expect(request.url).to.include("json=true"); + }); + } + + selectcsvexportbutton() { + cy.intercept("GET", "**/api/v1/asset/?csv=true**").as("getCsvexport"); + cy.get("#export-csv-option").click(); + cy.wait("@getCsvexport").then(({ request, response }) => { + expect(response.statusCode).to.eq(200); + expect(request.url).to.include("csv=true"); + }); + } + + selectImportOption() { cy.get(".import-assets-button").click(); } diff --git a/src/Components/Assets/AssetManage.tsx b/src/Components/Assets/AssetManage.tsx index 25f879ddd09..1df9fbde9a6 100644 --- a/src/Components/Assets/AssetManage.tsx +++ b/src/Components/Assets/AssetManage.tsx @@ -360,6 +360,7 @@ const AssetManage = (props: AssetManageProps) => { {asset?.name} { options: { icon: , disabled: totalCount === 0 || !authorizedForImportExport, + id: "export-json-option", }, }, { @@ -353,6 +354,7 @@ const AssetsList = () => { options: { icon: , disabled: totalCount === 0 || !authorizedForImportExport, + id: "export-csv-option", }, }, ]}