Skip to content

Commit

Permalink
Merge branch 'develop' into issue/9132/Yob_Field_Validation_Condition…
Browse files Browse the repository at this point in the history
…_in_Patient_transfer
  • Loading branch information
AdityaJ2305 authored Nov 19, 2024
2 parents 258d697 + 570ed1e commit ba605ee
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
33 changes: 33 additions & 0 deletions cypress/e2e/facility_spec/FacilityCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
4 changes: 4 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/interactive/LegendInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ const Login = (props: { forgot?: boolean }) => {
<button
id="login-button"
type="submit"
className="inline-flex w-full cursor-pointer items-center justify-center rounded bg-primary-500 px-4 py-2 text-sm font-semibold text-white"
className="inline-flex w-full cursor-pointer items-center justify-center rounded bg-primary-500 px-4 py-2 text-sm font-semibold text-white hover:bg-primary-600"
>
{t("login")}
</button>
Expand Down
16 changes: 10 additions & 6 deletions src/components/Facility/BedCapacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -277,18 +279,20 @@ export const BedCapacity = (props: BedCapacityProps) => {

<div className="cui-form-button-group mt-4">
<Cancel onClick={handleClose} />
{!isLastOptionType && headerText === "Add Bed Capacity" && (
{headerText === "Add Bed Capacity" && (
<Submit
id="bed-capacity-save-and-exit"
onClick={(e) => handleSubmit(e, "Save and Exit")}
label="Save Bed Capacity"
/>
)}
<Submit
id="bed-capacity-save"
onClick={(e) => handleSubmit(e)}
label={buttonText}
/>
{!isLastOptionType && (
<Submit
id="bed-capacity-save"
onClick={(e) => handleSubmit(e)}
label={buttonText}
/>
)}
</div>
</div>
)}
Expand Down

0 comments on commit ba605ee

Please sign in to comment.