navigate(`/facility/${facilityId}/users`)}
icon={}
>
From 7f55921ae0d63f6aa4644fd06d586ee494fb8cd0 Mon Sep 17 00:00:00 2001
From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Date: Tue, 26 Sep 2023 14:46:22 +0530
Subject: [PATCH 2/2] Test for asset transaction and service history
---
cypress/e2e/assets_spec/assets_manage.cy.ts | 47 ++++++++++--
cypress/pageobject/Asset/AssetCreation.ts | 74 +++++++++++++++++++
.../pageobject/Facility/FacilityCreation.ts | 2 -
src/Components/Assets/AssetManage.tsx | 17 ++++-
.../Assets/AssetServiceEditModal.tsx | 15 +++-
.../Form/FormFields/Autocomplete.tsx | 2 +-
6 files changed, 143 insertions(+), 14 deletions(-)
diff --git a/cypress/e2e/assets_spec/assets_manage.cy.ts b/cypress/e2e/assets_spec/assets_manage.cy.ts
index 1f89facd0a3..4748de92beb 100644
--- a/cypress/e2e/assets_spec/assets_manage.cy.ts
+++ b/cypress/e2e/assets_spec/assets_manage.cy.ts
@@ -12,6 +12,9 @@ describe("Asset", () => {
const assetSearchPage = new AssetSearchPage();
const assetFilters = new AssetFilters();
const fillFacilityName = "Dummy Facility 1";
+ const assetname = "Dummy Camera";
+ const locationName = "Dummy Location 1";
+ const initiallocationName = "Camera Location";
before(() => {
loginPage.loginAsDisctrictAdmin();
@@ -23,11 +26,38 @@ describe("Asset", () => {
cy.awaitUrl("/assets");
});
- it("Delete an Asset", () => {
- assetPage.openCreatedAsset();
- assetPage.interceptDeleteAssetApi();
- assetPage.deleteAsset();
- assetPage.verifyDeleteStatus();
+ it("Create & Edit a service history and verify reflection", () => {
+ assetSearchPage.typeSearchKeyword(assetname);
+ assetSearchPage.pressEnter();
+ assetSearchPage.verifyBadgeContent(assetname);
+ assetSearchPage.clickAssetByName(assetname);
+ assetPage.clickupdatedetailbutton();
+ assetPage.scrollintonotes();
+ assetPage.enterAssetNotes("Dummy Notes");
+ assetPage.enterAssetservicedate("01092023");
+ assetPage.clickassetupdatebutton();
+ assetPage.scrollintoservicehistory();
+ assetPage.clickedithistorybutton();
+ assetPage.scrollintonotes();
+ assetPage.enterAssetNotes("Dummy Notes Editted");
+ assetPage.clickassetupdatebutton();
+ assetPage.scrollintoservicehistory();
+ assetPage.viewassetservicehistorybutton();
+ assetPage.openassetservicehistory();
+ assetPage.verifyassetupdateservicehistory();
+ assetPage.viewassetservicehistorybutton();
+ });
+
+ it("Create a asset transaction and verify history", () => {
+ assetSearchPage.typeSearchKeyword(assetname);
+ assetSearchPage.pressEnter();
+ assetSearchPage.verifyBadgeContent(assetname);
+ assetSearchPage.clickAssetByName(assetname);
+ assetPage.clickupdatedetailbutton();
+ assetPage.clickassetlocation(locationName);
+ assetPage.clickUpdateAsset();
+ assetPage.verifyassetlocation(locationName);
+ assetPage.verifytransactionStatus(initiallocationName, locationName);
});
it("Verify Facility Asset Page Redirection", () => {
@@ -47,6 +77,13 @@ describe("Asset", () => {
facilityPage.verifyassetfacilitybackredirection();
});
+ it("Delete an Asset", () => {
+ assetPage.openCreatedAsset();
+ assetPage.interceptDeleteAssetApi();
+ assetPage.deleteAsset();
+ assetPage.verifyDeleteStatus();
+ });
+
afterEach(() => {
cy.saveLocalStorage();
});
diff --git a/cypress/pageobject/Asset/AssetCreation.ts b/cypress/pageobject/Asset/AssetCreation.ts
index b939c31405f..45356a1a4e7 100644
--- a/cypress/pageobject/Asset/AssetCreation.ts
+++ b/cypress/pageobject/Asset/AssetCreation.ts
@@ -276,4 +276,78 @@ export class AssetPage {
cy.get("#submit").contains("Import").click();
cy.wait("@importAsset").its("response.statusCode").should("eq", 201);
}
+
+ clickupdatedetailbutton() {
+ cy.get("[data-testid=asset-update-button]").click();
+ }
+
+ scrollintonotes() {
+ cy.get("#notes").scrollIntoView();
+ }
+
+ enterAssetNotes(text) {
+ cy.get("#notes").click().clear();
+ cy.get("#notes").click().type(text);
+ }
+
+ enterAssetservicedate(text) {
+ cy.get("input[name='last_serviced_on']").click();
+ cy.get("#date-input").click().type(text);
+ }
+
+ clickassetupdatebutton() {
+ cy.get("#submit").click();
+ }
+
+ viewassetservicehistorybutton() {
+ cy.get("#view-service-history").should("be.visible");
+ }
+
+ openassetservicehistory() {
+ cy.get("#view-service-history").click();
+ cy.get("#view-asset-edit-history").first().click();
+ }
+
+ verifyassetupdateservicehistory() {
+ cy.get("#edit-history-asset-servicedon").should("have.text", "01/09/2023");
+ cy.get("#edit-history-asset-note").should(
+ "have.text",
+ "Dummy Notes Editted"
+ );
+ cy.get("#view-history-back-button").contains("Back").click();
+ cy.get("#view-history-back-button").contains("Close").click();
+ }
+
+ scrollintoservicehistory() {
+ cy.get("#service-history").scrollIntoView();
+ }
+
+ clickedithistorybutton() {
+ cy.get("#edit-service-history").click();
+ }
+
+ verifytransactionStatus(initiallocationName: string, locationName: string) {
+ cy.get("#transaction-history").scrollIntoView();
+ cy.get("#transaction-history table tbody tr:first-child td:eq(0)").should(
+ "contain",
+ initiallocationName
+ );
+ cy.get("#transaction-history table tbody tr:first-child td:eq(1)").should(
+ "contain",
+ locationName
+ );
+ }
+
+ verifyassetlocation(locationName: string) {
+ cy.get("#asset-current-location").should("contain", locationName);
+ }
+
+ clickassetlocation(locationName: string) {
+ cy.get("#clear-button").click();
+ cy.get("[data-testid=asset-location-input] button").click();
+ cy.get("[data-testid=asset-location-input] button")
+ .click()
+ .type(locationName);
+ cy.get("[role='option']").contains(locationName).click();
+ }
}
diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts
index 0c12d4655fd..b6285bff72b 100644
--- a/cypress/pageobject/Facility/FacilityCreation.ts
+++ b/cypress/pageobject/Facility/FacilityCreation.ts
@@ -205,9 +205,7 @@ class FacilityPage {
}
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() {
diff --git a/src/Components/Assets/AssetManage.tsx b/src/Components/Assets/AssetManage.tsx
index 1df9fbde9a6..a173289fc8a 100644
--- a/src/Components/Assets/AssetManage.tsx
+++ b/src/Components/Assets/AssetManage.tsx
@@ -231,6 +231,7 @@ const AssetManage = (props: AssetManageProps) => {
{
setServiceEditData({ ...service, open: true });
@@ -240,6 +241,7 @@ const AssetManage = (props: AssetManageProps) => {
{
{item.label}
-
@@ -514,7 +519,10 @@ const AssetManage = (props: AssetManageProps) => {
asset?.asset_class &&
asset?.asset_class != AssetClass.NONE && }
Service History
-
+
@@ -541,7 +549,10 @@ const AssetManage = (props: AssetManageProps) => {
Transaction History
-
+
diff --git a/src/Components/Assets/AssetServiceEditModal.tsx b/src/Components/Assets/AssetServiceEditModal.tsx
index 75c9dd9fc60..66d44d11907 100644
--- a/src/Components/Assets/AssetServiceEditModal.tsx
+++ b/src/Components/Assets/AssetServiceEditModal.tsx
@@ -97,7 +97,10 @@ export const AssetServiceEditModal = (props: {
{edit.edited_by.username}
-
@@ -124,19 +127,25 @@ export const AssetServiceEditModal = (props: {
Serviced On
-
+
{formatDate(editRecord.serviced_on)}
Notes
- {editRecord.note || "-"}
+
+ {editRecord.note || "-"}
+
)}
{
editRecord ? setEditRecord(undefined) : props.handleClose();
diff --git a/src/Components/Form/FormFields/Autocomplete.tsx b/src/Components/Form/FormFields/Autocomplete.tsx
index dcf3ab5e8b6..7a2c37351e4 100644
--- a/src/Components/Form/FormFields/Autocomplete.tsx
+++ b/src/Components/Form/FormFields/Autocomplete.tsx
@@ -164,7 +164,7 @@ export const Autocomplete = (props: AutocompleteProps) => {
{value?.icon}
{value && !props.isLoading && !props.required && (
- |