diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a6a107..eda0369 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,5 @@ jobs: - run: npx nx affected -t lint --parallel=3 - run: npx nx affected -t test --parallel=3 --configuration=ci - - run: npx nx affected -t build --parallel=3 \ No newline at end of file + - run: npx nx affected -t build --parallel=3 + - run: npx nx affected -t e2e --parallel=3 --configuration=ci \ No newline at end of file diff --git a/e2e/src/e2e/app.cy.ts b/e2e/src/e2e/app.cy.ts index 62ac22d..03e5a66 100644 --- a/e2e/src/e2e/app.cy.ts +++ b/e2e/src/e2e/app.cy.ts @@ -1,13 +1,14 @@ -import { getGreeting } from '../support/app.po'; +import { getTitle } from '../support/app.po'; describe('ecommerce', () => { beforeEach(() => cy.visit('/')); it('should display welcome message', () => { // Custom command example, see `../support/commands.ts` file - cy.login('my-email@something.com', 'myPassword'); + //cy.login('my-email@something.com', 'myPassword'); // Function helper example, see `../support/app.po.ts` file - getGreeting().contains('Welcome ecommerce'); + getTitle().contains('Ecommerce'); }); + }); diff --git a/e2e/src/e2e/login.cy.ts b/e2e/src/e2e/login.cy.ts new file mode 100644 index 0000000..e0add1c --- /dev/null +++ b/e2e/src/e2e/login.cy.ts @@ -0,0 +1,24 @@ +import { getTitle } from '../support/app.po'; + +describe('ecommerce', () => { + beforeEach(() => cy.visit('/')); + + it('Should Login', () => { + + /*cy.get('a').contains('Fazer Login').click(); + cy.get('input[type="email"]').type('felipinho.luna@gmail.com'); + cy.get('button').contains('Próximo').click(); + cy.get('input[type="password"]').type('MentoriaAngularPro'); + cy.get('button').contains('Entrar').click();*/ + + // Custom command example, see `../support/commands.ts` file + cy.login('felipinho.luna@gmail.com', 'MentoriaAngularPro'); + + // should redirect to Home + cy.url().should('include', '/home'); + + // Function helper example, see `../support/app.po.ts` file + getTitle().contains('Ecommerce'); + }); + +}); diff --git a/e2e/src/support/app.po.ts b/e2e/src/support/app.po.ts index 3293424..7e3e783 100644 --- a/e2e/src/support/app.po.ts +++ b/e2e/src/support/app.po.ts @@ -1 +1 @@ -export const getGreeting = () => cy.get('h1'); +export const getTitle = () => cy.get('h1'); diff --git a/e2e/src/support/commands.ts b/e2e/src/support/commands.ts index 9d2aea8..df606e3 100644 --- a/e2e/src/support/commands.ts +++ b/e2e/src/support/commands.ts @@ -17,9 +17,19 @@ declare namespace Cypress { } // // -- This is a parent command -- -Cypress.Commands.add('login', (email, password) => { +Cypress.Commands.add('login', (email: string, password: string ) => { // eslint-disable-next-line no-console console.log('Custom command example: Login', email, password); + + cy.get('a').contains('Fazer Login').click(); + + cy.get('input[type="email"]').type( email ); + + cy.get('button').contains('Próximo').click(); + + cy.get('input[type="password"]').type( password ); + + cy.get('button').contains('Entrar').click(); }); // // -- This is a child command --