Skip to content

Commit

Permalink
Removing unnecessary test
Browse files Browse the repository at this point in the history
  • Loading branch information
tbiethman committed Aug 24, 2022
1 parent 47d1155 commit 2c52293
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
19 changes: 0 additions & 19 deletions packages/driver/cypress/e2e/commands/actions/type.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -958,25 +958,6 @@ describe('src/cy/commands/actions/type - #type', () => {
.should('have.value', 'baroo')
})

// WebKit will select all input content on focus. This causes our
// cursor placement logic to be ignored, as we interpret the default
// selection as a user-provided selection that we do not want to override.
// We work around this by preventing the default selection on focus using
// our own capture-phase 'focus' event handler; this test ensures that user-set
// capture-phase events continue to function as expected for the purpose
// of selection updates.
it('respects changed selection in focus handler during capture phase', () => {
cy.get('#input-without-value')
.then(($el) => {
$el.val('foo')
$el.get(0).addEventListener('focus', (e) => {
e.currentTarget.setSelectionRange(0, 1)
}, { capture: true })
})
.type('bar')
.should('have.value', 'baroo')
})

it('overwrites text when selectAll in mouseup handler', () => {
cy.$$('#input-without-value').val('0').mouseup(function () {
$(this).select()
Expand Down
6 changes: 3 additions & 3 deletions packages/driver/src/cy/focused.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ export const create = (state: StateFunc) => ({
// and persist it, leaving the selection contents to be overwritten rather than appended to
// on subsequent actions.
//
// In order to avoid this behavior, we explicitly set the selection range with the current
// selectionStart/selectionEnd values. This will bypass the default select-all behavior, even though
// logically it looks like a no-op.
// To avoid this behavior, we explicitly set the selection range with the current
// selectionStart/selectionEnd values prior to calling focus. This will bypass the
// default select-all behavior even though logically it looks like a no-op.
try {
el.setSelectionRange(el.selectionStart, el.selectionEnd)
} catch (e) {
Expand Down

0 comments on commit 2c52293

Please sign in to comment.