Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Aug 24, 2021
2 parents ba922c7 + 8988b2c commit d745ca2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 56 deletions.
66 changes: 19 additions & 47 deletions packages/driver/cypress/integration/commands/actions/type_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const expectTextEndsWith = (expected) => {
}
}

const isChromium = Cypress.isBrowser({ family: 'chromium' })

describe('src/cy/commands/actions/type - #type', () => {
beforeEach(() => {
cy.visit('/fixtures/dom.html')
Expand Down Expand Up @@ -2028,12 +2026,8 @@ describe('src/cy/commands/actions/type - #type', () => {
.type(' f\n{backspace}')
.type('{moveToStart}{del}')
.then(($el) => {
if (isChromium) {
expect(stub).callCount(5)
expect($el[0].value).eq('oo bar baz ')
} else {
expect(stub, 'should NOT send beforeinput unless in chromium based browser').not.called
}
expect(stub).callCount(5)
expect($el[0].value).eq('oo bar baz ')
})
})

Expand Down Expand Up @@ -2076,12 +2070,8 @@ describe('src/cy/commands/actions/type - #type', () => {
.type(' f\n{backspace}')
.type('{moveToStart}{del}')
.then(($el) => {
if (isChromium) {
expect(stub).callCount(5)
expect($el[0].value).eq('oo bar baz f')
} else {
expect(stub, 'should NOT send beforeinput unless in chromium based browser').not.called
}
expect(stub).callCount(5)
expect($el[0].value).eq('oo bar baz f')
})
})

Expand Down Expand Up @@ -2124,12 +2114,8 @@ describe('src/cy/commands/actions/type - #type', () => {
.type(' f\n{backspace}')
.type('{moveToStart}{del}')
.then(($el) => {
if (isChromium) {
expect(stub).callCount(5)
expect($el[0].textContent).eq('oo bar baz f')
} else {
expect(stub, 'should NOT send beforeinput unless in chromium based browser').not.called
}
expect(stub).callCount(5)
expect($el[0].textContent).eq('oo bar baz f')
})
})

Expand Down Expand Up @@ -2169,11 +2155,7 @@ describe('src/cy/commands/actions/type - #type', () => {
.type('{ctrl}{backspace}')
.type('{ctrl}{shift}{backspace}')
.then(($el) => {
if (isChromium) {
expect(stub).callCount(4)
} else {
expect(stub, 'should NOT send beforeinput unless in chromium based browser').not.called
}
expect(stub).callCount(4)
})
})

Expand All @@ -2190,12 +2172,8 @@ describe('src/cy/commands/actions/type - #type', () => {
})
.type('foo')
.then(($el) => {
if (isChromium) {
expect(callCount).eq(3)
expect($el[0].value).eq('foo bar baz')
} else {
expect(callCount, 'should NOT send beforeinput unless in chromium based browser').eq(0)
}
expect(callCount).eq(3)
expect($el[0].value).eq('foo bar baz')
})
})
})
Expand Down Expand Up @@ -2573,17 +2551,15 @@ describe('src/cy/commands/actions/type - #type', () => {
// eslint-disable-next-line
console.table(table.data, table.columns)

const beforeinput = Cypress.isBrowser('firefox') ? '' : ' beforeinput,'

expect(table.name).to.eq('Keyboard Events')
const expectedTable = {
1: { 'Details': '{ code: KeyH, which: 72 }', Typed: 'h', 'Events Fired': `keydown, keypress,${beforeinput} textInput, input, keyup`, 'Active Modifiers': null, 'Prevented Default': null, 'Target Element': $input[0] },
1: { 'Details': '{ code: KeyH, which: 72 }', Typed: 'h', 'Events Fired': `keydown, keypress, beforeinput, textInput, input, keyup`, 'Active Modifiers': null, 'Prevented Default': null, 'Target Element': $input[0] },
2: { 'Details': '{ code: ControlLeft, which: 17 }', Typed: '{ctrl}', 'Events Fired': 'keydown', 'Active Modifiers': 'ctrl', 'Prevented Default': null, 'Target Element': $input[0] },
3: { 'Details': '{ code: AltLeft, which: 18 }', Typed: '{alt}', 'Events Fired': 'keydown', 'Active Modifiers': 'alt, ctrl', 'Prevented Default': null, 'Target Element': $input[0] },
4: { 'Details': '{ code: Equal, which: 187 }', Typed: '+', 'Events Fired': 'keydown, keyup', 'Active Modifiers': 'alt, ctrl', 'Prevented Default': null, 'Target Element': $input[0] },
5: { 'Details': '{ code: AltLeft, which: 18 }', Typed: '{alt}', 'Events Fired': 'keyup', 'Active Modifiers': 'ctrl', 'Prevented Default': null, 'Target Element': $input[0] },
6: { 'Details': '{ code: ControlLeft, which: 17 }', Typed: '{ctrl}', 'Events Fired': 'keyup', 'Active Modifiers': null, 'Prevented Default': null, 'Target Element': $input[0] },
7: { 'Details': '{ code: KeyI, which: 73 }', Typed: 'i', 'Events Fired': `keydown, keypress,${beforeinput} textInput, input, keyup`, 'Active Modifiers': null, 'Prevented Default': null, 'Target Element': $input[0] },
7: { 'Details': '{ code: KeyI, which: 73 }', Typed: 'i', 'Events Fired': `keydown, keypress, beforeinput, textInput, input, keyup`, 'Active Modifiers': null, 'Prevented Default': null, 'Target Element': $input[0] },
}

// uncomment for debugging
Expand Down Expand Up @@ -3484,20 +3460,18 @@ describe('src/cy/commands/actions/type - #type', () => {
// eslint-disable-next-line
console.table(table.data, table.columns)

const beforeInput = isChromium ? 'beforeinput, ' : ''

expect(table.name).to.eq('Keyboard Events')
const expectedTable = {
1: { 'Details': '{ code: MetaLeft, which: 91 }', Typed: '{cmd}', 'Events Fired': 'keydown', 'Active Modifiers': 'meta', 'Prevented Default': null, 'Target Element': $input[0] },
2: { 'Details': '{ code: AltLeft, which: 18 }', Typed: '{option}', 'Events Fired': 'keydown', 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
3: { 'Details': '{ code: KeyF, which: 70 }', Typed: 'f', 'Events Fired': `keydown, keypress, ${beforeInput}textInput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
4: { 'Details': '{ code: KeyO, which: 79 }', Typed: 'o', 'Events Fired': `keydown, keypress, ${beforeInput}textInput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
5: { 'Details': '{ code: KeyO, which: 79 }', Typed: 'o', 'Events Fired': `keydown, keypress, ${beforeInput}textInput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
6: { 'Details': '{ code: Enter, which: 13 }', Typed: '{enter}', 'Events Fired': `keydown, keypress, ${beforeInput}keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
7: { 'Details': '{ code: KeyB, which: 66 }', Typed: 'b', 'Events Fired': `keydown, keypress, ${beforeInput}textInput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
3: { 'Details': '{ code: KeyF, which: 70 }', Typed: 'f', 'Events Fired': `keydown, keypress, beforeinput, textInput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
4: { 'Details': '{ code: KeyO, which: 79 }', Typed: 'o', 'Events Fired': `keydown, keypress, beforeinput, textInput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
5: { 'Details': '{ code: KeyO, which: 79 }', Typed: 'o', 'Events Fired': `keydown, keypress, beforeinput, textInput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
6: { 'Details': '{ code: Enter, which: 13 }', Typed: '{enter}', 'Events Fired': `keydown, keypress, beforeinput, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
7: { 'Details': '{ code: KeyB, which: 66 }', Typed: 'b', 'Events Fired': `keydown, keypress, beforeinput, textInput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
8: { 'Details': '{ code: ArrowLeft, which: 37 }', Typed: '{leftarrow}', 'Events Fired': 'keydown, keyup', 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
9: { 'Details': '{ code: Delete, which: 46 }', Typed: '{del}', 'Events Fired': `keydown, ${beforeInput}input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
10: { 'Details': '{ code: Enter, which: 13 }', Typed: '{enter}', 'Events Fired': `keydown, keypress, ${beforeInput}keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
9: { 'Details': '{ code: Delete, which: 46 }', Typed: '{del}', 'Events Fired': `keydown, beforeinput, input, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
10: { 'Details': '{ code: Enter, which: 13 }', Typed: '{enter}', 'Events Fired': `keydown, keypress, beforeinput, keyup`, 'Active Modifiers': 'alt, meta', 'Prevented Default': null, 'Target Element': $input[0] },
11: { 'Details': '{ code: MetaLeft, which: 91 }', Typed: '{cmd}', 'Events Fired': 'keyup', 'Active Modifiers': 'alt', 'Prevented Default': null, 'Target Element': $input[0] },
12: { 'Details': '{ code: AltLeft, which: 18 }', Typed: '{option}', 'Events Fired': 'keyup', 'Active Modifiers': null, 'Prevented Default': null, 'Target Element': $input[0] },
}
Expand All @@ -3513,10 +3487,8 @@ describe('src/cy/commands/actions/type - #type', () => {
cy.get(':text:first').type('f').then(function ($el) {
const table = this.lastLog.invoke('consoleProps').table[2]()

const beforeInput = isChromium ? 'beforeinput, ' : ''

expect(table.data).to.deep.eq({
1: { Typed: 'f', 'Events Fired': `keydown, keypress, ${beforeInput}textInput, input, keyup`, 'Active Modifiers': null, Details: '{ code: KeyF, which: 70 }', 'Prevented Default': null, 'Target Element': $el[0] },
1: { Typed: 'f', 'Events Fired': `keydown, keypress, beforeinput, textInput, input, keyup`, 'Active Modifiers': null, Details: '{ code: KeyF, which: 70 }', 'Prevented Default': null, 'Target Element': $el[0] },
})
})
})
Expand Down
11 changes: 3 additions & 8 deletions packages/driver/src/cy/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,11 +689,7 @@ export interface typeOptions {
}

export class Keyboard {
private SUPPORTS_BEFOREINPUT_EVENT

constructor (Cypress, private state: State) {
this.SUPPORTS_BEFOREINPUT_EVENT = Cypress.isBrowser({ family: 'chromium' })
}
constructor (private state: State) {}

type (opts: typeOptions) {
const options = _.defaults({}, opts, {
Expand Down Expand Up @@ -1174,7 +1170,6 @@ export class Keyboard {
this.fireSimulatedEvent(elToType, 'keypress', key, options)
) {
if (
!this.SUPPORTS_BEFOREINPUT_EVENT ||
shouldIgnoreEvent('beforeinput', key.events) ||
this.fireSimulatedEvent(elToType, 'beforeinput', key, options)
) {
Expand Down Expand Up @@ -1317,8 +1312,8 @@ export class Keyboard {
}
}

const create = (Cypress, state) => {
return new Keyboard(Cypress, state)
const create = (state) => {
return new Keyboard(state)
}

let _defaults
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress/cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const create = function (specWindow, Cypress, Cookies, state, config, log) {
const jquery = $jQuery.create(state)
const location = $Location.create(state)
const focused = $Focused.create(state)
const keyboard = $Keyboard.create(Cypress, state)
const keyboard = $Keyboard.create(state)
const mouse = $Mouse.create(state, keyboard, focused, Cypress)
const timers = $Timers.create(Cypress)

Expand Down

0 comments on commit d745ca2

Please sign in to comment.