Skip to content

Commit

Permalink
Tests to verify error handling and access restrictions during Facilit…
Browse files Browse the repository at this point in the history
…y Creation (#9119)
  • Loading branch information
Alok authored Nov 19, 2024
1 parent b17eb22 commit 5eb31eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 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

0 comments on commit 5eb31eb

Please sign in to comment.