Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh committed Jan 26, 2022
1 parent 43718fd commit 887185c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
20 changes: 9 additions & 11 deletions packages/driver/cypress/integration/commands/actions/type_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,13 @@ describe('src/cy/commands/actions/type - #type', () => {

targets.forEach((targetId) => {
it(`${targetId}`, () => {
cy.get(`#target-${targetId}`).click()
cy.get(`#target-${targetId}`).focus()
cy.get(`#target-${targetId}`).type('{enter}')

cy.get('li').eq(0).should('have.text', 'click')
cy.get('li').eq(1).should('have.text', 'keydown')
cy.get('li').eq(2).should('have.text', 'keypress')
cy.get('li').eq(3).should('have.text', 'click')
cy.get('li').eq(4).should('have.text', 'keyup')
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')
})
})
})
Expand All @@ -594,13 +593,12 @@ describe('src/cy/commands/actions/type - #type', () => {

targets.forEach((targetId) => {
it(`${targetId}`, () => {
cy.get(`#target-${targetId}`).click()
cy.get(`#target-${targetId}`).focus()
cy.get(`#target-${targetId}`).type('{enter}')

cy.get('li').eq(0).should('have.text', 'click')
cy.get('li').eq(1).should('have.text', 'keydown')
cy.get('li').eq(2).should('have.text', 'keypress')
cy.get('li').eq(3).should('have.text', 'keyup')
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', 'keyup')
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cy/commands/actions/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export default function (Commands, Cypress, cy, state, config) {
// click event is only fired on button, image, submit, reset elements.
// That's why we cannot use $elements.isButtonLike() here.
const type = (type) => $elements.isInputType(options.$el.get(0), type)
const isButtonLike = type('button') || type('image') || type('submit') || type('reset')
const sendClickEvent = type('button') || type('image') || type('submit') || type('reset')

return keyboard.type({
$el: options.$el,
Expand Down Expand Up @@ -362,7 +362,7 @@ export default function (Commands, Cypress, cy, state, config) {

// https://github.com/cypress-io/cypress/issues/19541
// Send click event on type('{enter}')
if (isButtonLike) {
if (sendClickEvent) {
// Firefox sends a click event automatically.
if (!Cypress.isBrowser('firefox')) {
const ctor = $dom.getDocumentFromElement(el).defaultView?.PointerEvent
Expand Down

0 comments on commit 887185c

Please sign in to comment.