Skip to content

Commit

Permalink
Merge pull request #25 from FelipeDuarteLuna/26-02-2024 - Cypress: te…
Browse files Browse the repository at this point in the history
…stes end-to-end

26-02-2024 -  Cypress: testes end-to-end
  • Loading branch information
FelipeDuarteLuna authored Mar 4, 2024
2 parents 3115dfd + 096d233 commit 31699ec
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- run: npx nx affected -t build --parallel=3
- run: npx nx affected -t e2e --parallel=3 --configuration=ci
7 changes: 4 additions & 3 deletions e2e/src/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -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('[email protected]', 'myPassword');
//cy.login('[email protected]', 'myPassword');

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome ecommerce');
getTitle().contains('Ecommerce');
});

});
24 changes: 24 additions & 0 deletions e2e/src/e2e/login.cy.ts
Original file line number Diff line number Diff line change
@@ -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('[email protected]');
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('[email protected]', 'MentoriaAngularPro');

// should redirect to Home
cy.url().should('include', '/home');

// Function helper example, see `../support/app.po.ts` file
getTitle().contains('Ecommerce');
});

});
2 changes: 1 addition & 1 deletion e2e/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const getGreeting = () => cy.get('h1');
export const getTitle = () => cy.get('h1');
12 changes: 11 additions & 1 deletion e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
Expand Down

0 comments on commit 31699ec

Please sign in to comment.