mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-16 09:16:32 +01:00
add more cucumber scenarios
This commit is contained in:
parent
b40998e0bc
commit
ef961188ea
12 changed files with 190 additions and 71 deletions
|
|
@ -6,7 +6,7 @@ end
|
|||
Given /^there exists an active context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
|
||||
user = User.find_by_login(login)
|
||||
user.should_not be_nil
|
||||
@context = user.contexts.create!(:name => context_name, :hide => false)
|
||||
@context = user.contexts.find_or_create(:name => context_name, :hide => false)
|
||||
end
|
||||
|
||||
Given /^there exists a context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
|
||||
|
|
|
|||
|
|
@ -59,10 +59,32 @@ Given /^I have a hidden project called "([^"]*)"$/ do |project_name|
|
|||
@project.hide!
|
||||
end
|
||||
|
||||
When /^I open the project edit form$/ do
|
||||
click_link "link_edit_project_#{@project.id}"
|
||||
|
||||
wait_for do
|
||||
selenium.is_element_present("submit_project_#{@project.id}")
|
||||
end
|
||||
end
|
||||
|
||||
When /^I cancel the project edit form$/ do
|
||||
click_link "cancel_project_#{@project.id}"
|
||||
|
||||
if selenium.is_visible("submit_project_#{@project.id}")
|
||||
wait_for do
|
||||
!selenium.is_visible("submit_project_#{@project.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
When /^I edit the project description to "([^\"]*)"$/ do |new_description|
|
||||
click_link "link_edit_project_#{@project.id}"
|
||||
fill_in "project[description]", :with => new_description
|
||||
click_button "submit_project_#{@project.id}"
|
||||
|
||||
wait_for do
|
||||
!selenium.is_element_present("submit_project_#{@project.id}")
|
||||
end
|
||||
end
|
||||
|
||||
When /^I edit the project name to "([^\"]*)"$/ do |new_title|
|
||||
|
|
@ -80,7 +102,7 @@ When /^I edit the project name to "([^\"]*)"$/ do |new_title|
|
|||
:timeout => 5
|
||||
|
||||
wait_for do
|
||||
!selenium.is_element_present("submit_context_#{@project.id}")
|
||||
!selenium.is_element_present("submit_project_#{@project.id}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ end
|
|||
|
||||
When /^I submit a new action with description "([^"]*)" and the tags "([^"]*)" in the context "([^"]*)"$/ do |description, tags, context_name|
|
||||
fill_in "todo[description]", :with => description
|
||||
fill_in "tag_list", :with => tags
|
||||
fill_in "todo_tag_list", :with => tags
|
||||
|
||||
# fill_in does not seem to work when the field is prefilled with something. Empty the field first
|
||||
clear_context_name_from_next_action_form
|
||||
|
|
@ -43,7 +43,7 @@ When /^I submit a new deferred action with description "([^"]*)" and the tags "(
|
|||
clear_context_name_from_next_action_form
|
||||
fill_in "todo_context_name", :with => context_name
|
||||
|
||||
fill_in "tag_list", :with => tags
|
||||
fill_in "todo_tag_list", :with => tags
|
||||
fill_in "todo[show_from]", :with => format_date(@current_user.time + 1.week)
|
||||
submit_next_action_form
|
||||
end
|
||||
|
|
@ -56,7 +56,7 @@ When /^I submit a new deferred action with description "([^"]*)" to project "([^
|
|||
|
||||
fill_in "todo_project_name", :with => project_name
|
||||
fill_in "todo_context_name", :with => context_name
|
||||
fill_in "tag_list", :with => tags
|
||||
fill_in "todo_tag_list", :with => tags
|
||||
fill_in "todo[show_from]", :with => format_date(@current_user.time + 1.week)
|
||||
|
||||
submit_next_action_form
|
||||
|
|
@ -80,7 +80,7 @@ When /^I submit a new action with description "([^"]*)" to project "([^"]*)" wit
|
|||
|
||||
fill_in "todo_project_name", :with => project_name
|
||||
fill_in "todo_context_name", :with => context_name
|
||||
fill_in "tag_list", :with => tags
|
||||
fill_in "todo_tag_list", :with => tags
|
||||
|
||||
submit_next_action_form
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,6 +23,15 @@ When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description
|
|||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
open_edit_form_for(todo)
|
||||
fill_in "todo_description", :with => new_description
|
||||
selenium.click("//div[@id='edit_todo_#{todo.id}']//button[@id='submit_todo_#{todo.id}']", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
# do not wait for form to disappear to be able to test failures
|
||||
end
|
||||
|
||||
When /^I edit the due date of "([^"]*)" to tomorrow$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
|
@ -65,6 +74,15 @@ When /^I remove the show from date from "([^"]*)"$/ do |action_description|
|
|||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
When /^I edit the tags of "([^"]*)" to "([^"]*)"$/ do |action_description, tags|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
open_edit_form_for(todo)
|
||||
fill_in "tag_list", :with => tags
|
||||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
When /^I defer "([^"]*)" for 1 day$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
|
@ -72,9 +90,7 @@ When /^I defer "([^"]*)" for 1 day$/ do |action_description|
|
|||
defer_todo_1day_button = "xpath=//a[@id='defer_1_todo_#{todo.id}']/img"
|
||||
selenium.click defer_todo_1day_button
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
!selenium.is_element_present("//div[@id='line_todo_#{todo.id}']")
|
||||
end
|
||||
wait_for_ajax
|
||||
end
|
||||
|
||||
When /^I make a project of "([^"]*)"$/ do |action_description|
|
||||
|
|
@ -89,3 +105,9 @@ When /^I make a project of "([^"]*)"$/ do |action_description|
|
|||
end
|
||||
end
|
||||
|
||||
Then /^I should see an error message$/ do
|
||||
error_block = "xpath=//form/div[@id='edit_error_status']"
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(error_block)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,12 +40,34 @@ Given /^I have a todo "([^"]*)"$/ do |description|
|
|||
Given "I have a todo \"#{description}\" in the context \"Context A\""
|
||||
end
|
||||
|
||||
Given /^I have a todo "([^"]*)" with notes "([^"]*)"$/ do |description, notes|
|
||||
Given "I have a todo \"#{description}\" in the context \"Context A\""
|
||||
@todo.notes = notes
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) todos$/ do |count|
|
||||
count.to_i.downto 1 do |i|
|
||||
Given "I have a todo \"todo #{i}\" in the context \"Context A\""
|
||||
end
|
||||
end
|
||||
|
||||
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
|
||||
context = @current_user.contexts.find_or_create(:name => context_name)
|
||||
project = @current_user.projects.find_or_create(:name => project_name)
|
||||
@todo = @current_user.todos.create!(:context_id => context.id, :project_id => project.id, :description => action_description)
|
||||
@todo.tag_with(tags)
|
||||
@todo.save
|
||||
end
|
||||
|
||||
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)" that is due next week$/ do |action_description, project_name, tags, context_name|
|
||||
Given "I have a todo with description \"#{action_description}\" in project \"#{project_name}\" with tags \"#{tags}\" in the context \"#{context_name}\""
|
||||
@todo.due = @current_user.time + 1.week
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
###### DEFERRED TODOS #######
|
||||
|
||||
Given /^I have ([0-9]+) deferred todos$/ do |count|
|
||||
context = @current_user.contexts.create!(:name => "context B")
|
||||
count.to_i.downto 1 do |i|
|
||||
|
|
@ -66,6 +88,14 @@ 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 context "([^"]*)" with tags "([^"]*)"$/ do |action_description, context_name, tag_list|
|
||||
Given "I have a todo \"#{action_description}\" in context \"#{context_name}\" with tags \"#{tag_list}\""
|
||||
@todo.show_from = @current_user.time + 1.week
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
####### COMPLETED TODOS #######
|
||||
|
||||
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
|
||||
|
|
@ -117,25 +147,13 @@ Given /^I have ([0-9]+) completed todos with a note in project "([^"]*)" in cont
|
|||
@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|
|
||||
context = @current_user.contexts.find_or_create(:name => context_name)
|
||||
project = @current_user.projects.find_or_create(:name => project_name)
|
||||
@todo = @current_user.todos.create!(:context_id => context.id, :project_id => project.id, :description => action_description)
|
||||
@todo.tag_with(tags)
|
||||
@todo.save
|
||||
end
|
||||
|
||||
Given /^I have a todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)" that is due next week$/ do |action_description, project_name, tags, context_name|
|
||||
Given "I have a todo with description \"#{action_description}\" in project \"#{project_name}\" with tags \"#{tags}\" in the context \"#{context_name}\""
|
||||
@todo.due = @current_user.time + 1.week
|
||||
@todo.save!
|
||||
end
|
||||
|
||||
Given /^I have a completed todo with description "([^"]*)" in project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |action_description, project_name, tags, context_name|
|
||||
Given "I have a todo with description \"#{action_description}\" in project \"#{project_name}\" with tags \"#{tags}\" in the context \"#{context_name}\""
|
||||
@todo.complete!
|
||||
end
|
||||
|
||||
####### PROJECT WITH TODOS ######
|
||||
|
||||
Given /^I have a project "([^"]*)" that has the following todos$/ do |project_name, todos|
|
||||
Given "I have a project called \"#{project_name}\""
|
||||
@project.should_not be_nil
|
||||
|
|
@ -273,7 +291,6 @@ Then /^I should see an unstarred "([^"]*)"$/ do |action_description|
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
When /^I delete the action "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
|
@ -291,6 +308,18 @@ When /^I delete the todo "([^"]*)"$/ do |action_description|
|
|||
When "I delete the action \"#{action_description}\""
|
||||
end
|
||||
|
||||
When /^I open the notes of "([^"]*)"$/ do |action_description|
|
||||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
show_notes_img = "xpath=//div[@id='line_todo_#{todo.id}']/div/a/img"
|
||||
selenium.click show_notes_img
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_visible "//div[@id='notes_todo_#{todo.id}']"
|
||||
end
|
||||
end
|
||||
|
||||
Then /^I should see ([0-9]+) todos$/ do |count|
|
||||
count.to_i.downto 1 do |i|
|
||||
match_xpath "div["
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue