Skip to content

Commit

Permalink
added tests surrounding kendo edge case with endless loop finding fix…
Browse files Browse the repository at this point in the history
…ed content
  • Loading branch information
brian-mann committed Jun 23, 2015
1 parent f233209 commit 9288641
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 15 deletions.
10 changes: 7 additions & 3 deletions app/js/api/cypress/cy/commands/actions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,12 @@ $Cypress.register "Actions", (Cypress, _, $) ->
if $fixed = getElementWithFixedPosition($elToClick)
scrollWindowPastFixedElement($fixed)

retry = ->
getCoords(false)

## try again now that we've nudged the window's scroll
return getElementAtCoordinates(coords)
# return getElementAtCoordinates(coords)
return @_retry(retry, options)

if options.command
options.command.snapshot()
Expand All @@ -531,7 +535,7 @@ $Cypress.register "Actions", (Cypress, _, $) ->

return coordsObj(coords, $elToClick)

getCoords = =>
getCoords = (scrollIntoView = true) =>
## use native scrollIntoView here so scrollable
## containers are automatically handled correctly

Expand All @@ -540,7 +544,7 @@ $Cypress.register "Actions", (Cypress, _, $) ->
## and scrollBy the amount of distance between the center
## and the left of the element so it positions the center
## in the viewport
$el.get(0).scrollIntoView()
$el.get(0).scrollIntoView() if scrollIntoView

coords = @getCoordinates($el)

Expand Down
2 changes: 1 addition & 1 deletion app/js/api/cypress/cy/commands/querying.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ $Cypress.register "Querying", (Cypress, _, $) ->

## find elements by the :contains psuedo selector
## and any submit inputs with the attributeContainsWord selector
selector = "#{filter}:contains('#{text}'), #{filter}[type='submit'][value~='#{text}']"
selector = "#{filter}:not(script):contains('#{text}'), #{filter}[type='submit'][value~='#{text}']"

@command("get", selector, options).then (elements) ->
return log(null) if not elements
Expand Down
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"sinon-as-promised": "~2.0.3",
"underscore.inflection": "~1.2.0",
"js-cookie": "~1.5.1",
"bootstrap": "~3.3.5"
"bootstrap": "~3.3.5",
"kendo-ui": "~2015.1.616"
}
}
29 changes: 25 additions & 4 deletions spec/client/api/integration/clicks_spec.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
describe "Clicks Integration Tests", ->
enterCommandTestingMode("html/clicks")
context "html/fixed-nav", ->
enterCommandTestingMode("html/fixed-nav")

context "clicking edge cases", ->
it "can click inputs under a fixed-position nav", ->
@cy.get("button").click()
describe "fixed nav", ->
it "can click inputs under a fixed-position nav", ->
@cy.get("button").click()

context "html/dropdown", ->
enterCommandTestingMode("html/dropdown", {replaceIframeContents: false})

describe "animating dropdown with fixed background", ->
## this tests a kendo drop down opening
## as it opens the element from position returns the background element
## which is fixed position
## the fixed position element cannot be scrolled and thus an endless loop
## is created
it "can click an animating element when the element behind it is fixed position and cannot be scrolled", ->
@cy.window().then (win) ->
k = win.$("#dropdown").getKendoDropDownList()
k.open()

@cy
.contains(".k-item", "Strawberries").click()
.window().then (win) ->
k = win.$("#dropdown").getKendoDropDownList()
expect(k.text()).to.eq "Strawberries"
9 changes: 3 additions & 6 deletions spec/client/spec_helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,15 @@ window.enterIntegrationTestingMode = (fixture, options = {}) ->
@iframe.remove()
@Cypress.stop()

window.enterCommandTestingMode = (fixture = "html/dom") ->
window.enterCommandTestingMode = (fixture = "html/dom", options = {}) ->
before ->
@loadDom = _.bind(loadDom, @)

@loadDom(fixture)

beforeEach ->
@setup = (options = {}) =>
_.defaults options,
replaceIframeContents: true

if options.replaceIframeContents
@setup = (opts = {}) =>
if options.replaceIframeContents isnt false and opts.replaceIframeContents isnt false
@iframe.contents().find("head").html(@head)
@iframe.contents().find("body").html(@body)

Expand Down
44 changes: 44 additions & 0 deletions spec/fixtures/html/dropdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<title>DOM Fixture</title>
<script type="text/javascript" src="/lib/public/js/sinon.js"></script>
<script type="text/javascript" src="/bower_components/jquery/dist/jquery.js"></script>
</head>
<body>
<div id="background">
<link rel="stylesheet" href="/bower_components/kendo-ui/styles/kendo.common.min.css">
<link rel="stylesheet" href="/bower_components/kendo-ui/styles/kendo.default.min.css">

<style>
#background {
position: fixed;
background-color: gray;
width: 100%;
height: 100%;
}
</style>

<input id="dropdown" />

<script type="text/javascript" src="/bower_components/kendo-ui/js/kendo.ui.core.min.js"></script>
<script type="text/javascript">
$(function(){
$("#dropdown").kendoDropDownList({
optionLabel: "--Select--",
dataTextField: "t",
dataValueField: "v",
dataSource: [
{v: 1, t: "Apples"},
{v: 2, t: "Bananas"},
{v: 3, t: "Pears"},
{v: 4, t: "Watermelon"},
{v: 5, t: "Grapes"},
{v: 6, t: "Strawberries"}
]
})
})
</script>
</div>
</body>
</html>
File renamed without changes.

0 comments on commit 9288641

Please sign in to comment.