Skip to content

Commit

Permalink
update(cypress): update get by data cy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm committed May 14, 2024
1 parent 399bd4e commit b4af9b5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
20 changes: 18 additions & 2 deletions cypress/e2e/01-pin-input.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
describe("Pin Screen", () => {
it("Enter Pin Screen", () => {
cy.visit("");
it("Enter Pin Screen - Enter valid PIN", () => {
cy.visit("/");
cy.url().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.url().should("include", "/pre");
cy.url().should("include", "/chat");
});

it("Enter Pin Screen - Enter PIN with 3 digits", () => {
cy.visit("/");
cy.url().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");
});
});
13 changes: 11 additions & 2 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

Cypress.Commands.add("dataCy", (value) => {
return cy.get(`[data-cy=${value}]`);
declare namespace Cypress {
interface Chainable<Subject> {
getByTestAttr(
selector: string,
...options: any
): Chainable<JQuery<HTMLElement>>;
}
}

Cypress.Commands.add("getByTestAttr", (value: string, ...options: any) => {
return cy.get(`[data-cy=${value}]`, ...options);
});
10 changes: 0 additions & 10 deletions cypress/support/index.ts

This file was deleted.

3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"lib": ["es5", "dom"],
"types": ["cypress", "node"],
"baseUrl": "."
}
},
"include": ["**/*.ts"]
}

0 comments on commit b4af9b5

Please sign in to comment.