Update and add scenario's for testing interaction with new deferred container on context page and fix regressions

This commit is contained in:
Reinier Balt 2012-03-23 20:39:04 +01:00
parent dd957f0feb
commit 7435b1ba93
14 changed files with 161 additions and 112 deletions

View file

@ -82,16 +82,22 @@ Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_descripti
page.should_not have_xpath("//div[@id='tickler']//div[@id='line_todo_#{todo.id}']")
end
####### Project #######
Then /^I should see "([^"]*)" in the action container$/ do |todo_description|
Then /^I should (not see|see) "([^"]*)" in the action container$/ do |visible, todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']"
page.should have_xpath(xpath)
id = @source_view=="project" ? "p#{todo.project_id}items" : "c#{todo.context_id}items"
xpath = "//div[@id='#{id}']//div[@id='line_todo_#{todo.id}']"
page.send(visible=="see" ? :should : :should_not, have_xpath(xpath))
end
Then /^I should not see "([^"]*)" in the context container of "([^"]*)"$/ do |todo_description, context_name|
step "I should not see \"#{todo_description}\" in the action container"
end
####### Project #######
Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil

View file

@ -46,13 +46,19 @@ Given /^I have the following contexts$/ do |table|
step("I have the following contexts:", table)
end
Given /^I have a context "([^\"]*)" with (.*) actions$/ do |context_name, number_of_actions|
Given /^I have a context "([^\"]*)" with (\d+) (?:actions|todos)$/ do |context_name, number_of_actions|
context = @current_user.contexts.create!(:name => context_name)
@todos=[]
1.upto number_of_actions.to_i do |i|
@current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
@todos << @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
end
end
Given /^I have a context "([^\"]*)" with (\d+) deferred (?:actions|todos)$/ do |context_name, number_of_actions|
step "I have a context \"#{context_name}\" with #{number_of_actions} actions"
@todos.each {|todo| todo.description = "deferred "+todo.description; todo.show_from = Time.zone.now + 1.week; todo.save!}
end
When /^I edit the context name in place to be "([^\"]*)"$/ do |new_context_name|
page.find("span#context_name").click
fill_in "value", :with => new_context_name
@ -63,26 +69,15 @@ Then /^I should see the context name is "([^\"]*)"$/ do |context_name|
step "I should see \"#{context_name}\""
end
Then /^he should see that a context named "([^\"]*)" is present$/ do |context_name|
step "I should see \"#{context_name}\""
Then /^he should see that a context named "([^\"]*)" (is|is not) present$/ do |context_name, visible|
step "I should #{visible} \"#{context_name}\""
end
Then /^he should see that a context named "([^\"]*)" is not present$/ do |context_name|
step "I should not see \"#{context_name} (\""
end
Then /^I should not see empty message for todos of context/ do
page.should_not have_css("div#c#{@context.id}empty-nd", :visible=>true)
end
Then /^I should see empty message for todos of context/ do
page.should have_css("div#c#{@context.id}empty-nd", :visible => true)
end
Then /^I should not see empty message for completed todos of context$/ do
page.should_not have_css("div#empty-d", :visible=>true)
end
When /^I should see empty message for completed todos of context$/ do
page.should have_css("div#empty-d", :visible=>true)
end
Then /^I should (see|not see) empty message for (todo|completed todo|deferred todo)s of context/ do |visible, state|
css = "error"
css = "div#c#{@context.id}empty-nd" if state == "todo"
css = "div#empty-d" if state == "completed todo"
css = "div#tickler-empty-nd" if state == "deferred todo"
page.send(visible=="see" ? :should : :should_not, have_css(css, :visible=>true))
end

View file

@ -18,7 +18,7 @@ Given /^I have a project "([^"]*)" with (\d+) active actions and (\d+) deferred
step "I have a project \"#{name}\" with #{deferred_count} deferred todos"
end
Given /^I have a project "([^\"]*)" with ([0-9]+) (todo|active todo|deferred todo)s$/ do |project_name, num_todos, state|
Given /^I have a project "([^"]*)" with (\d+) (todo|active todo|deferred todo)s prefixed by "([^\"]*)"$/ do |project_name, num_todos, state, prefix|
@context = @current_user.contexts.find_or_create_by_name("Context A")
@project = @current_user.projects.find_or_create_by_name(project_name)
# acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this
@ -29,13 +29,17 @@ Given /^I have a project "([^\"]*)" with ([0-9]+) (todo|active todo|deferred tod
todo = @current_user.todos.create!(
:project_id => @project.id,
:context_id => @context.id,
:description => "#{state} #{i}")
:description => "#{prefix}#{state} #{i}")
todo.show_from = Time.zone.now + 1.week if state=="deferred todo"
todo.save!
@todos << todo
end
end
Given /^I have a project "([^"]*)" with (\d+) (todos|active todos|deferred todos)$/ do |project_name, num_todos, state|
step "I have a project \"#{project_name}\" with #{num_todos} #{state} prefixed by \"\""
end
Given /^there exists a project (?:|called )"([^"]*)" for user "([^"]*)"$/ do |project_name, user_name|
user = User.find_by_login(user_name)
user.should_not be_nil
@ -198,16 +202,10 @@ When /^I cancel adding a note to the project$/ do
end
Then /^I should (see|not see) empty message for (todos|deferred todos|completed todos) of project/ do |visible, state|
case state
when "todos"
css = "div#p#{@project.id}empty-nd"
when "deferred todos"
css = "div#tickler-empty-nd"
when "completed todos"
css = "div#empty-d"
else
css = "wrong state"
end
css = "wrong state"
css = "div#p#{@project.id}empty-nd" if state == "todos"
css = "div#tickler-empty-nd" if state == "deferred todos"
css = "div#empty-d" if state == "completed todos"
elem = find(css)
elem.should_not be_nil

View file

@ -20,7 +20,7 @@ Given /^I have a todo "([^"]*)" in the context "([^"]*)" which is due tomorrow$/
@todo.save!
end
Given /^I have (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names|
Given /^I have (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)" prefixed by "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names, prefix|
@context = @current_user.contexts.find_by_name(context_name)
@context.should_not be_nil
@ -29,13 +29,17 @@ Given /^I have (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "
@todos = []
number_of_todos.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => @context.id, :description => "todo #{i}", :project_id => @project.id)
todo = @current_user.todos.create!(:context_id => @context.id, :description => "#{prefix}todo #{i}", :project_id => @project.id)
todo.tag_with(tag_names)
todo.save!
@todos << todo
end
end
Given /^I have (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names|
step "I have #{number_of_todos} todos in project \"#{project_name}\" in context \"#{context_name}\" with tags \"#{tag_names}\" prefixed by \"\""
end
Given /^I have a todo "([^"]*)"$/ do |description|
step "I have a todo \"#{description}\" in the context \"Context A\""
end