Skip to content

Commit

Permalink
reuse already existing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Nov 18, 2024
1 parent 660e73a commit e433a09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions cypress/e2e/facility_spec/FacilityCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ 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 @@ -340,13 +335,18 @@ describe("Facility Creation", () => {
});

it("Access Restriction for Non-Admin Users to facility creation page", () => {
nonAdminUsers.forEach((user) => {
loginPage.login(user.username, user.password);
cy.visit("/facility/create");
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();
});
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FacilityPage {
}

submitForm() {
cy.get("button#submit").click();
cy.submitButton("Save Facility");
}

selectBedType(bedType: string) {
Expand Down

0 comments on commit e433a09

Please sign in to comment.