From 96f510abd4984c4b0c64d438fe19539699127cf7 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Tue, 13 Oct 2009 22:34:37 -0400 Subject: [PATCH] ALL SELENIUM TESTS PASSING!! Caught a couple of things that I had to fix plus a handful of broken tests. This is the first time in forever that we have a fully successful selenium suite. --- app/helpers/todos_helper.rb | 7 ++++--- app/views/projects/_project.rhtml | 2 +- app/views/projects/update.js.rjs | 1 + app/views/projects/update_project_name.js.rjs | 4 +--- public/javascripts/application.js | 18 ++++++++++-------- ...ect_name_should_change_default_project.rsel | 12 ++++++------ .../count_actions_in_hidden_project.rsel | 8 +++++--- .../project_detail/in_place_edit_name.rsel | 15 +++++++++------ test/selenium/tags/badge_count.rsel | 2 +- ..._starred_tags_without_anything_starred.rsel | 2 +- 10 files changed, 39 insertions(+), 32 deletions(-) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index a86eade7..fca29a59 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -25,7 +25,7 @@ module TodosHelper def remote_edit_menu_item(parameters, todo) return link_to_remote( - image_tag("edit_off.png", :mouseover => "edit_on.png", :alt => "", :align => "absmiddle", :id => 'edit_icon_todo_'+todo.id.to_s)+" Edit", + image_tag("edit_off.png", :mouseover => "edit_on.png", :alt => "Edit", :align => "absmiddle", :id => 'edit_icon_todo_'+todo.id.to_s)+" Edit", :url => {:controller => 'todos', :action => 'edit', :id => todo.id}, :method => 'get', :with => "'#{parameters}'", @@ -35,12 +35,13 @@ module TodosHelper def remote_delete_menu_item(parameters, todo) return link_to_remote( - image_tag("delete_off.png", :mouseover => "delete_on.png", :alt => "", :align => "absmiddle")+" Delete", + image_tag("delete_off.png", :mouseover => "delete_on.png", :alt => "Delete", :align => "absmiddle")+" Delete", :url => {:controller => 'todos', :action => 'destroy', :id => todo.id}, :method => 'delete', :with => "'#{parameters}'", :before => todo_start_waiting_js(todo), - :complete => todo_stop_waiting_js(todo)) + :complete => todo_stop_waiting_js(todo), + :confirm => "Are you sure that you want to delete the action '#{todo.description}'?") end def remote_defer_menu_item(days, todo) diff --git a/app/views/projects/_project.rhtml b/app/views/projects/_project.rhtml index 14e12002..e0bad6d2 100644 --- a/app/views/projects/_project.rhtml +++ b/app/views/projects/_project.rhtml @@ -1,5 +1,5 @@
-

+

