-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4441666
commit 71aaf89
Showing
2 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import { defineConfig } from "cypress"; | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
component: { | ||
devServer: { | ||
framework: "next", | ||
bundler: "webpack", | ||
framework: 'next', | ||
bundler: 'webpack', | ||
}, | ||
}, | ||
|
||
e2e: { | ||
baseUrl: 'http://localhost:3000', | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
describe('Cart', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000') | ||
}) | ||
|
||
it('should open cart modal', () => { | ||
cy.get('a[href^="/product"]').first().click() | ||
cy.location('pathname').should('include', '/product') | ||
|
||
cy.contains('Cart').click() | ||
cy.contains('Meu Carrinho').should('exist') | ||
}) | ||
|
||
it('should close cart modal', () => { | ||
cy.get('a[href^="/product"]').first().click() | ||
cy.location('pathname').should('include', '/product') | ||
|
||
cy.contains('Cart').click() | ||
cy.get('button').first().click() | ||
cy.contains('Meu Carrinho').should('not.exist') | ||
}) | ||
|
||
it('should be able to navigate to the product page and it to the cart', () => { | ||
cy.get('a[href^="/product"]').first().click() | ||
cy.location('pathname').should('include', '/product') | ||
|
||
cy.contains('GG').click() | ||
|
||
cy.contains('Adicionar ao carrinho').click() | ||
cy.contains('adicionado ao carrinho :)').should('exist') | ||
}) | ||
|
||
it('should not add to cart without selecting size', () => { | ||
cy.get('a[href^="/product"]').first().click() | ||
cy.location('pathname').should('include', '/product') | ||
|
||
cy.contains('Adicionar ao carrinho').click() | ||
cy.contains('adicionado ao carrinho :)').should('not.exist') | ||
cy.contains('selecione um tamanho antes de adicionar ao carrinho').should( | ||
'exist', | ||
) | ||
}) | ||
|
||
it('should be able to search for a product and add it to the cart', () => { | ||
cy.get('input[name=q]').type('moletom').parent('form').submit() | ||
|
||
cy.get('a[href^="/product"]').first().click() | ||
cy.location('pathname').should('include', '/product') | ||
|
||
cy.contains('GG').click() | ||
|
||
cy.contains('Adicionar ao carrinho').click() | ||
cy.contains('adicionado ao carrinho :)').should('exist') | ||
}) | ||
}) |