From c2b86039afe965e6993811a41c584b5cbba50839 Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Mon, 26 Jun 2023 20:28:53 +0530 Subject: [PATCH 1/2] Rename all instances of orgin_facility to origin_facility (#5498) Fixes coronasafe/care#1279 --- cypress/e2e/resource_spec/filter.cy.ts | 2 +- cypress/e2e/shifting_spec/filter.cy.ts | 4 ++-- src/Components/Patient/PatientHome.tsx | 2 +- src/Components/Patient/ShiftCreate.tsx | 2 +- src/Components/Resource/BadgesList.tsx | 8 +++---- src/Components/Resource/Commons.tsx | 4 ++-- src/Components/Resource/ListFilter.tsx | 24 +++++++++---------- src/Components/Resource/ListView.tsx | 4 ++-- src/Components/Resource/ResourceBoard.tsx | 4 ++-- src/Components/Resource/ResourceCreate.tsx | 2 +- src/Components/Resource/ResourceDetails.tsx | 12 +++++----- .../Resource/ResourceDetailsUpdate.tsx | 2 +- src/Components/Shifting/BadgesList.tsx | 8 +++---- src/Components/Shifting/Commons.tsx | 4 ++-- src/Components/Shifting/ListFilter.tsx | 24 +++++++++---------- src/Components/Shifting/ListView.tsx | 4 ++-- src/Components/Shifting/ShiftDetails.tsx | 8 +++---- .../Shifting/ShiftDetailsUpdate.tsx | 2 +- src/Components/Shifting/ShiftingBoard.tsx | 4 ++-- 19 files changed, 62 insertions(+), 62 deletions(-) diff --git a/cypress/e2e/resource_spec/filter.cy.ts b/cypress/e2e/resource_spec/filter.cy.ts index 1e19fb1dd5b..e4db00050e1 100644 --- a/cypress/e2e/resource_spec/filter.cy.ts +++ b/cypress/e2e/resource_spec/filter.cy.ts @@ -14,7 +14,7 @@ describe("Resource filter", () => { it("filter by origin facility", () => { cy.intercept(/\/api\/v1\/getallfacilities/).as("facilities_filter"); - cy.get("[name='orgin_facility']") + cy.get("[name='origin_facility']") .type("Dummy Facility 1") .wait("@facilities_filter"); cy.get("[role='option']").first().click(); diff --git a/cypress/e2e/shifting_spec/filter.cy.ts b/cypress/e2e/shifting_spec/filter.cy.ts index 996ddc600ea..f12aeec2760 100644 --- a/cypress/e2e/shifting_spec/filter.cy.ts +++ b/cypress/e2e/shifting_spec/filter.cy.ts @@ -14,11 +14,11 @@ describe("Shifting section filter", () => { it("filter by origin facility", () => { cy.intercept(/\/api\/v1\/getallfacilities/).as("facilities_filter"); - cy.get("[name='orgin_facility']") + cy.get("[name='origin_facility']") .wait(100) .type("Dummy") .wait("@facilities_filter"); - cy.get("[name='orgin_facility']").wait(100).type("{downarrow}{enter}"); + cy.get("[name='origin_facility']").wait(100).type("{downarrow}{enter}"); cy.contains("Apply").click(); }); diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index 15c4a7c52ac..373354ab648 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -868,7 +868,7 @@ export const PatientHome = (props: any) => { >
- {(shift.orgin_facility_object || {})?.name} + {(shift.origin_facility_object || {})?.name}
diff --git a/src/Components/Patient/ShiftCreate.tsx b/src/Components/Patient/ShiftCreate.tsx index e88f360ac7b..c8b802152fa 100644 --- a/src/Components/Patient/ShiftCreate.tsx +++ b/src/Components/Patient/ShiftCreate.tsx @@ -201,7 +201,7 @@ export const ShiftCreate = (props: patientShiftProps) => { const data = { status: wartime_shifting ? "PENDING" : "APPROVED", - orgin_facility: props.facilityId, + origin_facility: props.facilityId, shifting_approving_facility: ( state.form.shifting_approving_facility || {} ).id, diff --git a/src/Components/Resource/BadgesList.tsx b/src/Components/Resource/BadgesList.tsx index f5aeccb064c..217322c746d 100644 --- a/src/Components/Resource/BadgesList.tsx +++ b/src/Components/Resource/BadgesList.tsx @@ -12,14 +12,14 @@ export default function BadgesList(props: any) { useEffect(() => { async function fetchData() { - if (!appliedFilters.orgin_facility) return setOrginFacilityName(""); + if (!appliedFilters.origin_facility) return setOrginFacilityName(""); const res = await dispatch( - getAnyFacility(appliedFilters.orgin_facility, "orgin_facility") + getAnyFacility(appliedFilters.origin_facility, "origin_facility") ); setOrginFacilityName(res?.data?.name); } fetchData(); - }, [dispatch, appliedFilters.orgin_facility]); + }, [dispatch, appliedFilters.origin_facility]); useEffect(() => { async function fetchData() { @@ -69,7 +69,7 @@ export default function BadgesList(props: any) { }), ...dateRange("Modified", "modified_date"), ...dateRange("Created", "created_date"), - value("Origin facility", "orgin_facility", orginFacilityName), + value("Origin facility", "origin_facility", orginFacilityName), value( "Approving facility", "approving_facility", diff --git a/src/Components/Resource/Commons.tsx b/src/Components/Resource/Commons.tsx index 1a10156a8d0..0162f34d02c 100644 --- a/src/Components/Resource/Commons.tsx +++ b/src/Components/Resource/Commons.tsx @@ -1,7 +1,7 @@ export const initialFilterData = { status: "--", facility: "", - orgin_facility: "", + origin_facility: "", approving_facility: "", assigned_facility: "", emergency: "--", @@ -19,7 +19,7 @@ export const formatFilter = (params: any) => { return { status: filter.status === "--" ? null : filter.status, facility: "", - orgin_facility: filter.orgin_facility || undefined, + origin_facility: filter.origin_facility || undefined, approving_facility: filter.approving_facility || undefined, assigned_facility: filter.assigned_facility || undefined, emergency: diff --git a/src/Components/Resource/ListFilter.tsx b/src/Components/Resource/ListFilter.tsx index 06a7139f8b1..f57dd4b0f41 100644 --- a/src/Components/Resource/ListFilter.tsx +++ b/src/Components/Resource/ListFilter.tsx @@ -16,8 +16,8 @@ import { DateRange } from "../Common/DateRangeInputV2"; import DateRangeFormField from "../Form/FormFields/DateRangeFormField"; const clearFilterState = { - orgin_facility: "", - orgin_facility_ref: "", + origin_facility: "", + origin_facility_ref: "", approving_facility: "", approving_facility_ref: "", assigned_facility: "", @@ -40,8 +40,8 @@ export default function ListFilter(props: any) { const [isResourceLoading, setResourceLoading] = useState(false); const [isAssignedLoading, setAssignedLoading] = useState(false); const [filterState, setFilterState] = useMergeState({ - orgin_facility: filter.orgin_facility || "", - orgin_facility_ref: null, + origin_facility: filter.origin_facility || "", + origin_facility_ref: null, approving_facility: filter.approving_facility || "", approving_facility_ref: null, assigned_facility: filter.assigned_facility || "", @@ -58,13 +58,13 @@ export default function ListFilter(props: any) { useEffect(() => { async function fetchData() { - if (filter.orgin_facility) { + if (filter.origin_facility) { setOriginLoading(true); const res = await dispatch( - getAnyFacility(filter.orgin_facility, "orgin_facility") + getAnyFacility(filter.origin_facility, "origin_facility") ); if (res && res.data) { - setFilterState({ orgin_facility_ref: res.data }); + setFilterState({ origin_facility_ref: res.data }); } setOriginLoading(false); } @@ -118,7 +118,7 @@ export default function ListFilter(props: any) { const applyFilter = () => { const { - orgin_facility, + origin_facility, approving_facility, assigned_facility, emergency, @@ -130,7 +130,7 @@ export default function ListFilter(props: any) { status, } = filterState; const data = { - orgin_facility: orgin_facility || "", + origin_facility: origin_facility || "", approving_facility: approving_facility || "", assigned_facility: assigned_facility || "", emergency: emergency || "", @@ -194,9 +194,9 @@ export default function ListFilter(props: any) { ) : ( setFacility(obj, "orgin_facility")} + name="origin_facility" + selected={filterState.origin_facility_ref} + setSelected={(obj) => setFacility(obj, "origin_facility")} className="resource-page-filter-dropdown" errors={""} /> diff --git a/src/Components/Resource/ListView.tsx b/src/Components/Resource/ListView.tsx index 15c5bd4baba..ea82a6e2ee7 100644 --- a/src/Components/Resource/ListView.tsx +++ b/src/Components/Resource/ListView.tsx @@ -62,7 +62,7 @@ export default function ListView() { }, [ qParams.status, qParams.facility, - qParams.orgin_facility, + qParams.origin_facility, qParams.approving_facility, qParams.assigned_facility, qParams.emergency, @@ -122,7 +122,7 @@ export default function ListView() { >
- {(resource.orgin_facility_object || {}).name} + {(resource.origin_facility_object || {}).name}
diff --git a/src/Components/Resource/ResourceBoard.tsx b/src/Components/Resource/ResourceBoard.tsx index 3f42e82e2e0..afe076ab37f 100644 --- a/src/Components/Resource/ResourceBoard.tsx +++ b/src/Components/Resource/ResourceBoard.tsx @@ -70,7 +70,7 @@ const ResourceCard = ({ resource }: any) => { >
- {(resource.orgin_facility_object || {}).name} + {(resource.origin_facility_object || {}).name}
@@ -194,7 +194,7 @@ export default function ResourceBoard({ board, dispatch, filterProp.facility, - filterProp.orgin_facility, + filterProp.origin_facility, filterProp.approving_facility, filterProp.assigned_facility, filterProp.emergency, diff --git a/src/Components/Resource/ResourceCreate.tsx b/src/Components/Resource/ResourceCreate.tsx index 6bed5cacee1..e906c4a30df 100644 --- a/src/Components/Resource/ResourceCreate.tsx +++ b/src/Components/Resource/ResourceCreate.tsx @@ -186,7 +186,7 @@ export default function ResourceCreate(props: resourceProps) { status: "PENDING", category: state.form.category, sub_category: state.form.sub_category, - orgin_facility: props.facilityId, + origin_facility: props.facilityId, approving_facility: (state.form.approving_facility || {}).id, assigned_facility: (state.form.assigned_facility || {}).id, emergency: state.form.emergency === "true", diff --git a/src/Components/Resource/ResourceDetails.tsx b/src/Components/Resource/ResourceDetails.tsx index af51f1d0683..ccb1ae43dc6 100644 --- a/src/Components/Resource/ResourceDetails.tsx +++ b/src/Components/Resource/ResourceDetails.tsx @@ -118,18 +118,18 @@ export default function ResourceDetails(props: { id: string }) {
-
{data.orgin_facility_object?.name || "--"}
+
{data.origin_facility_object?.name || "--"}
- {data.orgin_facility_object?.facility_type?.name || "--"} + {data.origin_facility_object?.facility_type?.name || "--"}
- {data.orgin_facility_object?.district_object?.name || "--"} + {data.origin_facility_object?.district_object?.name || "--"}
- {data.orgin_facility_object?.local_body_object?.name || "--"} + {data.origin_facility_object?.local_body_object?.name || "--"}
- {data.orgin_facility_object?.state_object?.name || "--"} + {data.origin_facility_object?.state_object?.name || "--"}
{data.status === "REJECTED" || @@ -410,7 +410,7 @@ export default function ResourceDetails(props: { id: string }) {

Origin Facility

- {showFacilityCard(data.orgin_facility_object)} + {showFacilityCard(data.origin_facility_object)}

Resource Approving Facility

diff --git a/src/Components/Resource/ResourceDetailsUpdate.tsx b/src/Components/Resource/ResourceDetailsUpdate.tsx index ff1d0ff1338..cc07fa281b5 100644 --- a/src/Components/Resource/ResourceDetailsUpdate.tsx +++ b/src/Components/Resource/ResourceDetailsUpdate.tsx @@ -163,7 +163,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => { const data = { category: "OXYGEN", status: state.form.status, - orgin_facility: state.form.orgin_facility_object?.id, + origin_facility: state.form.origin_facility_object?.id, approving_facility: state.form?.approving_facility_object?.id, assigned_facility: state.form?.assigned_facility_object?.id, emergency: [true, "true"].includes(state.form.emergency), diff --git a/src/Components/Shifting/BadgesList.tsx b/src/Components/Shifting/BadgesList.tsx index ff6144776f2..eafe25405e9 100644 --- a/src/Components/Shifting/BadgesList.tsx +++ b/src/Components/Shifting/BadgesList.tsx @@ -31,14 +31,14 @@ export default function BadgesList(props: any) { useEffect(() => { async function fetchData() { - if (!qParams.orgin_facility) return setOriginFacilityName(""); + if (!qParams.origin_facility) return setOriginFacilityName(""); const res = await dispatch( - getAnyFacility(qParams.orgin_facility, "orgin_facility") + getAnyFacility(qParams.origin_facility, "origin_facility") ); setOriginFacilityName(res?.data?.name); } fetchData(); - }, [dispatch, qParams.orgin_facility]); + }, [dispatch, qParams.origin_facility]); useEffect(() => { async function fetchData() { @@ -102,7 +102,7 @@ export default function BadgesList(props: any) { "assigned_facility", assignedFacilityName ), - value(t("origin_facility"), "orgin_facility", originFacilityName), + value(t("origin_facility"), "origin_facility", originFacilityName), value( t("shifting_approval_facility"), "shifting_approving_facility", diff --git a/src/Components/Shifting/Commons.tsx b/src/Components/Shifting/Commons.tsx index 7de79b4baa5..db0e557f86c 100644 --- a/src/Components/Shifting/Commons.tsx +++ b/src/Components/Shifting/Commons.tsx @@ -3,7 +3,7 @@ export const limit = 14; export const initialFilterData = { status: "", facility: "", - orgin_facility: "", + origin_facility: "", shifting_approving_facility: "", assigned_facility: "", emergency: "", @@ -29,7 +29,7 @@ export const formatFilter = (params: any) => { return { status: filter.status === "" ? null : filter.status, facility: "", - orgin_facility: filter.orgin_facility || undefined, + origin_facility: filter.origin_facility || undefined, shifting_approving_facility: filter.shifting_approving_facility || undefined, assigned_facility: filter.assigned_facility || undefined, diff --git a/src/Components/Shifting/ListFilter.tsx b/src/Components/Shifting/ListFilter.tsx index 10bea4e68c3..e551c117db2 100644 --- a/src/Components/Shifting/ListFilter.tsx +++ b/src/Components/Shifting/ListFilter.tsx @@ -28,8 +28,8 @@ import { useTranslation } from "react-i18next"; import UserAutocompleteFormField from "../Common/UserAutocompleteFormField"; const clearFilterState = { - orgin_facility: "", - orgin_facility_ref: "", + origin_facility: "", + origin_facility_ref: "", shifting_approving_facility: "", shifting_approving_facility_ref: "", assigned_facility: "", @@ -67,8 +67,8 @@ export default function ListFilter(props: any) { ).map((option) => option.text); const [filterState, setFilterState] = useMergeState({ - orgin_facility: filter.orgin_facility || "", - orgin_facility_ref: null, + origin_facility: filter.origin_facility || "", + origin_facility_ref: null, shifting_approving_facility: filter.shifting_approving_facility || "", shifting_approving_facility_ref: null, assigned_facility: filter.assigned_facility || "", @@ -93,13 +93,13 @@ export default function ListFilter(props: any) { useEffect(() => { async function fetchData() { - if (filter.orgin_facility) { + if (filter.origin_facility) { setOriginLoading(true); const res = await dispatch( - getAnyFacility(filter.orgin_facility, "orgin_facility") + getAnyFacility(filter.origin_facility, "origin_facility") ); if (res && res.data) { - setFilterState({ orgin_facility_ref: res.data }); + setFilterState({ origin_facility_ref: res.data }); } setOriginLoading(false); } @@ -182,7 +182,7 @@ export default function ListFilter(props: any) { const applyFilter = () => { const { - orgin_facility, + origin_facility, shifting_approving_facility, assigned_facility, emergency, @@ -201,7 +201,7 @@ export default function ListFilter(props: any) { breathlessness_level, } = filterState; const data = { - orgin_facility: orgin_facility || "", + origin_facility: origin_facility || "", shifting_approving_facility: shifting_approving_facility || "", assigned_facility: assigned_facility || "", emergency: emergency || "", @@ -275,9 +275,9 @@ export default function ListFilter(props: any) { ) : ( setFacility(obj, "orgin_facility")} + name="origin_facility" + selected={filterState.origin_facility_ref} + setSelected={(obj) => setFacility(obj, "origin_facility")} className="shifting-page-filter-dropdown" errors={""} /> diff --git a/src/Components/Shifting/ListView.tsx b/src/Components/Shifting/ListView.tsx index a90f66b41c4..67e254c3d22 100644 --- a/src/Components/Shifting/ListView.tsx +++ b/src/Components/Shifting/ListView.tsx @@ -87,7 +87,7 @@ export default function ListView() { }, [ qParams.status, qParams.facility, - qParams.orgin_facility, + qParams.origin_facility, qParams.shifting_approving_facility, qParams.assigned_facility, qParams.emergency, @@ -170,7 +170,7 @@ export default function ListView() { >
- {(shift.orgin_facility_object || {}).name} + {(shift.origin_facility_object || {}).name}
diff --git a/src/Components/Shifting/ShiftDetails.tsx b/src/Components/Shifting/ShiftDetails.tsx index 8305f06b9a9..fac605f1155 100644 --- a/src/Components/Shifting/ShiftDetails.tsx +++ b/src/Components/Shifting/ShiftDetails.tsx @@ -120,7 +120,7 @@ export default function ShiftDetails(props: { id: string }) { "\n" + t("origin_facility") + ":" + - data?.orgin_facility_object?.name + + data?.origin_facility_object?.name + "\n" + t("contact_number") + ":" + @@ -352,7 +352,7 @@ export default function ShiftDetails(props: { id: string }) { {data.is_kasp ? t("district_program_management_supporting_unit") - : data.orgin_facility_object?.name || "--"} + : data.origin_facility_object?.name || "--"} {/* Made static based on #757 */}
@@ -618,7 +618,7 @@ export default function ShiftDetails(props: { id: string }) { {t("origin_facility")}:{" "} - {data.orgin_facility_object?.name || "--"} + {data.origin_facility_object?.name || "--"}
{wartime_shifting && (
@@ -856,7 +856,7 @@ export default function ShiftDetails(props: { id: string }) {

{t("details_of_origin_facility")}

- {showFacilityCard(data.orgin_facility_object)} + {showFacilityCard(data.origin_facility_object)}
{!data.assigned_facility_external && (
diff --git a/src/Components/Shifting/ShiftDetailsUpdate.tsx b/src/Components/Shifting/ShiftDetailsUpdate.tsx index 36c64efbd45..02fa1811f2d 100644 --- a/src/Components/Shifting/ShiftDetailsUpdate.tsx +++ b/src/Components/Shifting/ShiftDetailsUpdate.tsx @@ -197,7 +197,7 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { setIsLoading(true); const data: any = { - orgin_facility: state.form.orgin_facility_object?.id, + origin_facility: state.form.origin_facility_object?.id, shifting_approving_facility: state.form?.shifting_approving_facility_object?.id, assigned_facility: diff --git a/src/Components/Shifting/ShiftingBoard.tsx b/src/Components/Shifting/ShiftingBoard.tsx index cdd5b8dce65..403770f4c6a 100644 --- a/src/Components/Shifting/ShiftingBoard.tsx +++ b/src/Components/Shifting/ShiftingBoard.tsx @@ -109,7 +109,7 @@ const ShiftCard = ({ shift, filter }: any) => { >
- {(shift.orgin_facility_object || {}).name} + {(shift.origin_facility_object || {}).name}
@@ -288,7 +288,7 @@ export default function ShiftingBoard({ board, dispatch, filterProp.facility, - filterProp.orgin_facility, + filterProp.origin_facility, filterProp.shifting_approving_facility, filterProp.assigned_facility, filterProp.emergency, From a89bcaa382308bece2a86ae1e1d0d8c76e6292f0 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Tue, 27 Jun 2023 07:43:17 +0530 Subject: [PATCH 2/2] Asset Cypress : POM Approach (#5738) * First half of asset POM model * Asset Page 2/3 of POM Approach * Delete vite.config.ts * Asset Page 2/3 of POM Approach * Asset Cypress Modified into POM * Fix Random Error * facility fix * facility fix * failed test fix * failed test fix * fix to random failure * fix to facility failure --- cypress/e2e/assets_spec/asset_tab.cy.ts | 61 +++++++++++ cypress/e2e/assets_spec/assets.cy.ts | 100 ------------------ cypress/e2e/assets_spec/assets_manage.cy.ts | 57 ++++++++++ cypress/e2e/assets_spec/filter.cy.ts | 61 ----------- .../external_result.cy.ts | 10 +- .../e2e/external_results_spec/filter.cy.ts | 61 ++++------- cypress/e2e/facility_spec/facility.cy.ts | 30 +++--- cypress/e2e/patient_spec/patient_crud.cy.ts | 3 +- cypress/fixtures/external-result_sample.csv | 3 - cypress/fixtures/externalresultsample.csv | 2 + cypress/pageobject/Asset/AssetCreation.ts | 83 +++++++++++++++ cypress/pageobject/Asset/AssetFilters.ts | 32 ++++++ cypress/pageobject/Asset/AssetPagination.ts | 13 +++ cypress/pageobject/Asset/AssetQRScan.ts | 7 ++ cypress/pageobject/Asset/AssetSearch.ts | 15 +++ src/CAREUI/display/FilterBadge.tsx | 1 + .../FacilitiesSelectDialogue.tsx | 1 + 17 files changed, 315 insertions(+), 225 deletions(-) create mode 100644 cypress/e2e/assets_spec/asset_tab.cy.ts delete mode 100644 cypress/e2e/assets_spec/assets.cy.ts create mode 100644 cypress/e2e/assets_spec/assets_manage.cy.ts delete mode 100644 cypress/e2e/assets_spec/filter.cy.ts delete mode 100644 cypress/fixtures/external-result_sample.csv create mode 100644 cypress/fixtures/externalresultsample.csv create mode 100644 cypress/pageobject/Asset/AssetCreation.ts create mode 100644 cypress/pageobject/Asset/AssetFilters.ts create mode 100644 cypress/pageobject/Asset/AssetPagination.ts create mode 100644 cypress/pageobject/Asset/AssetQRScan.ts create mode 100644 cypress/pageobject/Asset/AssetSearch.ts diff --git a/cypress/e2e/assets_spec/asset_tab.cy.ts b/cypress/e2e/assets_spec/asset_tab.cy.ts new file mode 100644 index 00000000000..0abf11fcaf0 --- /dev/null +++ b/cypress/e2e/assets_spec/asset_tab.cy.ts @@ -0,0 +1,61 @@ +/// + +import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; +import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch"; +import { AssetQRScanPage } from "../../pageobject/Asset/AssetQRScan"; +import { AssetPagination } from "../../pageobject/Asset/AssetPagination"; +import { AssetFilters } from "../../pageobject/Asset/AssetFilters"; + +describe("Asset Tab", () => { + const assetSearchPage = new AssetSearchPage(); + const assetQRScanPage = new AssetQRScanPage(); + const assetPagination = new AssetPagination(); + const assetFilters = new AssetFilters(); + + before(() => { + cy.loginByApi("devdistrictadmin", "Coronasafe@123"); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.awaitUrl("/assets"); + }); + + // search for a element + + it("Search Asset Name", () => { + const initialUrl = cy.url(); + assetSearchPage.typeSearchKeyword("dummy camera 30"); + assetSearchPage.pressEnter(); + assetSearchPage.verifyUrlChanged(initialUrl); + }); + + // scan a asset qr code + + it("Scan Asset QR", () => { + assetQRScanPage.scanAssetQR(); + }); + + // filter the asset and verify the badges are there + + it("Filter Asset", () => { + assetFilters.filterAssets( + "Dummy Facility 1", + "INTERNAL", + "ACTIVE", + "ONVIF Camera" + ); + }); + + // Verify the pagination in the page + + it("Next/Previous Page", () => { + assetPagination.navigateToNextPage(); + assetPagination.navigateToPreviousPage(); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/e2e/assets_spec/assets.cy.ts b/cypress/e2e/assets_spec/assets.cy.ts deleted file mode 100644 index e49104b34dc..00000000000 --- a/cypress/e2e/assets_spec/assets.cy.ts +++ /dev/null @@ -1,100 +0,0 @@ -/// - -import { cy, describe, before, beforeEach, it } from "local-cypress"; -import { v4 as uuidv4 } from "uuid"; - -const phone_number = "9999999999"; -const serial_no = parseInt((Math.random() * 10 ** 10).toString()); - -describe("Asset", () => { - before(() => { - cy.loginByApi("devdistrictadmin", "Coronasafe@123"); - cy.saveLocalStorage(); - }); - - beforeEach(() => { - cy.restoreLocalStorage(); - cy.awaitUrl("/assets"); - }); - - it("Create an Asset", () => { - cy.get("button").should("contain", "Create Asset"); - cy.get("[data-testid=create-asset-buttom] button").click(); - cy.get("input[name='facilities']") - .type("Dummy Facility 1") - .then(() => { - cy.get("[role='option']").contains("Dummy Facility 1").click(); - }); - cy.get("button").should("contain", "Select"); - cy.get("button").get("#submit").click(); - cy.get("[data-testid=asset-name-input] input").type("New Test Asset"); - cy.get("[data-testid=asset-location-input] input") - .type("Camera Locat") - .then(() => { - cy.get("[role='option']").contains("Camera Locations").click(); - }); - cy.get("[data-testid=asset-type-input] button") - .click() - .then(() => { - cy.get("[role='option']").contains("Internal").click(); - }); - cy.get("[data-testid=asset-class-input] button") - .click() - .then(() => { - cy.get("[role='option']").contains("ONVIF Camera").click(); - }); - cy.get("[data-testid=asset-description-input] textarea").type( - "Test Description" - ); - cy.get("[data-testid=asset-working-status-input] li") - .contains("Working") - .click(); - const qr_id = uuidv4(); - cy.get("[data-testid=asset-qr-id-input] input").type(qr_id); - cy.get("[data-testid=asset-manufacturer-input] input").type( - "Manufacturer's Name" - ); - cy.get("[data-testid=asset-warranty-input] input").type("2025-12-25"); - cy.get("[data-testid=asset-support-name-input] input").type( - "Customer Support's Name" - ); - cy.get("#customer-support-phone-div").type(phone_number); - cy.get("[data-testid=asset-support-email-input] input").type( - "email@support.com" - ); - cy.get("[data-testid=asset-vendor-name-input] input").type("Vendor's Name"); - cy.get("[data-testid=asset-serial-number-input] input").type(serial_no); - cy.get("[data-testid=asset-last-serviced-on-input] input").type( - "2021-12-25" - ); - cy.get("[data-testid=asset-notes-input] textarea").type( - "Test note for asset creation!" - ); - cy.wait(500); - cy.get("#submit").contains("Create Asset").click(); - cy.verifyNotification("Asset created successfully"); - }); - - it("Search Asset Name", () => { - const initialUrl = cy.url(); - cy.get("[name='search']").type("dummy camera 30"); - cy.get("[name='search']").type("{enter}"); - cy.url().should((currentUrl) => { - expect(currentUrl).not.to.equal(initialUrl); - }); - }); - - it("Scan Asset QR", () => { - cy.contains("Scan Asset QR").click().wait(1000); - cy.get("video").should("exist"); - cy.get("button").contains("Close Scanner").should("exist").click(); - }); - - it("Next/Previous Page", () => { - // only works for desktop mode - cy.get("button#next-pages").click(); - cy.url().should("include", "page=2"); - cy.get("button#prev-pages").click(); - cy.url().should("include", "page=1"); - }); -}); diff --git a/cypress/e2e/assets_spec/assets_manage.cy.ts b/cypress/e2e/assets_spec/assets_manage.cy.ts new file mode 100644 index 00000000000..464617b3303 --- /dev/null +++ b/cypress/e2e/assets_spec/assets_manage.cy.ts @@ -0,0 +1,57 @@ +/// +import { AssetPage } from "../../pageobject/Asset/AssetCreation"; +import { v4 as uuidv4 } from "uuid"; + +describe("Asset", () => { + const assetPage = new AssetPage(); + const phone_number = "9999999999"; + const serialNumber = Math.floor(Math.random() * 10 ** 10).toString(); + + before(() => { + cy.loginByApi("devdistrictadmin", "Coronasafe@123"); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.awaitUrl("/assets"); + }); + + //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 = uuidv4(); + + assetPage.enterAssetDetails( + "New Test Asset", + "Test Description", + "Working", + qr_id, + "Manufacturer's Name", + "2025-12-25", + "Customer Support's Name", + phone_number, + "email@support.com", + "Vendor's Name", + serialNumber, + "2021-12-25", + "Test note for asset creation!" + ); + + assetPage.clickCreateAsset(); + + assetPage.verifySuccessNotification("Asset created successfully"); + }); + + // Edit an exisit asset + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/e2e/assets_spec/filter.cy.ts b/cypress/e2e/assets_spec/filter.cy.ts deleted file mode 100644 index 6d723936c78..00000000000 --- a/cypress/e2e/assets_spec/filter.cy.ts +++ /dev/null @@ -1,61 +0,0 @@ -/// - -import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; - -describe("Assets Filter", () => { - before(() => { - cy.loginByApi("devdistrictadmin", "Coronasafe@123"); - cy.saveLocalStorage(); - }); - - beforeEach(() => { - cy.restoreLocalStorage(); - cy.awaitUrl("/assets"); - cy.contains("Advanced Filters").click(); - }); - - it("Filter by Facility", () => { - cy.get("[name=Facilities]").type("dummy"); - cy.intercept(/\/api\/v1\/getallfacilities/).as("facilities"); - cy.wait("@facilities").then((interception) => { - console.log("url", interception.response.url); - expect(interception.response.statusCode).to.equal(200); - expect(interception.request.url).to.include("search_text=dummy"); - }); - cy.contains("Apply").click(); - cy.contains("Facility:"); - }); - - it("Filter by Asset Type", () => { - cy.get("[id='asset-type'] > div > button") - .click() - .get("li") - .contains("EXTERNAL") - .click(); - cy.contains("Apply").click(); - cy.contains("Asset Type: EXTERNAL"); - }); - - it("Filter by Asset Status", () => { - cy.get("[id='asset-status'] > div > button") - .click() - .get("li") - .contains("ACTIVE") - .click(); - cy.contains("Apply").click(); - cy.contains("Status: ACTIVE"); - }); - - it("Filter by Asset Class", () => { - cy.get("[id='asset-class'] > div > button") - .click() - .get("li") - .contains("ONVIF Camera") - .click(); - cy.contains("Apply").click(); - cy.contains("Asset Class: ONVIF"); - }); - afterEach(() => { - cy.saveLocalStorage(); - }); -}); diff --git a/cypress/e2e/external_results_spec/external_result.cy.ts b/cypress/e2e/external_results_spec/external_result.cy.ts index 22d46060049..3148d5fc204 100644 --- a/cypress/e2e/external_results_spec/external_result.cy.ts +++ b/cypress/e2e/external_results_spec/external_result.cy.ts @@ -34,17 +34,17 @@ describe("Edit Profile Testing", () => { cy.wait("@external_result").then((interception) => { expect(interception.response.statusCode).to.equal(200); }); - cy.url().should("include", "%2B91+73874+34255"); + cy.url().should("include", "%2B917387434255"); }); it("import", () => { cy.intercept("POST", "/api/v1/external_result/bulk_upsert").as("import"); - cy.get("div").contains("Import/Export").click({ force: true }); - cy.get("div").contains("Import Results").click({ force: true }); + cy.get("div").contains("Import/Export").click(); + cy.get("div").contains("Import Results").click(); cy.get("[id=result-upload]") - .selectFile("cypress/fixtures/external-result_sample.csv") + .selectFile("cypress/fixtures/externalresultsample.csv") .wait(100); - cy.get("button").contains("Save").click({ force: true }); + cy.get("button").contains("Save").click(); cy.wait("@import").then((interception) => { expect(interception.response.statusCode).to.equal(202); }); diff --git a/cypress/e2e/external_results_spec/filter.cy.ts b/cypress/e2e/external_results_spec/filter.cy.ts index 43bd6c9adf7..8654bb49e63 100644 --- a/cypress/e2e/external_results_spec/filter.cy.ts +++ b/cypress/e2e/external_results_spec/filter.cy.ts @@ -12,50 +12,31 @@ describe("External Results Filters", () => { cy.contains("Filters").click(); }); - it("filter by lsg", () => { - cy.get("[placeholder='Select Local Body']") - .type("ernakulam") - .type("{downarrow}{enter}"); + it("Advance Filter", () => { + cy.get("#local_bodies").click(); + cy.get("[role='option']").should("be.visible"); + cy.contains("[role='option']", "Aluva").click(); + cy.get("#local_bodies").click(); + cy.get("#wards").click(); + cy.get("[role='option']").should("be.visible"); + cy.contains("[role='option']", "12").click(); cy.contains("Apply").click(); - cy.contains("LSG:"); }); - it("filter by ward", () => { - cy.get("[placeholder='Select wards']") - .type("ernakulam") - .type("{downarrow}{enter}"); + it("filter by date", () => { + cy.get("input[name='created_date_start']").click(); + cy.get("[id^='headlessui-popover-panel-'] .care-l-angle-left-b").click(); + cy.get("div[id='date-1']").click(); + cy.get("div[id='date-8']").click(); + cy.get("input[name='result_date_start']").click(); + cy.get("[id^='headlessui-popover-panel-'] .care-l-angle-left-b").click(); + cy.get("div[id='date-1']").click(); + cy.get("div[id='date-8']").click(); + cy.get("input[name='sample_collection_date_start']").click(); + cy.get("[id^='headlessui-popover-panel-'] .care-l-angle-left-b").click(); + cy.get("div[id='date-1']").click(); + cy.get("div[id='date-8']").click(); cy.contains("Apply").click(); - cy.contains("Ward:"); - }); - - it("filter by created date", () => { - cy.get("[name='created_date_after']").type("2020-12-06"); - cy.get("[name='created_date_before']").type("2020-12-31"); - cy.contains("Apply").click(); - cy.contains("Created after: 2020-12-06"); - cy.contains("Created before: 2020-12-31"); - }); - - it("filter by result date", () => { - cy.get("[name='result_date_after']").type("2021-03-02"); - cy.get("[name='result_date_before']").type("2021-04-02"); - cy.contains("Apply").click(); - cy.contains("Result after: 2021-03-02"); - cy.contains("Result before: 2021-04-02"); - }); - - it("filter by sample collection date", () => { - cy.get("[name='sample_collection_date_after']").type("2021-01-04"); - cy.get("[name='sample_collection_date_before']").type("2021-03-03"); - cy.contains("Apply").click(); - cy.contains("Sample created after: 2021-01-04"); - cy.contains("Sample created before: 2021-03-03"); - }); - - it("filter by srf id", () => { - cy.get("[name='srf_id']").type("432"); - cy.contains("Apply").click(); - cy.contains("SRF ID: 432"); }); afterEach(() => { diff --git a/cypress/e2e/facility_spec/facility.cy.ts b/cypress/e2e/facility_spec/facility.cy.ts index b03c17245b4..112c167bc23 100644 --- a/cypress/e2e/facility_spec/facility.cy.ts +++ b/cypress/e2e/facility_spec/facility.cy.ts @@ -50,31 +50,31 @@ class facility { cy.get("[id=facility_type] > div > button").click(); cy.get("div").contains(type).click(); + cy.get("input[id=pincode]").should("exist").clear().type(pincode); cy.get("input[id=name]").should("exist").type(name); + cy.get("[id=state] > div > button").click(); + cy.get("div").contains(state).click(); + cy.get("[id=features] > div > div > button").click(); cy.get("li").contains(features[0]).click(); cy.get("li").contains(features[1]).click(); cy.get("body").click(); - cy.get("[id=state] > div > button").click(); - cy.get("div").contains(state).click(); - cy.get("[id=district] > div > button").click(); cy.get("div").contains(district).click(); + cy.get("textarea[id=address]").should("exist").type(address); + cy.get("[id=local_body] > div > button").click(); cy.get("div").contains(localbody).click(); + cy.get("input[name=phone_number]").clear(); + cy.get("input[name=phone_number]").type(phone); + cy.get("[id=ward] > div > button").click(); cy.get("div").contains(ward).click(); - cy.get("textarea[id=address]").should("exist").type(address); - - cy.get("input[id=pincode]").should("exist").clear().type(pincode); - - cy.get("input[name=phone_number]").should("exist").clear().type(phone); - cy.get("input[id=oxygen_capacity]").clear().type(oxygen_capacity); cy.get("input[id=expected_oxygen_requirement]") .should("exist") @@ -132,12 +132,12 @@ describe("Facility", () => { type: "Private Hospital", name: "cypress facility", features: ["CT Scan", "X-Ray"], + pincode: "682001", state: "Kerala", district: "Ernakulam", - localbody: "Alangad", - ward: "MANAKKAPADY", + localbody: "Aikaranad", + ward: "EZHIPRAM", address: "some address", - pincode: "884656", phone: "+919985784535", oxygen_capacity: "20", oxygen_requirement: "30", @@ -179,12 +179,12 @@ describe("Facility", () => { type: "TeleMedicine", name: " update", features: ["X-Ray", "Neonatal Care"], + pincode: "682003", state: "Kerala", district: "Ernakulam", - localbody: "Aikaranad", - ward: "PAZHAMTHOTTAM", + localbody: "Alangad", + ward: "VELIYATHUNADU", address: " update", - pincode: "584675", phone: "+919985784535", oxygen_capacity: "30", oxygen_requirement: "40", diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index c2ce7497154..2f82db9b5bb 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -95,7 +95,8 @@ describe("Patient Creation with consultation", () => { it("Edit the patient details", () => { cy.awaitUrl(patient_url + "/update"); - cy.get("[data-testid=name] input").clear().type("Test E2E User Edited"); + cy.get("[data-testid=name] input").clear(); + cy.get("[data-testid=name] input").type("Test E2E User Edited"); cy.get("#emergency_phone_number-div") .clear() .then(() => { diff --git a/cypress/fixtures/external-result_sample.csv b/cypress/fixtures/external-result_sample.csv deleted file mode 100644 index b22a56848b2..00000000000 --- a/cypress/fixtures/external-result_sample.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,age,age_in,result,srf_id,gender,address,district,local_body,local_body_type,ward,mobile_number,is_repeat,patient_status,sample_type,test_type,sample_collection_date,result_date,lab_name,source,patient_category -1,Test 1,38,years,Negative,165/EKM/202010122,F,"CSN HQ -Kochi, Kerala",Ernakulam,Karukutty,Grama Panchayath,7,9207054148,NO,Symptomatic,Nasopharyngeal swab/Nasal swab/Oropharyngeal swab/Throat swab/Sputum/BAL/ETA/ Nasopharyngeal Orophar,4,2020-10-14,2020-10-10,Gh Muvattupuzha,,Cat 17: All individuals who wish to get themselves tested diff --git a/cypress/fixtures/externalresultsample.csv b/cypress/fixtures/externalresultsample.csv new file mode 100644 index 00000000000..d1e543200b2 --- /dev/null +++ b/cypress/fixtures/externalresultsample.csv @@ -0,0 +1,2 @@ +District,srf id,name,age,age in,gender,mobile number,address,ward,local body,local body type,source,Sample Collection Date,result date,test type,lab name,sample type,patient status,Is Repeat,patient category,result +Ernakulam,00/EKM/0000,Test Upload,24,years,m,8888888888,Upload test address,7,Poothrikka,grama panchayath,Secondary contact aparna,2020-10-14,2020-10-14,Antigen,Karothukuzhi Laboratory,Ag-SD_Biosensor_Standard_Q_COVID-19_Ag_detection_kit,Asymptomatic,NO,Cat 17: All individuals who wish to get themselves tested,Negative diff --git a/cypress/pageobject/Asset/AssetCreation.ts b/cypress/pageobject/Asset/AssetCreation.ts new file mode 100644 index 00000000000..2ccd3e0c367 --- /dev/null +++ b/cypress/pageobject/Asset/AssetCreation.ts @@ -0,0 +1,83 @@ +// assetPage.ts + +export class AssetPage { + createAsset() { + cy.get("button").should("contain", "Create Asset"); + cy.get("[data-testid=create-asset-buttom] button").click(); + } + + selectFacility(facilityName: string) { + cy.get("input[name='facilities']") + .type(facilityName) + .then(() => { + cy.get("[role='option']").contains(facilityName).click(); + }); + cy.get("[data-testid='submit-button']").click(); + } + + selectLocation(locationName: string) { + cy.get("[data-testid=asset-location-input] input") + .type(locationName) + .then(() => { + cy.get("[role='option']").contains(locationName).click(); + }); + } + + selectAssetType(assetType: string) { + cy.get("[data-testid=asset-type-input] button") + .click() + .then(() => { + cy.get("[role='option']").contains(assetType).click(); + }); + } + + selectAssetClass(assetClass: string) { + cy.get("[data-testid=asset-class-input] button") + .click() + .then(() => { + cy.get("[role='option']").contains(assetClass).click(); + }); + } + + enterAssetDetails( + name: string, + description: string, + workingStatus: string, + qrId: string, + manufacturer: string, + warranty: string, + supportName: string, + supportPhone: string, + supportEmail: string, + vendorName: string, + serialNumber: string, + lastServicedOn: string, + notes: string + ) { + cy.get("[data-testid=asset-name-input] input").type(name); + cy.get("[data-testid=asset-description-input] textarea").type(description); + cy.get("[data-testid=asset-working-status-input] li") + .contains(workingStatus) + .click(); + cy.get("[data-testid=asset-qr-id-input] input").type(qrId); + cy.get("[data-testid=asset-manufacturer-input] input").type(manufacturer); + cy.get("[data-testid=asset-warranty-input] input").type(warranty); + cy.get("[data-testid=asset-support-name-input] input").type(supportName); + cy.get("#customer-support-phone-div").type(supportPhone); + cy.get("[data-testid=asset-support-email-input] input").type(supportEmail); + cy.get("[data-testid=asset-vendor-name-input] input").type(vendorName); + cy.get("[data-testid=asset-serial-number-input] input").type(serialNumber); + cy.get("[data-testid=asset-last-serviced-on-input] input").type( + lastServicedOn + ); + cy.get("[data-testid=asset-notes-input] textarea").type(notes); + } + + clickCreateAsset() { + cy.get("#submit").contains("Create Asset").click(); + } + + verifySuccessNotification(message: string) { + cy.verifyNotification(message); + } +} diff --git a/cypress/pageobject/Asset/AssetFilters.ts b/cypress/pageobject/Asset/AssetFilters.ts new file mode 100644 index 00000000000..57cc893bdb7 --- /dev/null +++ b/cypress/pageobject/Asset/AssetFilters.ts @@ -0,0 +1,32 @@ +export class AssetFilters { + filterAssets( + facilityName: string, + assetType: string, + assetStatus: string, + assetClass: string + ) { + cy.contains("Advanced Filters").click(); + cy.get("input[name='Facilities']") + .click() + .type(facilityName) + .then(() => { + cy.get("[role='option']").contains(facilityName).click(); + }); + cy.get("#asset-type") + .click() + .then(() => { + cy.get("[role='option']").contains(assetType).click(); + }); + cy.get("#asset-status") + .click() + .then(() => { + cy.get("[role='option']").contains(assetStatus).click(); + }); + cy.get("#asset-class") + .click() + .then(() => { + cy.get("[role='option']").contains(assetClass).click(); + }); + cy.contains("Apply").click(); + } +} diff --git a/cypress/pageobject/Asset/AssetPagination.ts b/cypress/pageobject/Asset/AssetPagination.ts new file mode 100644 index 00000000000..3fff457d8cf --- /dev/null +++ b/cypress/pageobject/Asset/AssetPagination.ts @@ -0,0 +1,13 @@ +export class AssetPagination { + navigateToNextPage() { + // only works for desktop mode + cy.get("button#next-pages").click(); + cy.url().should("include", "page=2"); + } + + navigateToPreviousPage() { + // only works for desktop mode + cy.get("button#prev-pages").click(); + cy.url().should("include", "page=1"); + } +} diff --git a/cypress/pageobject/Asset/AssetQRScan.ts b/cypress/pageobject/Asset/AssetQRScan.ts new file mode 100644 index 00000000000..a88f378f02f --- /dev/null +++ b/cypress/pageobject/Asset/AssetQRScan.ts @@ -0,0 +1,7 @@ +export class AssetQRScanPage { + scanAssetQR() { + cy.contains("Scan Asset QR").click().wait(1000); + cy.get("video").should("exist"); + cy.get("button").contains("Close Scanner").should("exist").click(); + } +} diff --git a/cypress/pageobject/Asset/AssetSearch.ts b/cypress/pageobject/Asset/AssetSearch.ts new file mode 100644 index 00000000000..26b9a81c140 --- /dev/null +++ b/cypress/pageobject/Asset/AssetSearch.ts @@ -0,0 +1,15 @@ +export class AssetSearchPage { + typeSearchKeyword(keyword: string) { + cy.get("[name='search']").type(keyword); + } + + pressEnter() { + cy.get("[name='search']").type("{enter}"); + } + + verifyUrlChanged(initialUrl: string) { + cy.url().should((currentUrl) => { + expect(currentUrl).not.to.equal(initialUrl); + }); + } +} diff --git a/src/CAREUI/display/FilterBadge.tsx b/src/CAREUI/display/FilterBadge.tsx index 10154126db9..28a7fe90f23 100644 --- a/src/CAREUI/display/FilterBadge.tsx +++ b/src/CAREUI/display/FilterBadge.tsx @@ -11,6 +11,7 @@ export interface FilterBadgeProps { const FilterBadge = ({ name, value, onRemove }: FilterBadgeProps) => { return ( { onClick={handleOk} disabled={!selectedFacility.id} label={t("select")} + data-testid="submit-button" />