diff --git a/cypress/e2e/spec.cy.js b/cypress/e2e/spec.cy.js index 5e30bf9e..5a2e68d6 100644 --- a/cypress/e2e/spec.cy.js +++ b/cypress/e2e/spec.cy.js @@ -1,6 +1,15 @@ -/// -describe('page', () => { - it('works', () => { - cy.visit('https://example.cypress.io') - }) -}) +import LoginPage from '../pages/pageObject.cy.js'; + +describe('Login Flow', () => { + it('should log in successfully', () => { + const loginPage = new LoginPage(); + const email = "test@email.com"; + const password = "password"; + + loginPage.visitSignInPage(); + loginPage.fillEmail(email); + loginPage.fillPassword(password); + loginPage.clickLoginButton(); + loginPage.isSignedIn(); + }); +}); diff --git a/cypress/page/pageObject.cy.js b/cypress/page/pageObject.cy.js new file mode 100644 index 00000000..60886a54 --- /dev/null +++ b/cypress/page/pageObject.cy.js @@ -0,0 +1,30 @@ +const emailInput = 'input[name="email"]'; +const passwordInput = 'input[type="password"]'; +const loginButton = '._flexButton_2u3cq_1._blue_2u3cq_42._outline_2u3cq_20'; + +class LoginPage { + visitSignInPage() { + const signInPageUrl = 'http://app.yourdocket.com/signin'; + cy.visit(signInPageUrl); + cy.url().should('include', '/signin'); + } + + fillEmail(email) { + cy.get(emailInput).type(email); + } + + fillPassword(password) { + cy.get(passwordInput).type(password); + } + + clickLoginButton() { + cy.get(loginButton).first().click(); + } + + isSignedIn() { + cy.url().should('include', '/today'); + } +} + +export default LoginPage; +