add done view to tag pages and add more tests

This commit is contained in:
Reinier Balt 2011-06-26 23:05:33 +02:00
parent 6e97541ab3
commit 601736de2d
14 changed files with 1106 additions and 869 deletions

View file

@ -60,6 +60,61 @@ Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |t
end
end
Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in the action container$/ do |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}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='due_after_this_month']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
@ -75,19 +130,25 @@ end
Then /^I should see "([^"]*)" in the active recurring todos container$/ do |repeat_pattern|
repeat = @current_user.recurring_todos.find_by_description(repeat_pattern)
repeat.should_not be_nil
xpath = "//div[@id='active_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
selenium.wait_for_element("xpath=#{xpath}", :timeout_in_seconds => 5)
selenium.is_visible(xpath).should be_true
unless repeat.nil?
xpath = "//div[@id='active_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
selenium.wait_for_element("xpath=#{xpath}", :timeout_in_seconds => 5)
selenium.is_visible(xpath).should be_true
else
Then "I should not see \"#{repeat_pattern}\""
end
end
Then /^I should not see "([^"]*)" in the completed recurring todos container$/ do |repeat_pattern|
repeat = @current_user.recurring_todos.find_by_description(repeat_pattern)
repeat.should_not be_nil
xpath = "//div[@id='completed_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
selenium.wait_for_element("xpath=#{xpath}", :timeout_in_seconds => 5)
selenium.is_visible(xpath).should be_true
unless repeat.nil?
xpath = "//div[@id='completed_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
selenium.wait_for_element("xpath=#{xpath}", :timeout_in_seconds => 5)
selenium.is_visible(xpath).should be_true
else
Then "I should not see \"#{repeat_pattern}\""
end
end

View file

@ -2,6 +2,10 @@ Given /this is a pending scenario/ do
pending
end
Given /^I set the locale to "([^"]*)"$/ do |locale|
@locale = locale
end
Given /^I am working on the mobile interface$/ do
@mobile_interface = true
end
@ -11,7 +15,7 @@ Then /the badge should show (.*)/ do |number|
xpath= "//span[@id='badge_count']"
if response.respond_to? :selenium
response.should have_xpath(xpath)
response.should have_xpath(xpath)
badge = response.selenium.get_text("xpath=#{xpath}").to_i
else
response.should have_xpath(xpath) do |node|

View file

