Skip to content

Commit

Permalink
make sure done is only called once
Browse files Browse the repository at this point in the history
  • Loading branch information
astone123 committed Apr 5, 2023
1 parent 7bb255b commit e6ab6a0
Showing 1 changed file with 37 additions and 45 deletions.
82 changes: 37 additions & 45 deletions packages/driver/cypress/e2e/commands/actions/type_events.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,30 @@ describe('src/cy/commands/actions/type - #type events', () => {

it('receives textInput event', (done) => {
// TODO fix this test in Webkit https://github.com/cypress-io/cypress/issues/26438
if (isWebkit) {
done()
}

const $txt = cy.$$(':text:first')
if (!isWebkit) {
const $txt = cy.$$(':text:first')

$txt[0].addEventListener('textInput', (e) => {
$txt[0].addEventListener('textInput', (e) => {
// FIXME: (firefox) firefox cannot access window objects else throw cross-origin error
expect(Object.prototype.toString.call(e.view)).eq('[object Window]')
e.view = null
expect(_.toPlainObject(e)).to.include({
bubbles: true,
cancelable: true,
data: 'a',
detail: 0,
type: 'textInput',
// view: cy.state('window'),
which: 0,
expect(Object.prototype.toString.call(e.view)).eq('[object Window]')
e.view = null
expect(_.toPlainObject(e)).to.include({
bubbles: true,
cancelable: true,
data: 'a',
detail: 0,
type: 'textInput',
// view: cy.state('window'),
which: 0,
})

done()
})

cy.get(':text:first').type('a')
} else {
done()
})

cy.get(':text:first').type('a')
}
})

it('receives input event', (done) => {
Expand Down Expand Up @@ -600,41 +600,33 @@ describe('src/cy/commands/actions/type - #type events', () => {
]

targets.forEach((target) => {
it(target, (done) => {
it(target, () => {
// TODO fix this test in Webkit https://github.com/cypress-io/cypress/issues/26438
if (isWebkit) {
done()
if (!isWebkit) {
cy.get(`#target-${target}`).focus().type('{enter}')

cy.get('li').should('have.length', 4)
cy.get('li').eq(0).should('have.text', 'keydown')
cy.get('li').eq(1).should('have.text', 'keypress')
cy.get('li').eq(2).should('have.text', 'click')
cy.get('li').eq(3).should('have.text', 'keyup')
}

cy.get(`#target-${target}`).focus().type('{enter}')

cy.get('li').should('have.length', 4)
cy.get('li').eq(0).should('have.text', 'keydown')
cy.get('li').eq(1).should('have.text', 'keypress')
cy.get('li').eq(2).should('have.text', 'click')
cy.get('li').eq(3).should('have.text', 'keyup')

done()
})
})

describe('keydown triggered on another element', () => {
targets.forEach((target) => {
it(target, (done) => {
it(target, () => {
// TODO fix this test in Webkit https://github.com/cypress-io/cypress/issues/26438
if (isWebkit) {
done()
if (!isWebkit) {
cy.get('#focus-options').select(target)
cy.get('#input-text').focus().type('{enter}')

cy.get('li').should('have.length', 3)
cy.get('li').eq(0).should('have.text', 'keypress')
cy.get('li').eq(1).should('have.text', 'click')
cy.get('li').eq(2).should('have.text', 'keyup')
}

cy.get('#focus-options').select(target)
cy.get('#input-text').focus().type('{enter}')

cy.get('li').should('have.length', 3)
cy.get('li').eq(0).should('have.text', 'keypress')
cy.get('li').eq(1).should('have.text', 'click')
cy.get('li').eq(2).should('have.text', 'keyup')

done()
})
})
})
Expand Down

0 comments on commit e6ab6a0

Please sign in to comment.