From 8dbf790810e8f2b91e6f20d3897d9f32fb801ef7 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 24 Mar 2010 17:58:15 +0100 Subject: [PATCH] fix cucumber story for drag and drop for dependencies. Was broken since last change of drop target to a hidden img that appears when dragging starts not a trivial one to fix :-) --- app/helpers/todos_helper.rb | 2 +- features/step_definitions/todo_steps.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 8eafc567..494608b5 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -122,7 +122,7 @@ module TodosHelper :title => 'Drag onto another action to make it depend on that action', :class => 'grip') + image_tag('blank.png', :width => 16, :height => 16, :border => 0, - :title => "Drop an action to make it depend on this action", :class => 'successor_target') + :id => "successor_target_#{@todo.id}", :title => "Drop an action to make it depend on this action", :class => 'successor_target') end end diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 54fec93c..82d73cdd 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -37,8 +37,13 @@ When /^I drag "(.*)" to "(.*)"$/ do |dragged, target| drag_id = Todo.find_by_description(dragged).id drop_id = Todo.find_by_description(target).id drag_name = "xpath=//div[@id='line_todo_#{drag_id}']//img[@class='grip']" - drop_name = "xpath=//div[@id='line_todo_#{drop_id}']//div[@class='description']" - + drop_name = "xpath=//div[@id='line_todo_#{drop_id}']//img[@id='successor_target_#{drop_id}']" + + # the target img is hidden until drag starts. We need to show the img or the + # xpath will not find it + js="$('img#successor_target_#{drop_id}').show();" + selenium.get_eval "(function() {with(this) {#{js}}}).call(selenium.browserbot.getCurrentWindow());" + selenium.drag_and_drop_to_object(drag_name, drop_name) arrow = "xpath=//div[@id='line_todo_#{drop_id}']/div/a[@class='show_successors']/img"