2011-09-10 00:51:39 +02:00
|
|
|
When /^I collapse the context container of "([^"]*)"$/ do |context_name|
|
2013-02-27 20:02:01 +01:00
|
|
|
context = @current_user.contexts.where(:name => context_name).first
|
2011-09-10 00:51:39 +02:00
|
|
|
context.should_not be_nil
|
|
|
|
|
|
|
|
|
|
xpath = "//a[@id='toggle_c#{context.id}']"
|
2012-03-12 22:52:45 +01:00
|
|
|
toggle = page.find(:xpath, xpath)
|
|
|
|
|
toggle.should be_visible
|
|
|
|
|
toggle.click
|
2011-09-10 00:51:39 +02:00
|
|
|
end
|
|
|
|
|
|
2013-03-18 13:33:30 +01:00
|
|
|
When(/^I collapse the project container of "(.*?)"$/) do |project_name|
|
|
|
|
|
project = @current_user.projects.where(:name => project_name).first
|
|
|
|
|
project.should_not be_nil
|
|
|
|
|
|
|
|
|
|
xpath = "//a[@id='toggle_p#{project.id}']"
|
|
|
|
|
toggle = page.find(:xpath, xpath)
|
|
|
|
|
toggle.should be_visible
|
|
|
|
|
toggle.click
|
|
|
|
|
end
|
|
|
|
|
|
2011-09-10 00:51:39 +02:00
|
|
|
When /^I toggle all collapsed context containers$/ do
|
|
|
|
|
click_link 'Toggle collapsed contexts'
|
|
|
|
|
end
|
|
|
|
|
|
2011-08-18 17:15:00 +02:00
|
|
|
####### Context #######
|
|
|
|
|
|
2011-04-14 16:26:16 +02:00
|
|
|
Then /^I should not see the context "([^"]*)"$/ do |context_name|
|
2013-02-27 20:02:01 +01:00
|
|
|
context = @current_user.contexts.where(:name => context_name).first
|
2011-04-14 16:26:16 +02:00
|
|
|
context.should_not be_nil
|
2011-04-19 16:40:55 +02:00
|
|
|
|
|
|
|
|
xpath = "//div[@id='c#{context.id}']"
|
2012-02-15 21:42:06 +01:00
|
|
|
page.should_not have_xpath(xpath, :visible => true)
|
2011-04-14 16:26:16 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should not see the container for context "([^"]*)"$/ do |context_name|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I should not see the context \"#{context_name}\""
|
2011-09-10 00:51:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should not see the context container for "([^"]*)"$/ do |context_name|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I should not see the context \"#{context_name}\""
|
2011-04-14 16:26:16 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the container for the context "([^"]*)" should not be visible$/ do |context_name|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I should not see the context \"#{context_name}\""
|
2011-04-14 16:26:16 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should see the container for context "([^"]*)"$/ do |context_name|
|
2013-02-27 20:02:01 +01:00
|
|
|
context = @current_user.contexts.where(:name => context_name).first
|
2011-04-14 16:26:16 +02:00
|
|
|
context.should_not be_nil
|
|
|
|
|
|
2011-08-18 17:15:00 +02:00
|
|
|
xpath = "//div[@id='c#{context.id}']"
|
2012-02-03 15:57:23 +01:00
|
|
|
page.should have_xpath(xpath)
|
2011-04-14 16:26:16 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^the container for the context "([^"]*)" should be visible$/ do |context_name|
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I should see the container for context \"#{context_name}\""
|
2011-04-14 16:26:16 +02:00
|
|
|
end
|
|
|
|
|
|
2013-03-18 13:33:30 +01:00
|
|
|
Then /^I should (see|not see) "([^"]*)" in the context container for "([^"]*)"$/ do |visible, todo_description, context_name|
|
2013-02-27 20:02:01 +01:00
|
|
|
context = @current_user.contexts.where(:name => context_name).first
|
2011-05-08 22:09:27 +02:00
|
|
|
context.should_not be_nil
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-05-08 22:09:27 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2012-02-15 21:42:06 +01:00
|
|
|
xpath = "//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
|
2013-03-18 13:33:30 +01:00
|
|
|
page.send( visible=='see' ? :should : :should_not, have_xpath(xpath))
|
2011-05-08 22:09:27 +02:00
|
|
|
end
|
|
|
|
|
|
2011-08-18 17:15:00 +02:00
|
|
|
####### Deferred #######
|
|
|
|
|
|
2011-06-26 23:05:33 +02:00
|
|
|
Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-06-26 23:05:33 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2013-03-17 15:41:36 +01:00
|
|
|
page.should have_xpath("//div[@id='deferred_pending_container']//div[@id='line_todo_#{todo.id}']")
|
2011-06-26 23:05:33 +02:00
|
|
|
end
|
|
|
|
|
|
2011-08-18 17:15:00 +02:00
|
|
|
Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-08-18 17:15:00 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2013-03-17 15:41:36 +01:00
|
|
|
page.should_not have_xpath("//div[@id='deferred_pending_container']//div[@id='line_todo_#{todo.id}']")
|
2011-08-18 17:15:00 +02:00
|
|
|
end
|
|
|
|
|
|
2012-03-23 20:39:04 +01:00
|
|
|
Then /^I should (not see|see) "([^"]*)" in the action container$/ do |visible, todo_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-06-26 23:05:33 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2013-03-17 15:41:36 +01:00
|
|
|
id = @source_view=="project" ? "p#{todo.project_id}_items" : "c#{todo.context_id}_items"
|
2012-03-23 20:39:04 +01:00
|
|
|
|
|
|
|
|
xpath = "//div[@id='#{id}']//div[@id='line_todo_#{todo.id}']"
|
|
|
|
|
page.send(visible=="see" ? :should : :should_not, have_xpath(xpath))
|
2011-06-26 23:05:33 +02:00
|
|
|
end
|
|
|
|
|
|
2012-03-23 20:39:04 +01:00
|
|
|
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 #######
|
|
|
|
|
|
2013-04-11 10:53:35 +02:00
|
|
|
Then /^I should (see|not see) "([^"]*)" in the project container of "([^"]*)"$/ do |visible, todo_description, project_name|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-08-11 17:13:01 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2013-02-27 20:02:01 +01:00
|
|
|
project = @current_user.projects.where(:name => project_name).first
|
2011-08-11 17:13:01 +02:00
|
|
|
project.should_not be_nil
|
|
|
|
|
|
2013-03-17 15:41:36 +01:00
|
|
|
xpath = "//div[@id='p#{todo.project.id}_items']//div[@id='line_todo_#{todo.id}']"
|
2013-04-11 10:53:35 +02:00
|
|
|
page.send( visible=='see' ? :should : :should_not, have_xpath(xpath))
|
2011-08-11 17:13:01 +02:00
|
|
|
end
|
|
|
|
|
|
2013-04-11 10:53:35 +02:00
|
|
|
Then(/^I should (see|not see) the project container for "([^"]*)"$/) do |visible, project_name|
|
2013-02-27 20:02:01 +01:00
|
|
|
project = @current_user.projects.where(:name => project_name).first
|
2011-08-18 17:15:00 +02:00
|
|
|
project.should_not be_nil
|
|
|
|
|
|
2013-04-11 10:53:35 +02:00
|
|
|
xpath = "//div[@id='p#{project.id}']"
|
|
|
|
|
page.send( visible=='see' ? :should : :should_not, have_xpath(xpath, :visible => true))
|
2013-03-18 13:33:30 +01:00
|
|
|
end
|
|
|
|
|
|
2013-04-11 10:53:35 +02:00
|
|
|
Then(/^the container for the project "(.*?)" should (be visible|not be visible)$/) do |project_name, visible|
|
|
|
|
|
map = { "be visible" => "see", "not be visible" => "not see"}
|
|
|
|
|
step("I should #{map[visible]} the project container for \"#{project_name}\"")
|
2013-03-18 13:33:30 +01:00
|
|
|
end
|
|
|
|
|
|
2011-08-18 17:15:00 +02:00
|
|
|
####### Completed #######
|
2011-08-11 17:13:01 +02:00
|
|
|
|
2013-03-18 12:24:42 +01:00
|
|
|
Then /^I should (not see|see) "([^"]*)" in the (completed|done today|done this week|done this month) container$/ do |visible, todo_description, container|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-06-26 23:05:33 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2013-03-18 12:24:42 +01:00
|
|
|
id = 'completed_container' if container == 'completed'
|
|
|
|
|
id = 'completed_today_container' if container == 'done today'
|
|
|
|
|
id = 'completed_rest_of_week_container' if container == 'done this week'
|
|
|
|
|
id = 'completed_rest_of_month_container' if container == 'done this month'
|
2011-06-26 23:05:33 +02:00
|
|
|
|
2013-03-18 12:24:42 +01:00
|
|
|
xpath = "//div[@id='#{id}']//div[@id='line_todo_#{todo.id}']"
|
|
|
|
|
page.send( visible=='see' ? :should : :should_not, have_xpath(xpath))
|
2011-06-26 23:05:33 +02:00
|
|
|
end
|
|
|
|
|
|
2011-08-18 17:15:00 +02:00
|
|
|
####### Hidden #######
|
|
|
|
|
|
2011-08-15 20:44:59 +02:00
|
|
|
Then /^I should see "([^"]*)" in the hidden container$/ do |todo_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-08-15 20:44:59 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2013-03-17 15:41:36 +01:00
|
|
|
xpath = "//div[@id='hidden_container']//div[@id='line_todo_#{todo.id}']"
|
2012-02-03 15:57:23 +01:00
|
|
|
page.should have_xpath(xpath)
|
2011-08-15 20:44:59 +02:00
|
|
|
end
|
|
|
|
|
|
2011-08-18 17:15:00 +02:00
|
|
|
####### Calendar #######
|
|
|
|
|
|
2011-06-26 23:05:33 +02:00
|
|
|
Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description|
|
2013-02-27 20:02:01 +01:00
|
|
|
todo = @current_user.todos.where(:description => todo_description).first
|
2011-06-26 23:05:33 +02:00
|
|
|
todo.should_not be_nil
|
|
|
|
|
|
2012-01-30 03:42:47 +01:00
|
|
|
within "div#due_after_this_month" do
|
2012-02-03 15:57:23 +01:00
|
|
|
page.should have_css("div#line_todo_#{todo.id}")
|
2011-06-26 23:05:33 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2011-08-18 17:15:00 +02:00
|
|
|
####### Repeat patterns #######
|
2011-06-21 11:03:23 +02:00
|
|
|
|
2012-03-19 14:05:54 +01:00
|
|
|
Then /^I should (see|not see) "([^"]*)" in the active recurring todos container$/ do |visibility, repeat_pattern|
|
2013-02-27 20:02:01 +01:00
|
|
|
repeat = @current_user.recurring_todos.where(:description => repeat_pattern).first
|
2011-08-11 17:13:01 +02:00
|
|
|
|
2011-06-26 23:05:33 +02:00
|
|
|
unless repeat.nil?
|
|
|
|
|
xpath = "//div[@id='active_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
|
2012-03-19 14:05:54 +01:00
|
|
|
page.send(visibility == "see" ? "should" : "should_not", have_xpath(xpath, :visible => true))
|
2011-06-26 23:05:33 +02:00
|
|
|
else
|
2012-03-19 14:05:54 +01:00
|
|
|
step "I should #{visibility} \"#{repeat_pattern}\""
|
2011-06-26 23:05:33 +02:00
|
|
|
end
|
2011-06-21 11:03:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Then /^I should not see "([^"]*)" in the completed recurring todos container$/ do |repeat_pattern|
|
2013-02-27 20:02:01 +01:00
|
|
|
repeat = @current_user.todos.where(:description => repeat_pattern).first
|
2011-06-26 23:05:33 +02:00
|
|
|
|
|
|
|
|
unless repeat.nil?
|
|
|
|
|
xpath = "//div[@id='completed_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
|
2012-03-12 22:52:45 +01:00
|
|
|
page.should_not have_xpath(xpath, :visible => true)
|
2011-06-26 23:05:33 +02:00
|
|
|
else
|
2012-02-15 21:42:06 +01:00
|
|
|
step "I should not see \"#{repeat_pattern}\""
|
2011-06-26 23:05:33 +02:00
|
|
|
end
|
2013-03-18 12:24:42 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
####### Empty message patterns #######
|
|
|
|
|
|
|
|
|
|
Then /^I should (see|not see) empty message for (done today|done this week|done this month|completed todos|deferred todos|todos) (of done actions|of context|of project|of home|of tag)/ do |visible, state, type|
|
|
|
|
|
css = "error: wrong state"
|
|
|
|
|
css = "div#c#{@context.id}-empty-d" if state == "todos" && type == "of context"
|
|
|
|
|
css = "div#p#{@project.id}-empty-d" if state == "todos" && type == "of project"
|
|
|
|
|
css = "div#no_todos_in_view" if state == "todos" && (type == "of home" || type == "of tag")
|
|
|
|
|
css = "div#completed_today_container" if state == "done today"
|
|
|
|
|
css = "div#completed_rest_of_week_container" if state == "done this week"
|
|
|
|
|
css = "div#completed_rest_of_month_container" if state == "done this month"
|
|
|
|
|
css = "div#completed_container-empty-d" if state == "completed todos"
|
|
|
|
|
css = "div#deferred_pending_container-empty-d" if state == "deferred todos"
|
|
|
|
|
|
|
|
|
|
elem = find(css)
|
|
|
|
|
elem.should_not be_nil
|
|
|
|
|
elem.send(visible=="see" ? :should : :should_not, be_visible)
|
2013-02-27 20:02:01 +01:00
|
|
|
end
|