Skip to content

Commit

Permalink
Restructure the existing cypress (ohcnetwork#9894)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Jan 11, 2025
1 parent a293183 commit dc3fd52
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
12 changes: 3 additions & 9 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ describe("Facility Management", () => {
cy.loginByApi("nurse");
});

it("Create a new facility using the admin role", () => {
it("Create a new facility using the admin role and verify validation errors", () => {
facilityPage.navigateToOrganization("Kerala");
facilityPage.navigateToFacilitiesList();
facilityPage.clickAddFacility();
facilityPage.submitFacilityCreationForm();
facilityPage.verifyValidationErrors();

// Fill form
facilityPage.fillBasicDetails(
Expand Down Expand Up @@ -47,12 +49,4 @@ describe("Facility Management", () => {
facilityPage.searchFacility(testFacility.name);
facilityPage.verifyFacilityNameInCard(testFacility.name);
});

it("Should show validation errors for required fields", () => {
facilityPage.navigateToOrganization("Kerala");
facilityPage.navigateToFacilitiesList();
facilityPage.clickAddFacility();
facilityPage.submitFacilityCreationForm();
facilityPage.verifyValidationErrors();
});
});
13 changes: 2 additions & 11 deletions cypress/e2e/login_spec/loginpage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@ describe("Login Page", () => {
cy.visit("/login");
});

it("should successfully login with admin credentials", () => {
cy.loginByApi("staff");
cy.url().should("include", "/");
});

it("should display login form elements", () => {
loginPage.verifyFormElements();
});

it("should show validation errors for empty fields", () => {
loginPage.clickSubmit().verifyValidationErrors();
it("should validate login form elements and display validation errors", () => {
loginPage.verifyFormElements().clickSubmit().verifyValidationErrors();
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/patient_spec/patient_search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("Patient Search", () => {

beforeEach(() => {
cy.visit("/login");
cy.loginByApi("nurse");
cy.loginByApi("staff");
});

it("search patient with phone number and verifies details", () => {
Expand Down
8 changes: 5 additions & 3 deletions cypress/pageObject/auth/LoginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export class LoginPage {
private readonly usernameInput = "[data-cy=username]";
private readonly passwordInput = "[data-cy=password]";
private readonly submitButton = "[data-cy=submit]";
private readonly errorMessage = ".text-red-500";

// Add new methods while keeping existing loginByRole
typeUsername(username: string) {
Expand All @@ -25,7 +24,7 @@ export class LoginPage {
}

clickSubmit() {
cy.get(this.submitButton).click();
cy.clickSubmitButton("Login");
return this;
}

Expand All @@ -37,7 +36,10 @@ export class LoginPage {
}

verifyValidationErrors() {
cy.get(this.errorMessage).should("be.visible");
cy.verifyErrorMessages([
"This field is required",
"This field is required",
]);
return this;
}

Expand Down

0 comments on commit dc3fd52

Please sign in to comment.