diff --git a/features/context_list.feature b/features/context_list.feature index a1c3afa8..3b864fef 100644 --- a/features/context_list.feature +++ b/features/context_list.feature @@ -9,6 +9,24 @@ Feature: Manage the list of contexts | testuser | secret | false | And I have logged in as "testuser" with password "secret" + Scenario: The list of contexts contain all contexts + Given I have the following contexts + | name | hide | + | @ipad | false | + | @home | false | + | @boss | false | + When I go to the contexts page + Then I should see "@ipad" + And I should see "@home" + And I should see "@boss" + And the badge should show 3 + + Scenario: Clicking on a project takes me to the context page + Given I have a context called "@computer" + When I go to the contexts page + And I follow "@computer" + Then I should be on the context page for "@computer" + @selenium Scenario: Delete context from context page should update badge Given I have a context called "@computer" @@ -76,13 +94,20 @@ Feature: Manage the list of contexts And I add a new active context "foo, bar" Then I should see "Name cannot contain the comma" - @selenium @wip + @selenium Scenario: I can drag and drop to order the contexts - # TODO: pending scenario - Given this is a pending scenario + Given I have the following contexts + | name | + | @ipad | + | @home | + | @boss | + When I go to the contexts page + Then context "@ipad" should be above context "@home" + When I drag context "@ipad" below context "@home" + Then context "@home" should be above context "@ipad" - @selenium @wip - Scenario: Hiding and unhiding the new project form + @selenium + Scenario: Hiding and unhiding the new context form When I go to the contexts page Then the new context form should be visible When I follow "Hide form" diff --git a/features/project_list.feature b/features/project_list.feature index e682797b..862716cd 100644 --- a/features/project_list.feature +++ b/features/project_list.feature @@ -12,10 +12,11 @@ Feature: Manage the list of projects And there exists a project "a project name starting with a" for user "testuser" And I have logged in as "testuser" with password "secret" - Scenario: The list of project contain all projects + Scenario: The list of projects contain all projects When I go to the projects page Then I should see "manage me" And I should see "upgrade jquery" + And I should see "a project name starting with a" And the badge should show 3 Scenario: Clicking on a project takes me to the project page diff --git a/features/step_definitions/context_list_steps.rb b/features/step_definitions/context_list_steps.rb index e808ceac..e7906782 100644 --- a/features/step_definitions/context_list_steps.rb +++ b/features/step_definitions/context_list_steps.rb @@ -42,6 +42,31 @@ When /^I add a new hidden context "([^"]*)"$/ do |context_name| submit_new_context_form end +Then /^context "([^"]*)" should be above context "([^"]*)"$/ do |context_high, context_low| + high_id = @current_user.contexts.find_by_name(context_high).id + low_id = @current_user.contexts.find_by_name(context_low).id + high_pos = selenium.get_element_position_top("//div[@id='context_#{high_id}']").to_i + low_pos = selenium.get_element_position_top("//div[@id='context_#{low_id}']").to_i + (high_pos < low_pos).should be_true +end + +When /^I drag context "([^"]*)" below context "([^"]*)"$/ do |context_drag, context_drop| + drag_id = @current_user.contexts.find_by_name(context_drag).id + drop_id = @current_user.contexts.find_by_name(context_drop).id + + container_height = selenium.get_element_height("//div[@id='container_context_#{drag_id}']").to_i + vertical_offset = container_height*2 + coord_string = "10,#{vertical_offset}" + + drag_context_handle_xpath = "//div[@id='context_#{drag_id}']//span[@class='handle']" + drop_context_container_xpath = "//div[@id='container_context_#{drop_id}']" + + selenium.mouse_down_at(drag_context_handle_xpath,"2,2") + selenium.mouse_move_at(drop_context_container_xpath,coord_string) + # no need to simulate mouse_over for this test + selenium.mouse_up_at(drop_context_container_xpath,coord_string) +end + Then /^I should see that a context named "([^"]*)" is not present$/ do |context_name| Then "I should not see \"#{context_name}\"" end @@ -60,6 +85,14 @@ Then /^I should see the context "([^"]*)" under "([^"]*)"$/ do |context_name, st response.should have_xpath("//div[@id='list-contexts-#{state}']//div[@id='context_#{context.id}']") end +Then /^the new context form should be visible$/ do + selenium.is_visible("context_new").should be_true +end + +Then /^the new context form should not be visible$/ do + selenium.is_visible("context_new").should be_false +end + Then /^the context list badge for ([^"]*) contexts should show (\d+)$/ do |state_name, count| selenium.get_text("xpath=//span[@id='#{state_name}-contexts-count']").should == count end diff --git a/features/step_definitions/context_steps.rb b/features/step_definitions/context_steps.rb index 5a7dfbfa..40a8b3ba 100644 --- a/features/step_definitions/context_steps.rb +++ b/features/step_definitions/context_steps.rb @@ -47,7 +47,11 @@ end Given /^I have the following contexts$/ do |table| Context.delete_all table.hashes.each do |hash| - context = Factory(:context, hash) + context = @current_user.contexts.create!(:name => hash[:name]) + unless hash[:hide].blank? + context.hide = hash[:hide] == true + context.save! + end end end