Skip to content

Commit

Permalink
Add tests for actionability retries for click and type
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-shehane committed Jan 10, 2025
1 parent ce289ab commit c50a138
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 31 deletions.
46 changes: 46 additions & 0 deletions packages/driver/cypress/e2e/commands/actions/click.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,52 @@ describe('src/cy/commands/actions/click', () => {
cy.get('#dom').invoke('css', 'scrollBehavior').then((scrollBehavior) => expect(scrollBehavior).to.eq('smooth'))
})
})

describe('retries in after hook when failures', () => {
it('clicks element in hook', (done) => {
cy.on('fail', (err) => {
expect(err.message).contain('expected true to be false')
done()
})

expect(true).to.be.false
})

after(() => {
const onClick = cy.stub()

const $button = cy.$$('#button')

$button.on('click', onClick)

cy.get('#button').click().then(() => {
expect(onClick).to.be.calledOnce
})
})
})

describe('retries in afterEach hook when failures', () => {
it('clicks element in hook', (done) => {
cy.on('fail', (err) => {
expect(err.message).contain('expected true to be false')
done()
})

expect(true).to.be.false
})

afterEach(() => {
const onClick = cy.stub()

const $button = cy.$$('#button')

$button.on('click', onClick)

cy.get('#button').click().then(() => {
expect(onClick).to.be.calledOnce
})
})
})
})

describe('assertion verification', () => {
Expand Down
46 changes: 46 additions & 0 deletions packages/driver/cypress/e2e/commands/actions/type.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,52 @@ describe('src/cy/commands/actions/type - #type', () => {

cy.get(':text:first').type('foo', { scrollBehavior: false, timeout: 200 })
})

describe('retries in after hook when failures', () => {
it('types in element in hook', (done) => {
cy.on('fail', (err) => {
expect(err.message).contain('expected true to be false')
done()
})

expect(true).to.be.false
})

after(() => {
const input = cy.$$('input:text:first')

input.val('')

expect(input).to.have.value('')

cy.get('input:text:first').type('foo').then(($input) => {
expect($input).to.have.value('foo')
})
})
})

describe('retries in afterEach hook when failures', () => {
it('types in element in hook', (done) => {
cy.on('fail', (err) => {
expect(err.message).contain('expected true to be false')
done()
})

expect(true).to.be.false
})

afterEach(() => {
const input = cy.$$('input:text:first')

input.val('')

expect(input).to.have.value('')

cy.get('input:text:first').type('foo').then(($input) => {
expect($input).to.have.value('foo')
})
})
})
})

describe('input types where no extra formatting required', () => {
Expand Down
31 changes: 0 additions & 31 deletions packages/driver/cypress/e2e/issues/2831.cy.js

This file was deleted.

0 comments on commit c50a138

Please sign in to comment.