Skip to content

Commit

Permalink
Merge pull request #5 from tielefernandes/aula-6
Browse files Browse the repository at this point in the history
🧪 test: [Logout] testando com viewport adaptado
  • Loading branch information
tielefernandes authored Nov 15, 2023
2 parents 4a8b2f6 + ce8e772 commit ea1773a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
3 changes: 3 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module.exports = defineConfig({
chromeWebSecurity: false,
e2e: {
baseUrl: 'https://notes-serverless-app.com',
env: {
viewportWidthBreakpoint: 768,
},
setupNodeEvents() {
// implement node event listeners here
},
Expand Down
61 changes: 38 additions & 23 deletions cypress/e2e/authenticated.cy.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
import { faker } from '@faker-js/faker/locale/en'

describe('Scenarios where authentication is a pre-condition', () => {
beforeEach(() => {
cy.intercept('GET', '**/notes').as('getNotes')
cy.sessionLogin()
})
beforeEach(() => {
cy.intercept('GET', '**/notes').as('getNotes')
cy.sessionLogin()
})

it('CRUDs a note', () => {
const noteDescription = faker.lorem.words(4)
it('CRUDs a note', () => {
const noteDescription = faker.lorem.words(4)

cy.createNote(noteDescription)
cy.wait('@getNotes')
cy.createNote(noteDescription)
cy.wait('@getNotes')

const updatedNoteDescription = faker.lorem.words(4)
const attachFile = true
const updatedNoteDescription = faker.lorem.words(4)
const attachFile = true

cy.editNote(noteDescription, updatedNoteDescription, attachFile)
cy.wait('@getNotes')
cy.editNote(noteDescription, updatedNoteDescription, attachFile)
cy.wait('@getNotes')

cy.deleteNote(updatedNoteDescription)
cy.wait('@getNotes')
})
cy.deleteNote(updatedNoteDescription)
cy.wait('@getNotes')
})

it.only('successfully submits the settings form', () => {
cy.intercept('POST', '**/prod/billing').as('paymentRequest')
it('successfully submits the settings form', () => {
cy.intercept('POST', '**/prod/billing').as('paymentRequest')

cy.fillSettingsFormAndSubmit()
cy.fillSettingsFormAndSubmit()

cy.wait('@getNotes')
cy.wait('@paymentRequest')
.its('state')
.should('be.equal', 'Complete')
})
cy.wait('@getNotes')
cy.wait('@paymentRequest')
.its('state')
.should('be.equal', 'Complete')
})

it('logs out', () => {
cy.visit('/')
cy.wait('@getNotes')

if (Cypress.config('viewportWidth') < Cypress.env('viewportWidthBreakpoint')) {
cy.get('.navbar-toggle.collapsed')
.should('be.visible')
.click()
}

cy.contains('.nav a', 'Logout').click()

cy.get('#email').should('be.visible')
})
})

0 comments on commit ea1773a

Please sign in to comment.