From 5e08bd47cca9f44923ab621dbcc2c5eddd1163ea Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 22 Jan 2024 13:45:30 +0530 Subject: [PATCH 01/29] Hide nav menu item "Dashboard" if not configured in config (#7072) * Hide dashboard nav menu item if not configured * remove `dashboard_url` from config --- public/config.json | 3 +-- src/Common/hooks/useConfig.ts | 2 +- src/Components/Common/Sidebar/Sidebar.tsx | 16 +++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/public/config.json b/public/config.json index 74e509fee59..9398e28c410 100644 --- a/public/config.json +++ b/public/config.json @@ -1,5 +1,4 @@ { - "dashboard_url": "https://dashboard.coronasafe.in", "github_url": "https://github.com/coronasafe", "coronasafe_url": "https://coronasafe.network?ref=care", "site_url": "care.coronasafe.in", @@ -23,4 +22,4 @@ "sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx", "sample_format_external_result_import": "/External-Results-Template.csv", "enable_abdm": true -} \ No newline at end of file +} diff --git a/src/Common/hooks/useConfig.ts b/src/Common/hooks/useConfig.ts index 15e456ea571..79addd71c8b 100644 --- a/src/Common/hooks/useConfig.ts +++ b/src/Common/hooks/useConfig.ts @@ -8,7 +8,7 @@ interface ILogo { } export interface IConfig { - dashboard_url: string; + dashboard_url?: string; github_url: string; coronasafe_url: string; site_url: string; diff --git a/src/Components/Common/Sidebar/Sidebar.tsx b/src/Components/Common/Sidebar/Sidebar.tsx index 9d378df4267..af450d9583d 100644 --- a/src/Components/Common/Sidebar/Sidebar.tsx +++ b/src/Components/Common/Sidebar/Sidebar.tsx @@ -147,13 +147,15 @@ const StatelessSidebar = ({ handleOverflow={handleOverflow} onClickCB={() => onItemClick && onItemClick(false)} /> - } - external - handleOverflow={handleOverflow} - /> + {dashboard_url && ( + } + external + handleOverflow={handleOverflow} + /> + )}
From 446256d39d6d76ffdfda9787a1496560a180c8eb Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:45:09 +0530 Subject: [PATCH 02/29] modified FLAKY TEST (#7074) --- cypress/e2e/assets_spec/asset_homepage.cy.ts | 6 +++--- cypress/e2e/assets_spec/assets_creation.cy.ts | 6 +++--- cypress/e2e/assets_spec/assets_manage.cy.ts | 2 +- .../e2e/facility_spec/facility_creation.cy.ts | 2 +- .../e2e/facility_spec/facility_homepage.cy.ts | 2 +- cypress/e2e/facility_spec/locations.cy.ts | 17 ++++++++++++++++- cypress/e2e/patient_spec/patient_crud.cy.ts | 2 +- cypress/e2e/resource_spec/filter.cy.ts | 2 +- cypress/e2e/resource_spec/resources.cy.ts | 2 +- cypress/e2e/users_spec/user_creation.cy.ts | 2 +- cypress/e2e/users_spec/user_manage.cy.ts | 2 +- cypress/e2e/users_spec/user_profile.cy.ts | 2 +- cypress/pageobject/Facility/FacilityCreation.ts | 2 +- cypress/pageobject/Facility/FacilityLocation.ts | 4 ++++ 14 files changed, 36 insertions(+), 17 deletions(-) diff --git a/cypress/e2e/assets_spec/asset_homepage.cy.ts b/cypress/e2e/assets_spec/asset_homepage.cy.ts index a2c1c7734d2..388f19424a4 100644 --- a/cypress/e2e/assets_spec/asset_homepage.cy.ts +++ b/cypress/e2e/assets_spec/asset_homepage.cy.ts @@ -62,7 +62,7 @@ describe("Asset Tab", () => { it("Filter Asset", () => { assetFilters.filterAssets( - "Dummy Facility 1", + "Dummy Facility 40", "INTERNAL", "ACTIVE", "ONVIF Camera", @@ -70,7 +70,7 @@ describe("Asset Tab", () => { ); assetFilters.clickadvancefilter(); assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters - assetFilters.assertFacilityText("Dummy Facility 1"); + assetFilters.assertFacilityText("Dummy Facility 40"); assetFilters.assertAssetTypeText("INTERNAL"); assetFilters.assertAssetClassText("ONVIF"); assetFilters.assertStatusText("ACTIVE"); @@ -89,7 +89,7 @@ describe("Asset Tab", () => { it("Import new asset", () => { assetPage.selectassetimportbutton(); assetPage.selectImportOption(); - assetPage.selectImportFacility("Dummy Facility 1"); + assetPage.selectImportFacility("Dummy Facility 40"); assetPage.importAssetFile(); assetPage.selectImportLocation("Camera Loc"); assetPage.clickImportAsset(); diff --git a/cypress/e2e/assets_spec/assets_creation.cy.ts b/cypress/e2e/assets_spec/assets_creation.cy.ts index dde4e0d0e8b..63f8bee50c8 100644 --- a/cypress/e2e/assets_spec/assets_creation.cy.ts +++ b/cypress/e2e/assets_spec/assets_creation.cy.ts @@ -25,7 +25,7 @@ describe("Asset", () => { it("Verify asset creation fields throws error if empty", () => { assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); + assetPage.selectFacility("Dummy Facility 40"); assetPage.clickCreateAsset(); assetPage.verifyEmptyAssetNameError(); @@ -39,7 +39,7 @@ describe("Asset", () => { it("Create an Asset", () => { assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); + assetPage.selectFacility("Dummy Facility 40"); assetPage.selectLocation("Camera Loc"); assetPage.selectAssetType("Internal"); assetPage.selectAssetClass("ONVIF Camera"); @@ -139,7 +139,7 @@ describe("Asset", () => { it("Add an vital monitor asset and configure it", () => { assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); + assetPage.selectFacility("Dummy Facility 40"); assetPage.selectLocation("Camera Loc"); assetPage.selectAssetType("Internal"); assetPage.selectAssetClass("HL7 Vitals Monitor"); diff --git a/cypress/e2e/assets_spec/assets_manage.cy.ts b/cypress/e2e/assets_spec/assets_manage.cy.ts index 92a4f5be9b8..3a47ebec8df 100644 --- a/cypress/e2e/assets_spec/assets_manage.cy.ts +++ b/cypress/e2e/assets_spec/assets_manage.cy.ts @@ -17,7 +17,7 @@ describe("Asset", () => { const facilityPage = new FacilityPage(); const assetSearchPage = new AssetSearchPage(); const assetFilters = new AssetFilters(); - const fillFacilityName = "Dummy Facility 1"; + const fillFacilityName = "Dummy Facility 40"; const assetname = "Dummy Camera"; const locationName = "Dummy Location 1"; const initiallocationName = "Camera Location"; diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index ab9d72f430f..ea27938c7e9 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -30,7 +30,7 @@ describe("Facility Creation", () => { const doctorCapacity = "5"; const totalDoctor = "10"; const facilityName = "cypress facility"; - const facilityName2 = "Dummy Facility 1"; + const facilityName2 = "Dummy Facility 40"; const facilityAddress = "cypress address"; const facilityUpdateAddress = "cypress updated address"; const facilityNumber = "9898469865"; diff --git a/cypress/e2e/facility_spec/facility_homepage.cy.ts b/cypress/e2e/facility_spec/facility_homepage.cy.ts index 5d1cef4efcf..2ed666ac842 100644 --- a/cypress/e2e/facility_spec/facility_homepage.cy.ts +++ b/cypress/e2e/facility_spec/facility_homepage.cy.ts @@ -18,7 +18,7 @@ describe("Facility Homepage Function", () => { const capacitiesAlias = "downloadCapacitiesCSV"; const doctorsAlias = "downloadDoctorsCSV"; const triagesAlias = "downloadTriagesCSV"; - const facilityName = "Dummy Facility 1"; + const facilityName = "Dummy Facility 40"; const facilityLocaion = "Dummy Location"; const stateName = "Kerala"; const district = "Ernakulam"; diff --git a/cypress/e2e/facility_spec/locations.cy.ts b/cypress/e2e/facility_spec/locations.cy.ts index 1f2726c79ab..62905b87744 100644 --- a/cypress/e2e/facility_spec/locations.cy.ts +++ b/cypress/e2e/facility_spec/locations.cy.ts @@ -57,7 +57,20 @@ describe("Location Management Section", () => { it("Add a Bed to facility location along with duplication and deleting a bed", () => { // mandatory field verification in bed creation - facilityLocation.clickManageBedButton(); + cy.get("body").then(($body) => { + if ($body.find("#manage-bed-button:visible").length) { + // If the '#manage-bed-button' is visible + facilityLocation.clickManageBedButton(); + } else { + // If the '#manage-bed-button' is not visible + facilityLocation.clickAddNewLocationButton(); + facilityPage.fillFacilityName(locationName); + facilityLocation.selectLocationType(locationType); + assetPage.clickassetupdatebutton(); + facilityLocation.clickNotification(); + facilityLocation.clickManageBedButton(); + } + }); facilityLocation.clickAddBedButton(); assetPage.clickassetupdatebutton(); userCreationPage.verifyErrorMessages(EXPECTED_BED_ERROR_MESSAGES); @@ -102,6 +115,7 @@ describe("Location Management Section", () => { facilityLocation.selectLocationType(locationType); facilityLocation.fillMiddlewareAddress(locationMiddleware); assetPage.clickassetupdatebutton(); + facilityLocation.clickNotification(); // verify the reflection facilityLocation.verifyLocationName(locationName); facilityLocation.verifyLocationType(locationType); @@ -130,6 +144,7 @@ describe("Location Management Section", () => { facilityLocation.selectBedType(bedType); facilityLocation.setMultipleBeds(numberOfBeds); assetPage.clickassetupdatebutton(); + facilityLocation.clickNotification(); // verify the bed creation facilityLocation.verifyBedBadge(bedType); facilityLocation.verifyBedBadge(bedStatus); diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index 66c8b35e236..38eec604758 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -35,7 +35,7 @@ describe("Patient Creation with consultation", () => { it("Create a new patient with no consultation", () => { patientPage.createPatient(); - patientPage.selectFacility("dummy facility"); + patientPage.selectFacility("dummy facility 40"); patientPage.patientformvisibility(); patientPage.enterPatientDetails( phone_number, diff --git a/cypress/e2e/resource_spec/filter.cy.ts b/cypress/e2e/resource_spec/filter.cy.ts index c457f867ed4..d9f5f50c16f 100644 --- a/cypress/e2e/resource_spec/filter.cy.ts +++ b/cypress/e2e/resource_spec/filter.cy.ts @@ -16,7 +16,7 @@ describe("Resource filter", () => { cy.intercept(/\/api\/v1\/getallfacilities/).as("facilities_filter"); cy.contains("Filters").click(); cy.get("[name='origin_facility']") - .type("Dummy Facility 1") + .type("Dummy Facility 40") .wait("@facilities_filter"); cy.get("[role='option']").first().click(); cy.contains("Apply").click(); diff --git a/cypress/e2e/resource_spec/resources.cy.ts b/cypress/e2e/resource_spec/resources.cy.ts index a774023059f..7077f4082a2 100644 --- a/cypress/e2e/resource_spec/resources.cy.ts +++ b/cypress/e2e/resource_spec/resources.cy.ts @@ -41,7 +41,7 @@ describe("Resource Page", () => { it("Create a resource request", () => { cy.visit("/facility"); - cy.get("#search").click().type("dummy facility 1"); + cy.get("#search").click().type("dummy facility 40"); cy.intercept("GET", "**/api/v1/facility/**").as("loadFacilities"); cy.get("#facility-details").click(); cy.wait("@loadFacilities").its("response.statusCode").should("eq", 200); diff --git a/cypress/e2e/users_spec/user_creation.cy.ts b/cypress/e2e/users_spec/user_creation.cy.ts index 55d4b3bef1a..72d2e7f15f4 100644 --- a/cypress/e2e/users_spec/user_creation.cy.ts +++ b/cypress/e2e/users_spec/user_creation.cy.ts @@ -15,7 +15,7 @@ describe("User Creation", () => { const userCreationPage = new UserCreationPage(); const facilityPage = new FacilityPage(); const assetSearchPage = new AssetSearchPage(); - const fillFacilityName = "Dummy Facility 1"; + const fillFacilityName = "Dummy Facility 40"; const makeid = (length: number) => { let result = ""; const characters = "abcdefghijklmnopqrstuvwxyz0123456789"; diff --git a/cypress/e2e/users_spec/user_manage.cy.ts b/cypress/e2e/users_spec/user_manage.cy.ts index 35818751526..05e84715be1 100644 --- a/cypress/e2e/users_spec/user_manage.cy.ts +++ b/cypress/e2e/users_spec/user_manage.cy.ts @@ -16,7 +16,7 @@ describe("Manage User", () => { const usernameforworkinghour = "devdistrictadmin"; const usernamerealname = "Dummy Doctor"; const facilitytolinkusername = "Dummy Shifting Center"; - const facilitytolinkskill = "Dummy Facility 1"; + const facilitytolinkskill = "Dummy Facility 40"; const workinghour = "23"; const linkedskill = "General Medicine"; diff --git a/cypress/e2e/users_spec/user_profile.cy.ts b/cypress/e2e/users_spec/user_profile.cy.ts index b6fe64b2455..3f3202eb423 100644 --- a/cypress/e2e/users_spec/user_profile.cy.ts +++ b/cypress/e2e/users_spec/user_profile.cy.ts @@ -17,7 +17,7 @@ describe("Manage User Profile", () => { const doctorYoE = "10"; const medicalCouncilRegistration = "1234567890"; - const facilitySearch = "Dummy Facility 1"; + const facilitySearch = "Dummy Facility 40"; before(() => { loginPage.loginAsDevDoctor(); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index e6569799eaa..6be99cf5758 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -26,7 +26,7 @@ class FacilityPage { } fillFacilityName(name: string) { - cy.get("#name").clear().type(name); + cy.get("#name").click().clear().click().type(name); } fillPincode(pincode: string) { diff --git a/cypress/pageobject/Facility/FacilityLocation.ts b/cypress/pageobject/Facility/FacilityLocation.ts index f836b0773f6..b332d06ebf0 100644 --- a/cypress/pageobject/Facility/FacilityLocation.ts +++ b/cypress/pageobject/Facility/FacilityLocation.ts @@ -56,6 +56,10 @@ class FacilityLocation { cy.get("#add-new-bed").click(); } + clickNotification() { + cy.get(".pnotify").click(); + } + enterBedName(name: string) { cy.get("#bed-name").click().clear().click().type(name); } From 8025200aada55fda1d66ff49576bfa9c7b76e5f0 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 22 Jan 2024 20:43:11 +0530 Subject: [PATCH 03/29] Fixed the edge case in cypress flaky test (#7076) * modified FLAKY TEST * modified FLAKY TEST --- cypress/e2e/facility_spec/locations.cy.ts | 5 +++-- cypress/pageobject/Asset/AssetFilters.ts | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/facility_spec/locations.cy.ts b/cypress/e2e/facility_spec/locations.cy.ts index 62905b87744..97727e05ca0 100644 --- a/cypress/e2e/facility_spec/locations.cy.ts +++ b/cypress/e2e/facility_spec/locations.cy.ts @@ -23,6 +23,7 @@ describe("Location Management Section", () => { "Please select a bed type", ]; const locationName = "Test-location"; + const locationNameTwo = "Test-location-2"; const locationDescription = "Test Description"; const locationType = "WARD"; const locationMiddleware = "dev_middleware.coronasafe.live"; @@ -110,14 +111,14 @@ describe("Location Management Section", () => { assetPage.clickassetupdatebutton(); userCreationPage.verifyErrorMessages(EXPECTED_LOCATION_ERROR_MESSAGES); // create a new location - facilityPage.fillFacilityName(locationName); + facilityPage.fillFacilityName(locationNameTwo); facilityLocation.fillDescription(locationDescription); facilityLocation.selectLocationType(locationType); facilityLocation.fillMiddlewareAddress(locationMiddleware); assetPage.clickassetupdatebutton(); facilityLocation.clickNotification(); // verify the reflection - facilityLocation.verifyLocationName(locationName); + facilityLocation.verifyLocationName(locationNameTwo); facilityLocation.verifyLocationType(locationType); facilityLocation.verifyLocationDescription(locationDescription); facilityLocation.verifyLocationMiddleware(locationMiddleware); diff --git a/cypress/pageobject/Asset/AssetFilters.ts b/cypress/pageobject/Asset/AssetFilters.ts index 9a8d9781786..5ded59f4f63 100644 --- a/cypress/pageobject/Asset/AssetFilters.ts +++ b/cypress/pageobject/Asset/AssetFilters.ts @@ -56,9 +56,7 @@ export class AssetFilters { }); } 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(); From 619cff77235e7fbbda31e516cade4e260fcce5fe Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Tue, 23 Jan 2024 21:00:29 +0530 Subject: [PATCH 04/29] Add CSP headers (#7083) * reduce external links * add csp headers * ignore csp in cypress * avoid waiting for fontawesome in cypress * Revert "ignore csp in cypress" This reverts commit fe54552f86b1779b49945fde7dd5af7bb4af5b15. --- .env | 2 + cypress/support/commands.ts | 2 - index.html | 22 ++-- netlify.toml | 9 ++ package-lock.json | 230 ++++------------------------------ package.json | 2 + src/Components/Auth/Login.tsx | 2 +- src/style/CAREUI.css | 3 - src/style/index.css | 17 ++- vite.config.ts | 17 +++ 10 files changed, 81 insertions(+), 225 deletions(-) diff --git a/.env b/.env index 38fd950b0d8..da48755037b 100644 --- a/.env +++ b/.env @@ -8,3 +8,5 @@ REACT_PUBLIC_URL=https://care.coronasafe.in # Dev envs ESLINT_NO_DEV_ERRORS=true + +CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3-patient-data-10bedicu.s3.amazonaws.com http://localhost:4566" diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 0c491814102..0314f65feee 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -69,10 +69,8 @@ Cypress.Commands.add("loginByApi", (username, password) => { Cypress.Commands.add( "awaitUrl", (url: string, disableLoginVerification = false) => { - cy.intercept(/fontawesome/).as("fontawesome"); cy.intercept(/currentuser/).as("currentuser"); cy.visit(url); - cy.wait("@fontawesome"); disableLoginVerification ? cy.wait("@currentuser") : cy.wait("@currentuser").its("response.statusCode").should("eq", 200); diff --git a/index.html b/index.html index 83c80ef3214..e366febadbb 100644 --- a/index.html +++ b/index.html @@ -24,18 +24,12 @@ - - -
- -
+
- -