Skip to content

Commit

Permalink
test(add): add POM into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm committed May 20, 2024
1 parent dc48174 commit 79d4839
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 17 deletions.
33 changes: 16 additions & 17 deletions cypress/e2e/01-pin-input.cy.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import { chatsMainPage } from "./PageObjects/ChatsMain";
import { loginPinPage } from "./PageObjects/LoginPin";
import { preLoadingPage } from "./PageObjects/PreLoading";

describe("Pin Screen", () => {
beforeEach(() => {
loginPinPage.launchApplication();
});

it("Enter Pin Screen - Enter valid PIN", () => {
cy.visit("/");
cy.getByTestAttr("pin-keypad", { timeout: 30000 }).should("exist");
cy.location("href").should("include", "/auth/unlock");
cy.getByTestAttr("button-pin-1").should("exist").click();
cy.getByTestAttr("button-pin-2").should("exist").click();
cy.getByTestAttr("button-pin-3").should("exist").click();
cy.getByTestAttr("button-pin-4").should("exist").click();
cy.getByTestAttr("button-confirm-pin").should("exist").click();
cy.getByTestAttr("button-confirm-pin").should("not.exist");
cy.location("href").should("include", "/pre");
cy.location("href").should("include", "/chat");
loginPinPage.waitUntilPageIsLoaded();
loginPinPage.enterPin("1234");
loginPinPage.clickConfirm();
preLoadingPage.validateURL();
chatsMainPage.validateURL();
});

it("Enter Pin Screen - Enter PIN with 3 digits", () => {
cy.visit("/");
cy.location("href").should("include", "/auth/unlock");
cy.getByTestAttr("button-pin-1").should("exist").click();
cy.getByTestAttr("button-pin-2").should("exist").click();
cy.getByTestAttr("button-pin-3").should("exist").click();
cy.getByTestAttr("button-confirm-pin").should("exist").and("be.disabled");
loginPinPage.waitUntilPageIsLoaded();
loginPinPage.enterPin("123");
loginPinPage.validateConfirmButtonIsDisabled();
});
});
7 changes: 7 additions & 0 deletions cypress/e2e/PageObjects/ChatsMain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ChatsMainPage {
public validateURL() {
cy.location("href").should("include", "/chat");
}
}

export const chatsMainPage: ChatsMainPage = new ChatsMainPage();
61 changes: 61 additions & 0 deletions cypress/e2e/PageObjects/LoginPin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
class LoginPinPage {
get pinButton0() {
return cy.getByTestAttr("button-pin-0");
}
get pinButton1() {
return cy.getByTestAttr("button-pin-1");
}
get pinButton2() {
return cy.getByTestAttr("button-pin-2");
}
get pinButton3() {
return cy.getByTestAttr("button-pin-3");
}
get pinButton4() {
return cy.getByTestAttr("button-pin-4");
}
get pinButton5() {
return cy.getByTestAttr("button-pin-5");
}
get pinButton6() {
return cy.getByTestAttr("button-pin-6");
}
get pinButton7() {
return cy.getByTestAttr("button-pin-7");
}
get pinButton8() {
return cy.getByTestAttr("button-pin-8");
}
get pinButton9() {
return cy.getByTestAttr("button-pin-9");
}

get pinButtonConfirm() {
return cy.getByTestAttr("button-confirm-pin");
}

public clickConfirm() {
this.pinButtonConfirm.should("exist").click();
}

public enterPin(pin: string) {
pin.split("").forEach((digit) => {
cy.getByTestAttr(`button-pin-${digit}`).should("exist").click();
});
}

public launchApplication() {
cy.visit("/");
}

public validateConfirmButtonIsDisabled() {
this.pinButtonConfirm.should("exist").and("be.disabled");
}

public waitUntilPageIsLoaded() {
cy.getByTestAttr("pin-keypad", { timeout: 30000 }).should("exist");
cy.location("href").should("include", "/auth/unlock");
}
}

export const loginPinPage: LoginPinPage = new LoginPinPage();
7 changes: 7 additions & 0 deletions cypress/e2e/PageObjects/PreLoading.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class PreLoadingPage {
public validateURL() {
cy.location("href").should("include", "/pre");
}
}

export const preLoadingPage: PreLoadingPage = new PreLoadingPage();

0 comments on commit 79d4839

Please sign in to comment.