<% if collapsible -%> <%= image_tag("collapse.png") %> <% end -%> diff --git a/app/views/projects/update.js.rjs b/app/views/projects/update.js.rjs index eee8534f..a38b79d4 100644 --- a/app/views/projects/update.js.rjs +++ b/app/views/projects/update.js.rjs @@ -22,6 +22,7 @@ else page << "$('#todo_context_name').val('#{@project.default_context.name}');" if @project.default_context page << "$('input[name=default_context_name]').val('#{@project.default_context.name}');" if @project.default_context + page << "$('#todo_project_name').val('#{@project.name}');" page << "defaultContexts = #{default_contexts_for_autocomplete};" page << "defaultTags = #{default_tags_for_autocomplete};" end diff --git a/app/views/projects/update_project_name.js.rjs b/app/views/projects/update_project_name.js.rjs index e643738b..6f8316cf 100644 --- a/app/views/projects/update_project_name.js.rjs +++ b/app/views/projects/update_project_name.js.rjs @@ -1,10 +1,8 @@ -page['project_name_in_place_editor'].replace_html @project.name - page['default_project_name_id'].value = @project.name page['todo_project_name'].value = @project.name # renew project auto complete array -page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}; projectAutoCompleter.changed = true" +page << "var projectNames = #{project_names_for_autocomplete};" status_message = "Name of project was changed" page.notify :notice, status_message, 5.0 diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 4ac84489..bf2cbb64 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -378,6 +378,15 @@ $(document).ready(function() { }, {style: 'padding:0px', submit: "OK"}); /* Projects behavior */ + $('h2#project_name').editable(function(value, settings){ + project_id = $(this).parents('.container').children('div').get(0).id.split('_')[2]; + highlight = function(){ + $('h2#project_name').effect('highlight', {}, 500); + }; + $.post('/projects/update/'+project_id, {'project[name]': value, 'update_project_name': 'true'}, highlight, 'script'); + return(value); + }, {style: 'padding:0px', submit: "OK"}); + $('.alphabetize_link').click(function(evt){ evt.preventDefault(); if(confirm('Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order.')){ @@ -428,14 +437,7 @@ $(document).ready(function() { '« Hide form', 'Hide new context form', 'Create a new context »', 'Add a context'); }); - $('a.delete_project_button').live('click', function(evt){ - evt.preventDefault(); - if(confirm("Are you sure that you want to "+this.title+"?")){ - $(this).parents('.context').block({message: null}); - params = {_method: 'delete'}; - $.post(this.href, params, null, 'script'); - } - }); + $("#list-contexts-active").sortable({handle: '.handle', update: update_order}); $("#list-contexts-hidden").sortable({handle: '.handle', update: update_order}); /* diff --git a/test/selenium/project_detail/changing_project_name_should_change_default_project.rsel b/test/selenium/project_detail/changing_project_name_should_change_default_project.rsel index e78dcd21..d42d74d3 100644 --- a/test/selenium/project_detail/changing_project_name_should_change_default_project.rsel +++ b/test/selenium/project_detail/changing_project_name_should_change_default_project.rsel @@ -3,11 +3,11 @@ login :as => 'admin' open "/projects/1" # change project name -click "project_name_in_place_editor" -wait_for_element_present "css=#project_name_in_place_editor-inplaceeditor input.editor_field" -type "css=#project_name_in_place_editor-inplaceeditor input.editor_field", "Test Foo" -click "css=#project_name_in_place_editor-inplaceeditor input.editor_ok_button" -wait_for_text "project_name_in_place_editor", "Test Foo" +click "project_name" +wait_for_element_present "css=#project_name form input" +type "css=#project_name form input", "Test Foo" +click "css=#project_name form button" +wait_for_text "project_name", "Test Foo" # check that the default project name is changed too -assert_value "todo_project_name", "Test Foo" \ No newline at end of file +wait_for_value "todo_project_name", "Test Foo" diff --git a/test/selenium/project_detail/count_actions_in_hidden_project.rsel b/test/selenium/project_detail/count_actions_in_hidden_project.rsel index f4bbd9e6..233b4c93 100644 --- a/test/selenium/project_detail/count_actions_in_hidden_project.rsel +++ b/test/selenium/project_detail/count_actions_in_hidden_project.rsel @@ -2,9 +2,11 @@ setup :fixtures => :all login :as => 'admin' open '/projects/1' assert_text 'badge_count', '2' +click 'css=.project_settings a' +wait_for_visible "project[default_context_name]" click 'project_state_hidden' -wait_for_attribute 'css=#project_status .active span', 'class', 'inactive_state' -wait_for_attribute 'css=#project_status .hidden span', 'class', 'active_state' +click 'css=.positive' +wait_for_text_present 'marked as hidden' assert_text 'badge_count', '2' type "todo_description", "add one to hidden project 1" @@ -20,4 +22,4 @@ assert_text 'badge_count', '4' open '/projects/1' assert_text 'badge_count', '4' -assert_checked 'project_state_hidden' +assert_text_present 'marked as hidden' diff --git a/test/selenium/project_detail/in_place_edit_name.rsel b/test/selenium/project_detail/in_place_edit_name.rsel index 53e3f041..05be914a 100644 --- a/test/selenium/project_detail/in_place_edit_name.rsel +++ b/test/selenium/project_detail/in_place_edit_name.rsel @@ -1,10 +1,13 @@ setup :fixtures => :all login :as => 'admin' open "/projects/1" -click "project_name_in_place_editor" -wait_for_element_present "css=#project_name_in_place_editor-inplaceeditor input.editor_field" -type "css=#project_name_in_place_editor-inplaceeditor input.editor_field", "Test Foo" -click "css=#project_name_in_place_editor-inplaceeditor input.editor_ok_button" -wait_for_text "project_name_in_place_editor", "Test Foo" + +click "project_name" +wait_for_element_present "css=#project_name form input" +type "css=#project_name form input", "Test Foo" +click "css=#project_name form button" +wait_for_text "project_name", "Test Foo" + + open "/projects/1" -wait_for_text "project_name_in_place_editor", "Test Foo" +wait_for_text "project_name", "Test Foo" diff --git a/test/selenium/tags/badge_count.rsel b/test/selenium/tags/badge_count.rsel index 4359059d..ae441110 100644 --- a/test/selenium/tags/badge_count.rsel +++ b/test/selenium/tags/badge_count.rsel @@ -3,7 +3,7 @@ login :as => 'admin' open "/todos/tag/foo" assert_text 'badge_count', '2' -click "css=#delete_icon_2" +click "css=#ultodo_2 img[alt='Delete']" assert_confirmation "Are you sure that you want to delete the action 'Call dinosaur exterminator'?" wait_for_element_not_present "todo_2" diff --git a/test/selenium/tags/open_starred_tags_without_anything_starred.rsel b/test/selenium/tags/open_starred_tags_without_anything_starred.rsel index de8fbeda..6aaf5812 100644 --- a/test/selenium/tags/open_starred_tags_without_anything_starred.rsel +++ b/test/selenium/tags/open_starred_tags_without_anything_starred.rsel @@ -1,6 +1,6 @@ setup :fixtures => [:users, :projects, :contexts, :todos, :notes] login :as => 'admin' open "/" -click_and_wait "xpath=//ul[@id='navlist'] //a[@title='See your starred actions']" +click_and_wait "xpath=//a[@title='See your starred actions']" assert_title "exact:TRACKS::Tagged with 'starred'" verify_text_present "Currently there are no incomplete actions with the tag 'starred'"