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
  • Loading branch information
Alokih committed Nov 14, 2024
1 parent da5d576 commit 660e73a
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 @@ -59,6 +59,11 @@ describe("Facility Creation", () => {
const triageErrorMessage = ["This field is required"];
const facilityType = "Primary Health Centres";

const nonAdminUsers = [
{ username: "dummynurse1", password: "Coronasafe@123" },
{ username: "devdoctor", password: "Coronasafe@123" },
];

before(() => {
loginPage.loginAsDistrictAdmin();
cy.saveLocalStorage();
Expand Down Expand Up @@ -317,6 +322,34 @@ 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", () => {
nonAdminUsers.forEach((user) => {
loginPage.login(user.username, user.password);
cy.visit("/facility/create");

facilityPage.verifyErrorNotification(
"You don't have permission to perform this action. Contact the admin",
);
});
});

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 660e73a

Please sign in to comment.