Introduce selenium tests to help get the ajax interactions correct and maintainable.

Start to improve the ajax interactions around the new deferred actions section on the project detail page
Add a README for developers describing how to run the selenium tests.


git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@387 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-01-02 00:19:57 +00:00
parent 71df0f1061
commit bde8a0bde0
170 changed files with 35512 additions and 25 deletions

View file

@ -100,20 +100,25 @@ class TodoController < ApplicationController
@item = check_user_return_item
@item.toggle_completion()
@saved = @item.save
if @saved
@remaining_undone_in_context = @user.contexts.find(@item.context_id).not_done_todo_count
determine_down_count
determine_completed_count
end
return if request.xhr?
if @saved
# TODO: I think this will work, but can't figure out how to test it
notify :notice, "The action <strong>'#{@item.description}'</strong> was marked as <strong>#{@item.completed? ? 'complete' : 'incomplete' }</strong>"
redirect_to :action => "index"
else
notify :notice, "The action <strong>'#{@item.description}'</strong> was NOT marked as <strong>#{@item.completed? ? 'complete' : 'incomplete' } due to an error on the server.</strong>", "index"
redirect_to :action => "index"
respond_to do |format|
format.js do
if @saved
@remaining_undone_in_context = @user.contexts.find(@item.context_id).not_done_todo_count
determine_down_count
determine_completed_count
end
render
end
format.html do
if @saved
# TODO: I think this will work, but can't figure out how to test it
notify :notice, "The action <strong>'#{@item.description}'</strong> was marked as <strong>#{@item.completed? ? 'complete' : 'incomplete' }</strong>"
redirect_to :action => "index"
else
notify :notice, "The action <strong>'#{@item.description}'</strong> was NOT marked as <strong>#{@item.completed? ? 'complete' : 'incomplete' } due to an error on the server.</strong>", "index"
redirect_to :action => "index"
end
end
end
end

View file

@ -96,9 +96,20 @@ module TodoHelper
def item_container_id
return "tickler-items" if source_view_is :deferred
return "p#{@item.project_id}" if source_view_is :project
if source_view_is :project
return "p#{@item.project_id}" if @item.active?
return "tickler" if @item.deferred?
end
return "c#{@item.context_id}"
end
def should_show_new_item
return true if source_view_is(:deferred) && @item.deferred?
return true if source_view_is(:project) && @item.project.hidden? && @item.project_hidden?
return true if source_view_is(:project) && @item.deferred?
return true if !source_view_is(:deferred) && @item.active?
return false
end
def parent_container_type
return 'tickler' if source_view_is :deferred
@ -107,10 +118,10 @@ module TodoHelper
end
def empty_container_msg_div_id
return "tickler-empty-nd" if source_view_is(:project) && @item.deferred?
return "p#{@item.project_id}empty-nd" if source_view_is :project
return "c#{@item.context_id}empty-nd" if source_view_is :context
return "tickler-empty-nd" if source_view_is :deferred
nil
return "c#{@item.context_id}empty-nd"
end
def project_names_for_autocomplete

View file

@ -9,11 +9,7 @@ if @saved
page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')"
page << "contextAutoCompleter.options.array = #{context_names_for_autocomplete}" if @new_context_created
page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}" if @new_project_created
show_new_item = false
show_new_item = true if source_view_is(:deferred) && @item.deferred?
show_new_item = true if source_view_is(:project) && @item.project.hidden? && @item.project_hidden?
show_new_item = true if !source_view_is(:deferred) && @item.active?
if show_new_item
if should_show_new_item()
if @new_context_created
page.insert_html :top, 'display_box', :partial => 'context/context', :locals => { :context => @item.context, :collapsible => true }
else

View file

@ -6,7 +6,8 @@ if @saved
page.insert_html :top, "completed", :partial => 'todo/item', :locals => { :parent_container_type => "completed" }
page.visual_effect :highlight, dom_id(@item, 'line'), {'startcolor' => "'#99ff99'"}
page[empty_container_msg_div_id].show if @down_count == 0 && !empty_container_msg_div_id.nil?
page.hide "empty-d" # If we've checked something as done, completed items can't be empty
page.show 'tickler-empty-nd' if source_view_is(:project)
page.hide 'empty-d' # If we've checked something as done, completed items can't be empty
end
if @remaining_undone_in_context == 0 && source_view_is(:todo)
page.visual_effect :fade, item_container_id, :duration => 0.4
@ -19,7 +20,7 @@ if @saved
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? # If we've checked something as undone, uncompleted items can't be empty
end
page.hide "status"
page.replace_html "badge_count", @down_count
page.replace_html "badge_count", @down_count
else
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")
end

View file

@ -33,10 +33,16 @@ if @saved
page.visual_effect :highlight, dom_id(@item), :duration => 3
end
elsif source_view_is :project
if @project_changed || @item.deferred?
if @project_changed
page[@item].remove
page.show("p#{@original_item_project_id}empty-nd") if (@remaining_undone_in_project == 0)
page.replace_html "badge_count", @remaining_undone_in_project
elsif @item.deferred?
page[@item].remove
page.show("p#{@original_item_project_id}empty-nd") if (@remaining_undone_in_project == 0)
page.insert_html :bottom, "tickler", :partial => 'todo/item', :locals => { :parent_container_type => parent_container_type }
page['tickler-empty-nd'].hide
page.replace_html "badge_count", @remaining_undone_in_project
else
page.replace dom_id(@item), :partial => 'todo/item', :locals => { :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(@item), :duration => 3