@ -33,10 +33,6 @@ Given /^I have ([0-9]+) deferred todos$/ do |count|
end
end
Given /^I have a deferred todo "([^"]*)"$/ do |description|
Given "I have a deferred todo \"#{description}\" in the context \"context B\""
end
Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
context = @current_user.contexts.find_or_create(:name => context_name)
todo = @current_user.todos.create!(:context_id => context.id, :description => description)
@ -44,23 +40,40 @@ Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ do |descript
todo.save!
end
Given /^I have a deferred todo "([^"]*)"$/ do |description|
Given "I have a deferred todo \"#{description}\" in the context \"context B\""
end
Given /^I have ([0-9]+) completed todos in project "([^"]*)" in context "([^"]*)"$/ do |count, project_name, context_name|
context = @current_user.contexts.find_by_name(context_name)
context.should_not be_nil
project = @current_user.projects.find_by_name(project_name)
project.should_not be_nil
@context = @current_user.contexts.find_by_name(context_name)
@context.should_not be_nil
@project = @current_user.projects.find_by_name(project_name)
@project.should_not be_nil
@todos = []
count.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}", :project_id => project.id)
todo.complete!
@todo = @current_user.todos.create!(:context_id => @context.id, :description => "todo #{i}", :project_id => @project.id)
@todo.complete!
@todos << @todo
end
end
Given /^I have a completed todo "([^"]*)" in project "([^"]*)" in context "([^"]*)"$/ do |action_description, project_name, context_name|
Given "I have 1 completed todos in project \"#{project_name}\" in context \"#{context_name}\""
@todos[0].description = action_description
@todos[0].save!
end
Given /^I have (\d+) completed todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |count, project_name, context_name, tags|
Given "I have #{count} completed todos in project \"#{project_name}\" in context \"#{context_name}\""
@todos.each { |t| t.tag_with(tags); t.save! }
end
Given /^I have ([0-9]+) completed todos in context "([^"]*)"$/ do |count, context_name|
context = @current_user.contexts.find_by_name(context_name)
context.should_not be_nil
count.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
todo.complete!
@ -73,11 +86,13 @@ Given /^I have ([0-9]+) completed todos$/ do |count|
end
Given /^I have ([0-9]+) completed todos with a note$/ do |count|
context = @current_user.contexts.find_or_create(:name => "context D")
count.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}", :notes => "note #{i}")
todo.complete!
end
Given "I have #{count} completed todos"
@todos.each { |t| t.notes = "note #{t.id}"; t.save!}
end
Given /^I have ([0-9]+) completed todos with a note in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |count, project_name, context_name, tags|
Given "I have #{count} completed todos in project \"#{project_name}\" in context \"#{context_name}\" with tags \"#{tags}\""
@todos.each { |t| t.notes = "note #{t.id}"; t.save! }
end
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
@ -146,10 +161,14 @@ When /^I mark "([^"]*)" as uncompleted$/ do |action_description|
todo_container = "p#{todo.project_id}items" if @source_view=="project"
todo_container = "c#{todo.context_id}items" if @source_view=="context" || @source_view=="todos" || @source_view=="tag"
todo_container.should_not == "fail"
todo_container.should_not == "fail" unless @source_view=="done"
wait_for :timeout => 5 do
selenium.is_element_present("//div[@id='#{todo_container}']//div[@id='line_todo_#{todo.id}']")
unless @source_view=="done"
wait_for :timeout => 5 do
selenium.is_element_present("//div[@id='#{todo_container}']//div[@id='line_todo_#{todo.id}']")
end
else
wait_for_ajax
end
end
@ -157,7 +176,6 @@ When /^I mark the complete todo "([^"]*)" active$/ do |action_description|
When "I mark \"#{action_description}\" as uncompleted"
end
When /^I star the action "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
@ -175,6 +193,24 @@ When /^I star the action "([^"]*)"$/ do |action_description|
end
end
When /^I unstar the action "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
xpath_unstarred = "//div[@id='line_todo_#{todo.id}']//img[@class='unstarred_todo']"
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='starred_todo']"
selenium.is_element_present(xpath_starred).should be_true
star_img = "//img[@id='star_img_#{todo.id}']"
selenium.click(star_img, :wait_for => :ajax, :javascript_framework => :jquery)
wait_for :timeout => 5 do
selenium.is_element_present(xpath_unstarred)
end
end
Then /^I should see a starred "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
@ -184,6 +220,18 @@ Then /^I should see a starred "([^"]*)"$/ do |action_description|
selenium.is_element_present(xpath_starred).should be_true
end
Then /^I should see an unstarred "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
xpath_starred = "//div[@id='line_todo_#{todo.id}']//img[@class='unstarred_todo']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath_starred)
end
end
When /^I delete the action "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
@ -231,61 +279,6 @@ Then /^a confirmation for adding a new context "([^"]*)" should be asked$/ do |c
selenium.get_confirmation.should == "New context '#{context_name}' will be also created. Are you sure?"
end
Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in the action container$/ do |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}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='completed_container']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^I should not see "([^"]*)" in the deferred container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='tickler']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
Then /^I should see "([^"]*)" in the due next month container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "//div[@id='due_after_this_month']//div[@id='line_todo_#{todo.id}']"
wait_for :timeout => 5 do
selenium.is_element_present(xpath)
end
end
Then /^the selected project should be "([^"]*)"$/ do |content|
# Works for mobile. TODO: make it work for both mobile and non-mobile
field_labeled("Project").element.search(".//option[@selected = 'selected']").inner_html.should =~ /#{content}/

View file

