fix failing test and finish all wip scenarios

Signed-off-by: Reinier Balt <lrbalt@gmail.com>
This commit is contained in:
Reinier Balt 2011-05-08 22:09:27 +02:00
parent f05826d07a
commit 3faac2514d
10 changed files with 95 additions and 17 deletions

View file

@ -44,6 +44,23 @@ Then /^I should see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_
selenium.is_visible(xpath).should be_true
end
Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name|
context = @current_user.contexts.find_by_name(context_name)
context.should_not be_nil
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
if selenium.is_element_present(xpath)
# give jquery some time to finish
wait_for :timeout_in_seconds => 5 do
!selenium.is_visible(xpath)
end
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

View file

@ -28,6 +28,18 @@ Then /^I should see the empty message in the deferred container$/ do
end
end
Then /^I should see the empty tickler message$/ do
wait_for :timeout => 5 do
selenium.is_visible("xpath=//div[@id='tickler-empty-nd']")
end
end
Then /^I should not see the empty tickler message$/ do
wait_for :timeout => 5 do
!selenium.is_visible("xpath=//div[@id='tickler-empty-nd']")
end
end
Then /^I should see an error flash message saying "([^"]*)"$/ do |message|
xpath = "//div[@id='message_holder']/h4[@id='flash']"
text = response.selenium.get_text("xpath=#{xpath}")

View file

@ -42,6 +42,12 @@ When /^I submit a deferred new action with description "([^"]*)" to project "([^
When "I submit a new deferred action with description \"#{description}\" to project \"#{project_name}\" with tags \"\" in the context \"#{context_name}\""
end
When /^I submit a new deferred action with description "([^"]*)"$/ do |description|
fill_in "todo[description]", :with => description
fill_in "todo[show_from]", :with => format_date(@current_user.time + 1.week)
submit_next_action_form
end
When /^I submit a new action with description "([^"]*)" to project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |description, project_name, tags, context_name|
fill_in "todo[description]", :with => description

View file

@ -42,3 +42,13 @@ When /^I clear the due date of "([^"]*)"$/ do |action_description|
selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='due_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery)
submit_edit_todo_form(todo)
end
When /^I remove the show from date from "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
open_edit_form_for(todo)
selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='show_from_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery)
submit_edit_todo_form(todo)
end

View file

@ -31,8 +31,12 @@ Given /^I have ([0-9]+) deferred todos$/ do |count|
end
end
Given /^I have a deferred todo "(.*)"$/ do |description|
context = @current_user.contexts.create!(:name => "context B")
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)
@current_user.todos.create!(:context_id => context.id, :description => description, :show_from => @current_user.time + 1.week)
end

View file

@ -10,23 +10,46 @@ Feature: Manage deferred todos
And there exists a project "manage me" for user "testuser"
And I have logged in as "testuser" with password "secret"
@selenium @wip
@selenium
Scenario: I can add a deferred todo and it will show in the tickler
# also adding the first deferred todo will hide the empty message
When I go to the tickler
Given I have a context called "test"
When I go to the tickler page
Then I should see the empty tickler message
When I submit a deferred new action with description "a new next action"
When I submit a new deferred action with description "a new next action"
Then I should see "a new next action"
And I should not see the empty tickler message
Scenario: Editing the description of a todo updated the todo
Given this is a pending scenario
@selenium
Scenario: Editing the description of a todo in the tickler updated the todo
Given I have a deferred todo "not yet now"
When I go to the tickler page
Then I should see "not yet now"
When I edit the description of "not yet now" to "almost"
Then I should not see "not yet now"
And I should see "almost"
@selenium
Scenario: Editing the context of a todo moves it to the new context
Given this is a pending scenario
Given I have a context called "A"
And I have a context called "B"
And I have a deferred todo "not yet now" in the context "A"
When I go to the tickler page
Then I should see "not yet now" in the context container for "A"
When I edit the context of "not yet now" to "B"
Then I should see "not yet now" in the context container for "B"
And I should not see "not yet now" in the context container for "A"
@selenium
Scenario: Removing the show from date from a todo removes it from the tickler
Given this is a pending scenario
Given I have a deferred todo "not yet now"
When I go to the tickler page
Then I should see "not yet now"
When I remove the show from date from "not yet now"
Then I should not see "not yet now"
And I should see the empty tickler message
When I go to the home page
Then I should see "not yet now"
Scenario: Opening the tickler page shows me all deferred todos
Given I have a deferred todo "not yet now"