From 5eb31eb5e28d286751f5ec2e8bd71342388480ee Mon Sep 17 00:00:00 2001 From: Alok Date: Tue, 19 Nov 2024 12:26:24 +0530 Subject: [PATCH 1/3] Tests to verify error handling and access restrictions during Facility Creation (#9119) --- .../e2e/facility_spec/FacilityCreation.cy.ts | 33 +++++++++++++++++++ .../pageobject/Facility/FacilityCreation.ts | 4 +++ 2 files changed, 37 insertions(+) diff --git a/cypress/e2e/facility_spec/FacilityCreation.cy.ts b/cypress/e2e/facility_spec/FacilityCreation.cy.ts index 5e644238999..5fd988480fc 100644 --- a/cypress/e2e/facility_spec/FacilityCreation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityCreation.cy.ts @@ -317,6 +317,39 @@ describe("Facility Creation", () => { ); }); + it("Should display error when district admin tries to create facility in a different district", () => { + facilityPage.visitCreateFacilityPage(); + facilityPage.fillFacilityName(facilityName); + facilityPage.selectFacilityType(facilityType); + facilityPage.fillPincode("682001"); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Kottayam"); + facilityPage.selectLocalBody("Arpookara"); + facilityPage.selectWard("5"); + facilityPage.fillAddress(facilityAddress); + facilityPage.fillPhoneNumber(facilityNumber); + facilityPage.submitForm(); + facilityPage.verifyErrorNotification( + "You do not have permission to perform this action.", + ); + }); + + it("Access Restriction for Non-Admin Users to facility creation page", () => { + const nonAdminLoginMethods = [ + loginPage.loginAsDevDoctor.bind(loginPage), + loginPage.loginAsStaff.bind(loginPage), + ]; + + nonAdminLoginMethods.forEach((loginMethod) => { + loginMethod(); + cy.visit("/facility/create"); + facilityPage.verifyErrorNotification( + "You don't have permission to perform this action. Contact the admin", + ); + cy.clearCookies(); + }); + }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 908431e3a65..0fddc3f9799 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -302,6 +302,10 @@ class FacilityPage { cy.verifyNotification(message); } + verifyErrorNotification(message: string) { + cy.verifyNotification(message); + } + visitAlreadyCreatedFacility() { cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities"); cy.get("[id='facility-details']").first().click(); From e0264d06edf473638b60f6f102a21896ec0bad4b Mon Sep 17 00:00:00 2001 From: Kamishetty Rishith <119791436+Rishith25@users.noreply.github.com> Date: Tue, 19 Nov 2024 12:26:52 +0530 Subject: [PATCH 2/3] Login page input fields UI update (#9125) --- src/CAREUI/interactive/LegendInput.tsx | 2 +- src/components/Auth/Login.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CAREUI/interactive/LegendInput.tsx b/src/CAREUI/interactive/LegendInput.tsx index cb415d76ab1..064eb2ceb0f 100644 --- a/src/CAREUI/interactive/LegendInput.tsx +++ b/src/CAREUI/interactive/LegendInput.tsx @@ -130,7 +130,7 @@ export default function LegendInput(props: InputProps) { required={props.required} autoComplete={props.autoComplete} className={classNames( - "cui-input w-full rounded-md border-secondary-300 bg-secondary-50 shadow-sm focus:border-2 focus:border-primary-500 focus:bg-secondary-100 focus:outline-none focus:ring-0", + "cui-input w-full rounded-md border-2 border-secondary-300 border-transparent bg-secondary-50 shadow-sm focus:border-2 focus:border-primary-500 focus:bg-secondary-100 focus:outline-none focus:ring-0", props.size === "small" && "px-3 py-2 text-xs", (!props.size || !["small", "large"].includes(props.size)) && "px-4 py-3", diff --git a/src/components/Auth/Login.tsx b/src/components/Auth/Login.tsx index aab5f8df179..4255161194a 100644 --- a/src/components/Auth/Login.tsx +++ b/src/components/Auth/Login.tsx @@ -350,7 +350,7 @@ const Login = (props: { forgot?: boolean }) => { From 570ed1ea258c8f121e7b30b88109aa6a246a0067 Mon Sep 17 00:00:00 2001 From: Aditya Jindal Date: Tue, 19 Nov 2024 12:27:18 +0530 Subject: [PATCH 3/3] Fix: Bed capacity pop up errors (#9123) --- src/components/Facility/BedCapacity.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/Facility/BedCapacity.tsx b/src/components/Facility/BedCapacity.tsx index 0bb405670fd..156dc6adce6 100644 --- a/src/components/Facility/BedCapacity.tsx +++ b/src/components/Facility/BedCapacity.tsx @@ -77,6 +77,8 @@ export const BedCapacity = (props: BedCapacityProps) => { const existingData = capacityQuery.data?.results; // if all options are diabled if (existingData.length === BED_TYPES.length) { + setBedTypes([]); + setIsLoading(false); return; } // disable existing bed types @@ -277,18 +279,20 @@ export const BedCapacity = (props: BedCapacityProps) => {
- {!isLastOptionType && headerText === "Add Bed Capacity" && ( + {headerText === "Add Bed Capacity" && ( handleSubmit(e, "Save and Exit")} label="Save Bed Capacity" /> )} - handleSubmit(e)} - label={buttonText} - /> + {!isLastOptionType && ( + handleSubmit(e)} + label={buttonText} + /> + )}
)}