From 92886411374ecc8d2ac5ee6624b991dced708741 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Tue, 23 Jun 2015 13:47:24 -0400 Subject: [PATCH] added tests surrounding kendo edge case with endless loop finding fixed content --- app/js/api/cypress/cy/commands/actions.coffee | 10 +++-- .../api/cypress/cy/commands/querying.coffee | 2 +- bower.json | 3 +- .../client/api/integration/clicks_spec.coffee | 29 ++++++++++-- spec/client/spec_helper.coffee | 9 ++-- spec/fixtures/html/dropdown.html | 44 +++++++++++++++++++ .../html/{clicks.html => fixed-nav.html} | 0 7 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 spec/fixtures/html/dropdown.html rename spec/fixtures/html/{clicks.html => fixed-nav.html} (100%) diff --git a/app/js/api/cypress/cy/commands/actions.coffee b/app/js/api/cypress/cy/commands/actions.coffee index b4a4cf76c6f8..82c23559f1a9 100644 --- a/app/js/api/cypress/cy/commands/actions.coffee +++ b/app/js/api/cypress/cy/commands/actions.coffee @@ -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() @@ -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 @@ -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) diff --git a/app/js/api/cypress/cy/commands/querying.coffee b/app/js/api/cypress/cy/commands/querying.coffee index 49ceea9cd684..fef49cf07f56 100644 --- a/app/js/api/cypress/cy/commands/querying.coffee +++ b/app/js/api/cypress/cy/commands/querying.coffee @@ -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 diff --git a/bower.json b/bower.json index 0358f22520fa..a948fa980995 100644 --- a/bower.json +++ b/bower.json @@ -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" } } diff --git a/spec/client/api/integration/clicks_spec.coffee b/spec/client/api/integration/clicks_spec.coffee index d6ab7fd460aa..e8c2f969c141 100644 --- a/spec/client/api/integration/clicks_spec.coffee +++ b/spec/client/api/integration/clicks_spec.coffee @@ -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() \ No newline at end of file + 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" diff --git a/spec/client/spec_helper.coffee b/spec/client/spec_helper.coffee index 6112d14b3258..403cb3d25aa6 100644 --- a/spec/client/spec_helper.coffee +++ b/spec/client/spec_helper.coffee @@ -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) diff --git a/spec/fixtures/html/dropdown.html b/spec/fixtures/html/dropdown.html new file mode 100644 index 000000000000..961eb1ac54bb --- /dev/null +++ b/spec/fixtures/html/dropdown.html @@ -0,0 +1,44 @@ + + + + DOM Fixture + + + + +
+ + + + + + + + + +
+ + \ No newline at end of file diff --git a/spec/fixtures/html/clicks.html b/spec/fixtures/html/fixed-nav.html similarity index 100% rename from spec/fixtures/html/clicks.html rename to spec/fixtures/html/fixed-nav.html