Bump selenium-webdriver, implement aspect sorting cucumber step with selenium API
This commit is contained in:
parent
2ce7a1e185
commit
bf92a7441e
6 changed files with 22 additions and 35 deletions
7
Gemfile
7
Gemfile
|
|
@ -261,12 +261,7 @@ group :test do
|
|||
|
||||
gem "capybara", "2.4.4"
|
||||
gem "database_cleaner" , "1.4.1"
|
||||
gem "selenium-webdriver", "2.46.2"
|
||||
|
||||
source "https://rails-assets.org" do
|
||||
gem "rails-assets-jquery-simulate", "1.0.1"
|
||||
gem "rails-assets-jquery-simulate-ext", "1.3.0"
|
||||
end
|
||||
gem "selenium-webdriver", "2.47.1"
|
||||
|
||||
# General helpers
|
||||
|
||||
|
|
|
|||
|
|
@ -541,9 +541,6 @@ GEM
|
|||
rails-assets-jquery-fullscreen-plugin (0.5.0)
|
||||
rails-assets-jquery-placeholder (2.1.2)
|
||||
rails-assets-jquery (>= 1.6)
|
||||
rails-assets-jquery-simulate (1.0.1)
|
||||
rails-assets-jquery-simulate-ext (1.3.0)
|
||||
rails-assets-jquery (>= 1.7.0)
|
||||
rails-assets-jquery-textchange (0.2.3)
|
||||
rails-assets-jquery
|
||||
rails-assets-jquery.slimscroll (1.3.6)
|
||||
|
|
@ -648,7 +645,7 @@ GEM
|
|||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (~> 1.1)
|
||||
selenium-webdriver (2.46.2)
|
||||
selenium-webdriver (2.47.1)
|
||||
childprocess (~> 0.5)
|
||||
multi_json (~> 1.0)
|
||||
rubyzip (~> 1.0)
|
||||
|
|
@ -831,8 +828,6 @@ DEPENDENCIES
|
|||
rails-assets-jeresig--jquery.hotkeys (= 0.2.0)!
|
||||
rails-assets-jquery (= 1.11.2)!
|
||||
rails-assets-jquery-placeholder (= 2.1.2)!
|
||||
rails-assets-jquery-simulate (= 1.0.1)!
|
||||
rails-assets-jquery-simulate-ext (= 1.3.0)!
|
||||
rails-assets-jquery-textchange (= 0.2.3)!
|
||||
rails-assets-markdown-it (= 4.4.0)!
|
||||
rails-assets-markdown-it--markdown-it-for-inline (= 0.1.1)!
|
||||
|
|
@ -857,7 +852,7 @@ DEPENDENCIES
|
|||
ruby-oembed (= 0.8.14)
|
||||
rubyzip (= 1.1.7)
|
||||
sass-rails (= 5.0.1)
|
||||
selenium-webdriver (= 2.46.2)
|
||||
selenium-webdriver (= 2.47.1)
|
||||
shoulda-matchers (= 2.8.0)
|
||||
sidekiq (= 3.4.2)
|
||||
sidetiq (= 0.6.3)
|
||||
|
|
|
|||
|
|
@ -81,11 +81,11 @@ app.pages.Contacts = Backbone.View.extend({
|
|||
$("#aspect_nav .nav").sortable({
|
||||
items: "li.aspect[data-aspect-id]",
|
||||
update: function() {
|
||||
$("#aspect_nav .ui-sortable").removeClass("synced");
|
||||
$("#aspect_nav .ui-sortable").addClass("syncing");
|
||||
var data = JSON.stringify({ ordered_aspect_ids: $(this).sortable("toArray", { attribute: "data-aspect-id" }) });
|
||||
$.ajax(Routes.orderAspects(),
|
||||
{ type: "put", dataType: "text", contentType: "application/json", data: data })
|
||||
.done(function() { $("#aspect_nav .ui-sortable").addClass("synced"); });
|
||||
.done(function() { $("#aspect_nav .ui-sortable").removeClass("syncing"); });
|
||||
},
|
||||
revert: true,
|
||||
helper: "clone"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#aspect_nav
|
||||
%ul.nav.nav-tabs.nav-stacked.synced
|
||||
%ul.nav.nav-tabs.nav-stacked.ui-sortable
|
||||
%li.all_contacts{:class => ("active" if params["set"] == "all")}
|
||||
%a{:href => contacts_path(:set => "all")}
|
||||
= t('contacts.index.all_contacts')
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ Feature: User manages contacts
|
|||
And I have an aspect called "People"
|
||||
And I have an aspect called "Cat People"
|
||||
When I am on the contacts page
|
||||
And I drag "Cat People" up 40 pixels
|
||||
And I drag "Cat People" up
|
||||
And I go to the contacts page
|
||||
Then I should see "Cat People" as 2. aspect
|
||||
And I should see "People" as 3. aspect
|
||||
|
|
|
|||
|
|
@ -88,24 +88,21 @@ When /^(.*) in the aspect creation modal$/ do |action|
|
|||
end
|
||||
end
|
||||
|
||||
When /^I drag "([^"]*)" (up|down) (\d+) pixels?$/ do |aspect_name, direction, distance|
|
||||
distance = distance.to_i * -1 if direction == "up"
|
||||
page.execute_script %{
|
||||
function drag() {
|
||||
$("li.aspect:contains('#{aspect_name}')")
|
||||
.simulate("drag-n-drop", { dy: #{distance}, interpolation: { stepWidth: 10, stepDelay: 5 } });
|
||||
}
|
||||
function loadScripts() {
|
||||
$.getScript("/assets/jquery-simulate/jquery.simulate.js", function(){
|
||||
$.getScript("/assets/jquery-simulate-ext/src/jquery.simulate.ext.js", function(){
|
||||
$.getScript("/assets/jquery-simulate-ext/src/jquery.simulate.drag-n-drop.js", drag);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (!$.simulate) { loadScripts(); } else { drag(); }
|
||||
}
|
||||
expect(find("#aspect_nav")).to have_css ".synced"
|
||||
end
|
||||
When /^I drag "([^"]*)" (up|down)$/ do |aspect_name, direction|
|
||||
aspect_id = @me.aspects.where(name: aspect_name).first.id
|
||||
aspect = find(:xpath, "//div[@id='aspect_nav']/ul/li[@data-aspect-id='#{aspect_id}']")
|
||||
target = direction == "up" ? aspect.all(:xpath, "./preceding-sibling::li").last :
|
||||
aspect.all(:xpath, "./following-sibling::li").first
|
||||
browser = aspect.base.driver.browser
|
||||
mouse = browser.mouse
|
||||
native_aspect = aspect.base.native
|
||||
native_target = target.base.native
|
||||
mouse.down native_aspect
|
||||
mouse.move_to native_target, native_target.size.width / 2, 0
|
||||
sleep 1
|
||||
mouse.up
|
||||
expect(page).to have_no_css "#aspect_nav .ui-sortable.syncing"
|
||||
end
|
||||
|
||||
And /^I toggle the aspect "([^"]*)"$/ do |name|
|
||||
toggle_aspect(name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue