implement new scenarios that were pending from the selenium-on-rails removal and fix a bug it uncovered

This commit is contained in:
Reinier Balt 2011-09-14 20:50:21 +02:00
parent 9eca1557fb
commit 2563532022
6 changed files with 103 additions and 23 deletions

View file

@ -6,7 +6,6 @@
-%>
update_project_page();
<% end %>
TracksForm.set_project_name_and_default_project_name("<%= escape_javascript(@project.name)%>");
<% else -%>
TracksPages.show_edit_errors(html_for_error_messages());
<% end %>
@ -24,12 +23,14 @@ function update_project_list_page() {
ProjectListPage.update_all_states_count(<%=@active_projects_count%>, <%=@hidden_projects_count%>, <%=@completed_projects_count%>);
ProjectListPage.show_or_hide_all_state_containers(<%= @show_active_projects %>, <%= @show_hidden_projects %>, <%= @show_completed_projects %>);
TracksForm.set_project_name_and_default_project_name("<%= escape_javascript(@project.name)%>");
}
function update_project_page() {
remove_project_edit_form();
update_and_show_project_settings();
TracksForm.set_project_name("<%= escape_javascript(@project.name)%>");
$("h2#project_name").html("<%= escape_javascript(@project.name)%>");
<% if @project.default_context %>
TracksForm.set_context_name_and_default_context_name("<%= escape_javascript(@project.default_context.name)%>");
<% end %>
@ -75,7 +76,7 @@ function remove_and_re_add_project() {
<%
# the following functions return empty string if rendering the partial is not
# necessary, for example the sidebar is not on the project list page, so do not
# render it into the function.
# render it into the function.
-%>
function html_for_project_listing() {
return "<%= source_view_is(:project_list) ? escape_javascript(render(:partial => 'project_listing', :object => @project )) : "" %>";

View file

@ -41,7 +41,7 @@ Feature: Edit a project
And I edit the project name to "cherries"
Then the project title should be "cherries"
@selenium @wip
@selenium
Scenario: I can change the name of the project and it should update the new todo form
Given I have a project "bananas" with 1 todos
When I go to the "bananas" project
@ -49,7 +49,7 @@ Feature: Edit a project
Then the project title should be "cherries"
And the project field of the new todo form should contain "cherries"
@selenium @wip
@selenium
Scenario: I can change the default context of the project and it should update the new todo form
Given I have a project "bananas" with 1 todos
When I go to the "bananas" project
@ -110,28 +110,28 @@ Feature: Edit a project
When I cancel the project edit form
Then I should see "This project is active with no default context and with no default tags"
@selenium @wip
@selenium
Scenario: Moving the todo to the tickler will move todo to tickler container and update empty messages
Given I have a project "test" with 1 todos
When I go to the "test" project
Then I should see "todo 1" in the action container
And I should see "Currently there are no deferred actions in this project"
And I should see "Currently there are no deferred or pending actions"
And I should not see "Currently there are no incomplete actions in this project"
When I defer "todo 1" for 1 day
Then I should see "todo 1" in the deferred container
And I should not see "Currently there are no deferred actions in this project"
And I should not see "Currently there are no deferred or pending actions"
And I should see "Currently there are no incomplete actions in this project"
@selenium @wip
@selenium
Scenario: Moving the todo out of the tickler will move todo to active container and update empty messages
Given I have a project "test" with 1 deferred todos
When I go to the "test" project
Then I should see "todo 1" in the deferred container
And I should see "Currently there are no incomplete actions in this project"
And I should not see "Currently there are no deferred actions in this project"
When I defer "todo 1" for 1 day
Then I should see "todo 1" in the active container
And I should see "Currently there are no deferred actions in this project"
And I should not see "Currently there are no deferred or pending actions"
When I clear the show from date of "todo 1"
Then I should see "todo 1" in the action container
And I should see "Currently there are no deferred or pending actions"
And I should not see "Currently there are no incomplete actions in this project"
@selenium
@ -141,7 +141,7 @@ Feature: Edit a project
And I mark "todo 1" as complete
Then I should see "Currently there are no incomplete actions in this project"
@selenium @wip
@selenium
Scenario: Making all deferred todos inactive will show empty message
Given I have a project "test" with 1 deferred todos
When I go to the "test" project

View file

@ -1,14 +1,24 @@
Given /^I have a project "([^\"]*)" with (.*) todos$/ do |project_name, num_todos|
Given /^I have a project "([^\"]*)" with ([0-9]+) todos$/ do |project_name, num_todos|
@context = @current_user.contexts.find_or_create_by_name("Context A")
@project = @current_user.projects.create!(:name => project_name)
# acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this
@project.move_to_bottom
@todos=[]
1.upto num_todos.to_i do |i|
@current_user.todos.create!(
todo = @current_user.todos.create!(
:project_id => @project.id,
:context_id => @context.id,
:description => "todo #{i}")
@todos << todo
end
end
Given /^I have a project "([^\"]*)" with ([0-9]+) deferred todos$/ do |project_name, num_todos|
Given "I have a project \"#{project_name}\" with #{num_todos} todos"
@todos.each do |todo|
todo.show_from = Time.zone.now + 1.week
todo.save!
end
end
@ -130,6 +140,44 @@ When /^I try to edit the project name to "([^\"]*)"$/ do |new_title|
:timeout => 5
end
When /^I edit the default context to "([^"]*)"$/ do |default_context|
click_link "link_edit_project_#{@project.id}"
wait_for do
selenium.is_element_present("submit_project_#{@project.id}")
end
fill_in "project[default_context_name]", :with => default_context
selenium.click "submit_project_#{@project.id}",
:wait_for => :text,
:text => "Project saved",
:timeout => 5
wait_for :timeout => 5 do
!selenium.is_element_present("submit_project_#{@project.id}")
end
end
Then /^I edit the default tags to "([^"]*)"$/ do |default_tags|
click_link "link_edit_project_#{@project.id}"
wait_for do
selenium.is_element_present("submit_project_#{@project.id}")
end
fill_in "project[default_tags]", :with => default_tags
selenium.click "submit_project_#{@project.id}",
:wait_for => :text,
:text => "Project saved",
:timeout => 5
wait_for :timeout => 5 do
!selenium.is_element_present("submit_project_#{@project.id}")
end
end
When /^I edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name|
@project = @current_user.projects.find_by_name(project_current_name)
@project.should_not be_nil
@ -225,7 +273,9 @@ Then /^I should see the italic text "([^\"]*)" in the project description$/ do |
end
Then /^the project title should be "(.*)"$/ do |title|
selenium.get_text("css=h2#project_name").should == title
wait_for :timeout => 2 do
selenium.get_text("css=h2#project_name") == title
end
end
Then /^I should see the project name is "([^"]*)"$/ do |project_name|

View file

@ -139,6 +139,10 @@ When /^I remove the show from date from "([^"]*)"$/ do |action_description|
submit_edit_todo_form(todo)
end
When /^I clear the show from date of "([^"]*)"$/ do |action_description|
When "I remove the show from date from \"#{action_description}\""
end
When /^I defer "([^"]*)" for 1 day$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil

View file

@ -96,7 +96,6 @@ Then /^the selected context should be "([^"]*)"$/ do |content|
field_labeled("Context").element.search(".//option[@selected = 'selected']").inner_html.should =~ /#{content}/
end
Then /^I should see the page selector$/ do
page_selector_xpath = ".//a[@class='next_page']"
response.body.should have_xpath(page_selector_xpath)
@ -110,3 +109,30 @@ Then /^the page should be "([^"]*)"$/ do |page_number|
end
page_number_found.should == page_number.to_i
end
Then /^the project field of the new todo form should contain "([^"]*)"$/ do |project_name|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_project_name']"
project_name.should == response.selenium.get_value("xpath=#{xpath}")
end
Then /^the default context of the new todo form should be "([^"]*)"$/ do |context_name|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_context_name']"
context_name.should == response.selenium.get_value("xpath=#{xpath}")
end
Then /^the tag field in the new todo form should be empty$/ do
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_tag_list']"
assert response.selenium.get_value("xpath=#{xpath}").blank?
end
Then /^the tag field in the new todo form should be "([^"]*)"$/ do |tag_list|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_tag_list']"
tag_list.should == response.selenium.get_value("xpath=#{xpath}")
end
Then /^the tags of "([^"]*)" should be "([^"]*)"$/ do |todo_description, tag_list|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
todo.tag_list.should == tag_list
end

View file

@ -11,7 +11,6 @@ Feature: Tagging todos
And I have a context called "@pc"
And I have a project called "hacking tracks"
@wip
Scenario: If there are no todos with a tag, the tag page should show an empty message
When I go to the tag page for "starred"
Then I should see "Currently there are no incomplete actions with the tag 'starred'"
@ -56,7 +55,7 @@ Feature: Tagging todos
Then I should not see "prepare release" in the context container for "@pc"
Then I should see "prepare release" in the hidden container
@selenium @wip
@selenium
Scenario: Completing the last todo from the tag view will show the empty message
Given I have a todo "migrate old scripts" in context "@pc" with tags "starred"
When I go to the tag page for "starred"
@ -65,15 +64,15 @@ Feature: Tagging todos
Then I should not see the context container for "@pc"
And I should see "Currently there are no incomplete actions with the tag 'starred'"
@selenium @wip
@selenium
Scenario: Setting default tags for a project will prefill new todo form for that project
When I go to the project page for "hacking tracks"
When I go to the "hacking tracks" project
Then the tag field in the new todo form should be empty
And I edit the default tags to "tests"
Then the tag field in the new todo form should be "tests"
# also the tag field should be prefilled after reload
When I go to the project page for "hacking tracks"
Then the tag field in the new todo form shoudl be "tests"
When I go to the "hacking tracks" project
Then the tag field in the new todo form should be "tests"
# and the tag field should be prefilled after submitting a new todo
When I submit a new action with description "are my tags prefilled"
Then the tags of "are my tags prefilled" should be "tests"