@ -7,24 +7,47 @@ module NavigationHelpers
#
def path_to(page_name)
options = @mobile_interface ? {:format => :m} : {}
options.merge({:locale => @locale}) unless @locale.blank?
puts "@@@ l=#{@locale} sv = #{@source_view}- #{options}"
@source_view = nil
case page_name
when /the home\s?page/
@source_view = "todos"
root_path(options)
when /the done page/
@source_view = "done"
done_overview_path(options)
when /the done actions page for context "([^"]*)"/i
@source_view = "done"
context = @current_user.contexts.find_by_name($1)
done_todos_context_path(context)
done_todos_context_path(context, options)
when /the done actions page for project "([^"]*)"/i
@source_view = "done"
project = @current_user.projects.find_by_name($1)
done_todos_project_path(project)
done_todos_project_path(project, options)
when /the done actions page for tag "([^"]*)"/i
@source_view = "done"
done_tag_path($1, options)
when /the done actions page/
@source_view = "done"
done_todos_path(options)
when /the all done actions page for context "([^"]*)"/i
@source_view = "done"
context = @current_user.contexts.find_by_name($1)
all_done_todos_context_path(context, options)
when /the all done actions page for project "([^"]*)"/i
@source_view = "done"
project = @current_user.projects.find_by_name($1)
all_done_todos_project_path(project, options)
when /the all done actions page for tag "([^"]*)"/i
@source_view = "done"
all_done_tag_path($1, options)
when /the all done actions page/
@source_view = "done"
all_done_todos_path(options)
when /the statistics page/
@source_view = "stats"
stats_path(options)

View file

