mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-11 17:50:01 -06:00
fix actionability not erroring on covered element
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
_ = require("lodash")
|
||||
$ = require("jquery")
|
||||
Promise = require("bluebird")
|
||||
debug = require('debug')('cypress:driver:actionability')
|
||||
|
||||
$dom = require("../dom")
|
||||
$utils = require("../cypress/utils")
|
||||
@@ -49,8 +50,10 @@ ensureElIsNotCovered = (cy, win, $el, fromElViewport, options, log, onScroll) ->
|
||||
## figure out the deepest element we are about to interact
|
||||
## with at these coordinates
|
||||
$elAtCoords = getElementAtPointFromViewport(fromElViewport)
|
||||
|
||||
debug('elAtCoords', $elAtCoords)
|
||||
debug('el has pointer-events none?')
|
||||
cy.ensureElDoesNotHaveCSS($el, 'pointer-events', 'none', log)
|
||||
debug('is descendent of elAtCoords?')
|
||||
cy.ensureDescendents($el, $elAtCoords, log)
|
||||
|
||||
return $elAtCoords
|
||||
@@ -65,6 +68,8 @@ ensureElIsNotCovered = (cy, win, $el, fromElViewport, options, log, onScroll) ->
|
||||
## from underneath this fixed position element until we can't
|
||||
## anymore
|
||||
$fixed = getFixedOrStickyEl($elAtCoords)
|
||||
|
||||
debug('elAtCoords is fixed', !!$fixed)
|
||||
|
||||
## if we dont have a fixed position
|
||||
## then just bail, cuz we need to retry async
|
||||
@@ -161,7 +166,9 @@ ensureElIsNotCovered = (cy, win, $el, fromElViewport, options, log, onScroll) ->
|
||||
|
||||
## and possibly recursively scroll past it
|
||||
## if we haven't see it before
|
||||
possiblyScrollMultipleTimes($fixed)
|
||||
return possiblyScrollMultipleTimes($fixed)
|
||||
|
||||
throw err
|
||||
else
|
||||
scrollContainers(scrollables)
|
||||
|
||||
|
||||
@@ -35,7 +35,10 @@ create = (Cypress, state, timeout, clearTimeout, whenStable, finishAssertions) -
|
||||
## correctly handles not rewrapping errors so that stack
|
||||
## traces are correctly displayed
|
||||
if debug.enabled and error and not CypressErrorRe.test(error.name)
|
||||
debug('retrying due to caught error...')
|
||||
if debug.prevError && debug.prevError is error.message
|
||||
debug('exiting due to catching same error twice...')
|
||||
throw error
|
||||
debug.prevError = error.message
|
||||
console.error(error)
|
||||
|
||||
interval = options.interval ? options._interval
|
||||
|
||||
@@ -312,6 +312,22 @@ describe('src/cy/commands/actions/click', () => {
|
||||
cy.getAll('el', 'focus focusin').each(shouldBeCalledOnce)
|
||||
})
|
||||
|
||||
it('does not attempt to click element outside viewport', (done) => {
|
||||
cy.on('fail', (err) => {
|
||||
expect(err.message).contain('id="email-with-value"')
|
||||
expect(err.message).contain('hidden from view')
|
||||
done()
|
||||
})
|
||||
|
||||
cy.$$('#tabindex').css(overlayStyle)
|
||||
cy.get('#email-with-value').click()
|
||||
})
|
||||
|
||||
it('can click element outside viewport with force:true', () => {
|
||||
cy.$$('#tabindex').css(overlayStyle)
|
||||
cy.get('#email-with-value').click()
|
||||
})
|
||||
|
||||
it('does not fire a focus, mouseup, or click event when element has been removed on mousedown', () => {
|
||||
const $btn = cy.$$('button:first')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user