@ -8,79 +8,81 @@ Feature: Show done
| login | password | is_admin |
| testuser | secret | false |
And I have logged in as "testuser" with password "secret"
And I have 1 completed todos with a note
And I have a context called "@pc"
And I have a project called "test project"
And I have 1 completed todos in project "test project" in context "@pc" with tags "starred"
Scenario: Visit done overview page
When I go to the done page
Then I should see "Last Completed Actions"
And I should see "Last Completed Projects"
And I should see "Last Completed Repeating Actions"
Scenario: Home page links to show all completed todos
When I go to the home page
Scenario Outline: Page with actions links to show all completed actions
When I go to the <page>
Then I should see "Completed actions"
And I should see "Show all"
When I follow "Show all"
Then I should be on the done actions page
Then I should be on the <next page>
Scenarios:
| page | next page |
| home page | done actions page |
| context page for "@pc" | done actions page for context "@pc" |
| "test project" project | done actions page for project "test project" |
| tag page for "starred" | done actions page for tag "starred" |
Scenario Outline: I can see all todos completed in the last timeperiod
Given I have a context called "@pc"
And I have a project called "test"
And I have 1 completed todos in project "test" in context "@pc"
When I go to the <page>
Then I should see "todo 1"
And I should see "Completed today"
And I should see "Completed in the rest of this week"
And I should see "Completed in the rest of this month"
Scenarios:
| page |
| done actions page |
| done actions page for context "@pc" |
| done actions page for project "test" |
Scenario: I can see all todos completed
When I go to the done actions page
| page |
| done actions page |
| done actions page for context "@pc" |
| done actions page for project "test project" |
| done actions page for tag "starred" |
Scenario Outline: I can see all todos completed
When I go to the <page>
And I should see "You can see all completed actions here"
When I follow "here"
Then I should be on the all done actions page
Scenario: I can browse all todos completed by page
Given I have 50 completed todos with a note
When I go to the all done actions page
Then I should be on the <other page>
Scenarios:
| page | other page |
| done actions page | all done actions page |
| done actions page for project "test project" | all done actions page for project "test project" |
| done actions page for context "@pc" | all done actions page for context "@pc" |
| done actions page for tag "starred" | all done actions page for tag "starred" |
Scenario Outline: I can browse all todos completed by page
Given I have 50 completed todos with a note in project "test project" in context "@pc" with tags "starred"
When I go to the <page>
Then I should see the page selector
When I follow "2"
Then I should be on the all done actions page
Then I should be on the <page>
And the page should be "2"
Scenario: The context page for a context shows a link to all completed actions
Given I have a context called "@pc"
And I have 1 completed todos in context "@pc"
When I go to the context page for "@pc"
Then I should see "Completed actions"
And I should see "Show all"
When I follow "Show all"
Then I should be on the done actions page for context "@pc"
Scenario: The project page for a project shows a link to all completed actions
Given I have a context called "@pc"
And I have a project called "test"
And I have 1 completed todos in project "test" in context "@pc"
When I go to the "test" project
Then I should see "Completed actions"
And I should see "Show all"
When I follow "Show all"
Then I should be on the done actions page for project "test"
Scenarios:
| page |
| all done actions page |
| all done actions page for project "test project" |
| all done actions page for context "@pc" |
| all done actions page for tag "starred" |
Scenario: The projects page shows a link to all completed projects
Given I have a completed project called "finished"
When I go to the projects page
Then I should see "finished"
Then I should see "finished"
And I should see "Show all"
When I follow "Show all"
Then I should be on the done projects page
And I should see "finished"
Scenario: I can browse all completed projects by page
Given I have 40 completed projects
When I go to the projects page
@ -95,12 +97,12 @@ Feature: Show done
Scenario: The recurring todos page shows a link to all completed recurring todos
Given I have a completed repeat pattern "finished"
When I go to the recurring todos page
Then I should see "finished"
Then I should see "finished"
And I should see "Show all"
When I follow "Show all"
Then I should be on the done recurring todos page
And I should see "finished"
Scenario: I can browse all completed recurring todos by page
Given I have 40 completed repeat patterns
When I go to the recurring todos page
@ -110,31 +112,98 @@ Feature: Show done
When I follow "2"
Then I should be on the done recurring todos page
And the page should be "2"
@selenium
Scenario: I can toggle a done recurring todo active from done page
Given I have a completed repeat pattern "test"
Given I have a completed repeat pattern "test pattern"
When I go to the done recurring todos page
Then I should see "test"
When I mark the pattern "test" as active
Then I should not see "test" in the completed recurring todos container
Then I should see "test pattern"
When I mark the pattern "test pattern" as active
Then I should not see "test pattern" in the completed recurring todos container
When I go to the recurring todos page
Then I should see "test" in the active recurring todos container
Then I should see "test pattern" in the active recurring todos container
@selenium
Scenario: I can delete a recurring todo from the done page
Given this scenario is pending
Scenario: I can toggle a todo active from the done page
Given this scenario is pending
Given I have a completed repeat pattern "test pattern"
When I go to the done recurring todos page
Then I should see "test pattern"
When I delete the pattern "test pattern"
Then I should not see "test pattern" in the completed recurring todos container
When I go to the recurring todos page
Then I should see "test pattern" in the active recurring todos container
Scenario: I can toggle a todo active from the all done page
Given this scenario is pending
Scenario: I can toggle a todo active from the project done page
Given this scenario is pending
@selenium @wip
Scenario Outline: I can toggle a todo active from the done pages
When I go to the <page>
Then I should see "todo 1"
When I mark the complete todo "todo 1" active
Then I should not see "todo 1"
When I go to the <next page>
Then I should see "todo 1" in the context container for "@pc"
Scenario: I can toggle a todo active from the context done page
Given this scenario is pending
Scenarios:
| page | next page |
| done actions page | home page |
| all done actions page | home page |
| done actions page for context "@pc" | context page for "@pc" |
| done actions page for project "test project" | "test project" project |
| done actions page for tag "starred" | home page |
| all done actions page for context "@pc" | context page for "@pc" |
| all done actions page for project "test project"| "test project" project |
| all done actions page for tag "starred" | home page |
@selenium
Scenario Outline: I can toggle the star of a todo from the done pages
When I go to the <page>
Then I should see a starred "todo 1"
When I unstar the action "todo 1"
Then I should see an unstarred "todo 1"
Scenarios:
| page |
| done actions page |
| all done actions page |
| done actions page for context "@pc" |
| done actions page for project "test project" |
| done actions page for tag "starred" |
| all done actions page for context "@pc" |
| all done actions page for project "test project"|
| all done actions page for tag "starred" |
@selenium
Scenario: I can edit a project to active from the project done page
Given this scenario is pending
@wip
Scenario Outline: All pages are internationalized
Given I set the locale to "<locale>"
When I go to the <page>
Then I should not see "translation missing"
Scenarios:
| page | locale |
| done actions page | en |
| all done actions page | en |
| done actions page for context "@pc" | en |
| done actions page for project "test project" | en |
| done actions page for tag "starred" | en |
| all done actions page for context "@pc" | en |
| all done actions page for project "test project"| en |
| all done actions page for tag "starred" | en |
| done actions page | nl |
| all done actions page | nl |
| done actions page for context "@pc" | nl |
| done actions page for project "test project" | nl |
| done actions page for tag "starred" | nl |
| all done actions page for context "@pc" | nl |
| all done actions page for project "test project"| nl |
| all done actions page for tag "starred" | nl |
| done actions page | de |
| all done actions page | de |
| done actions page for context "@pc" | de |
| done actions page for project "test project" | de |
| done actions page for tag "starred" | de |
| all done actions page for context "@pc" | de |
| all done actions page for project "test project"| de |
| all done actions page for tag "starred" | de |