diff --git a/features/enhanced/form_submission_via_ajax.feature b/features/enhanced/form_submission_via_ajax.feature new file mode 100644 index 00000000..b83ed1b0 --- /dev/null +++ b/features/enhanced/form_submission_via_ajax.feature @@ -0,0 +1,164 @@ +Feature: Form submission via AJAX + In order to keep the AJAX based form submission consistent + As an user + I want to experience the same kind of user journey regardless of using AJAX or not + + Scenario Outline: A feature we should still see the source feature file contents via a dialog box + Given there is a + When I am on "" page + And "
" the "" form + Then I submit the form + Then there should be an AJAX request + When I use the features path link + Then there should be an AJAX request + And a dialog box should appear + + Examples: + | page | item | form action | + | edit feature | feature | update | + + Scenario Outline: After editing a item the hover dialog should still function + Given there is a + When I am on "" page + And "" the "" form + Then I submit the form + When I click "button.display_form" + Then there should be an AJAX request + + Examples: + | page | item | form action | + | new project | project | fill in | + | edit project | project | update | + | new feature | feature | fill in | + | edit feature | feature | update | + | new story | story | fill in | + | edit story | story | update | + | new step | step | fill in | + | edit step | step | update | + + Scenario Outline: The items panel should be visible + Given there is a + When I am on the page + And the is filled in + Then there should be an AJAX call + And the icons panel should be visible + + Examples: + | page | item | form action | + | new project | project | fill in | + | edit project | project | update | + | new feature | feature | fill in | + | edit feature | feature | update | + | new story | story | fill in | + | edit story | story | update | + | new step | step | fill in | + | edit step | step | update | + + Scenario Outline: The order button should still function + Given there is a + When I am on the page + And the is filled in + Then there should be an AJAX call + And the order button should be visible + When I click the "Order" button + Then I should see the handlers + +Examples: + | page | item | form action | + | new project | project | fill in | + | edit project | project | update | + | new feature | feature | fill in | + | edit feature | feature | update | + | new story | story | fill in | + | edit story | story | update | + + # @TODO Add more pagination related scenarios later + Scenario Outline: We should still be able to use the pagination + Given there is a + When I am on the page + And the is filled in + Then there should be an AJAX call + And pagination should be visible + + Examples: + | page | item | form action | + | new project | project | fill in | + | edit project | project | update | + | new feature | feature | fill in | + | edit feature | feature | update | + | new story | story | fill in | + | edit story | story | update | + | new step | step | fill in | + | edit step | step | update | + + Scenario Outline: Animated icon panels should still work + Given there is a + When I am on the page + And the is filled in + Then there should be an AJAX call + And I click panel for the first item in the sortable list + Then the panels icons should be visible + + Examples: + | page | item | form action | + | new project | project | fill in | + | edit project | project | update | + | new feature | feature | fill in | + | edit feature | feature | update | + | new story | story | fill in | + | edit story | story | update | + | new step | step | fill in | + | edit step | step | update | + + Scenario Outline: The submitted form should be hidden + Given there is a + When I am on the page + And the is filled in + Then there should be an AJAX call + And the for should be hidden + + Examples: + | page | item | form action | + | new project | project | fill in | + | edit project | project | update | + | new feature | feature | fill in | + | edit feature | feature | update | + | new story | story | fill in | + | edit story | story | update | + | new step | step | fill in | + | edit step | step | update | + + Scenario Outline: The submitted form can be revealed via a button + Given there is a + When I am on the page + And the is filled in + Then there should be an AJAX call + And the for should be hidden + And there should be a "view form" button + + Examples: + | page | item | form action | + | new project | project | fill in | + | edit project | project | update | + | new feature | feature | fill in | + | edit feature | feature | update | + | new story | story | fill in | + | edit story | story | update | + | new step | step | fill in | + | edit step | step | update | + + Scenario Outline: Should be able to sort the responding + Given there is a + When I am on the page + And the is filled in + Then there should be an AJAX call + And the order button should be visible + When I click the "Order" button + Then I should see the handlers + + Examples: + | page | item | form action | + | edit project | project | update | + | edit feature | feature | update | + | edit story | story | update | + | edit step | step | update | diff --git a/features/enhanced/import_feature_ajax_functionality.feature b/features/enhanced/import_feature_ajax_functionality.feature index aa6969fc..b7345c03 100644 --- a/features/enhanced/import_feature_ajax_functionality.feature +++ b/features/enhanced/import_feature_ajax_functionality.feature @@ -50,3 +50,9 @@ Feature: Import feature ajax functionality And I click "button.button" Then the flash message "was created" should be displayed + Scenario: Importing a feature should disable the submit button on sumbission + Given there is a project + And the project has a project path + When I am on the "import project" page + When I import "button.button" + Then the submit button should be disabled \ No newline at end of file diff --git a/features/enhanced/sidebar_functionality.feature b/features/enhanced/sidebar_functionality.feature index 5fedf81e..3e064139 100644 --- a/features/enhanced/sidebar_functionality.feature +++ b/features/enhanced/sidebar_functionality.feature @@ -1,10 +1,11 @@ -Feature: AJAX based Sidebar functionality +Feature: AJAX based sidebar functionality In order to keep the functionality consistent As a user I want to be able to submit a form and have the side bar along with its hover items available to the user + # @TODO move this to the form submission feature file Scenario Outline: Displaying the side bar after form submission - Given there is a + Given there is a When I view the "" path Then the side bar should not be rendered And submit the form @@ -12,7 +13,7 @@ Feature: AJAX based Sidebar functionality And the sidebar will be rendered via AJAX Examples: All pages that should have render the sidebar after an AJAX based form submission - | model | page name | + | item | page name | | project | edit project | | feature | edit feature | | story | edit story | diff --git a/features/step_definitions/features_steps.rb b/features/step_definitions/features_steps.rb index 1500636c..a222f8dc 100644 --- a/features/step_definitions/features_steps.rb +++ b/features/step_definitions/features_steps.rb @@ -67,6 +67,13 @@ click_link 'Stories' end +When /^I fill in the feature form"$/ do + When %{we fill in the feature title with 'Logging in'} + When %{we fill in the feature in_order with 'to create the best app'} + When %{we fill in the feature as_a with 'user'} + When %{we fill in the feature i_want with 'the best project ever'} +end + Then /^I should see a list of features$/ do response.should have_selector :ul do |list| list.should have_selector :li diff --git a/features/step_definitions/general_steps.rb b/features/step_definitions/general_steps.rb index e45ca5ed..3bfee855 100644 --- a/features/step_definitions/general_steps.rb +++ b/features/step_definitions/general_steps.rb @@ -12,4 +12,17 @@ When /^we submit the new feature$/ do click_button 'save' -end \ No newline at end of file +end + +# @TODO Refactor to work with other form actions +When /^"([^\"]*)" the "([^\"]*)" form$/ do |form_action, item| + case form_action + when /update/ + # Do nothing + when /fill in/ + When %{I fill in the #{item} form"} + else + raise "Can't find form action\"#{form_action}\".\n" + + "Now, go and add a mapping in #{__FILE__}" + end +end diff --git a/features/step_definitions/projects_steps.rb b/features/step_definitions/projects_steps.rb index 8e181cac..42660bed 100644 --- a/features/step_definitions/projects_steps.rb +++ b/features/step_definitions/projects_steps.rb @@ -141,6 +141,12 @@ end end +When /^I fill in the project form"$/ do + When %{we fill in the project title with 'A project'} + When %{we fill in the project aim with 'An aim'} + When %{we fill in the project description with 'A description'} +end + Then /^submit the form$/ do click_button 'save' end diff --git a/features/step_definitions/selenium_steps.rb b/features/step_definitions/selenium_steps.rb index 208fae20..2d4e5dab 100644 --- a/features/step_definitions/selenium_steps.rb +++ b/features/step_definitions/selenium_steps.rb @@ -60,6 +60,10 @@ selenium.click "css=button.button" end +When /^I use the features path link$/ do + click_link "#{@feature.path}" +end + Then /^the project's information will be display in the sidebar$/ do selenium.wait_for_visible("project_1") end @@ -135,7 +139,7 @@ end Then /^I should see a hover dialog box$/ do - selenium.wait_for_visible("css=div.hover") + selenium.wait_for_visible("css=div.hover", :timeout_in_seconds => 10) end Then /^I should not see a hover dialog box$/ do @@ -218,4 +222,8 @@ Then /^a dialog box should appear$/ do selenium.wait_for_visible("css=div.dialog", :timeout_in_seconds => 10) +end + +Then /^the submit button should be disabled$/ do + selenium.wait_for_element("css=button.ui-button-disabled", :timeout_in_seconds => 10) end \ No newline at end of file diff --git a/features/step_definitions/steps_steps.rb b/features/step_definitions/steps_steps.rb index 539e9b10..9495a6aa 100644 --- a/features/step_definitions/steps_steps.rb +++ b/features/step_definitions/steps_steps.rb @@ -17,6 +17,9 @@ When /^the step is viewed$/ do visit step_path @step end +When /^I fill in the step form"$/ do + When %{we fill in the step title with 'Given we have a new step'} +end Then /^the new step form should be displayed$/ do response.should have_selector :form diff --git a/features/step_definitions/stories_steps.rb b/features/step_definitions/stories_steps.rb index 66321312..0c39e695 100644 --- a/features/step_definitions/stories_steps.rb +++ b/features/step_definitions/stories_steps.rb @@ -53,6 +53,10 @@ visit story_path @story end +When /^I fill in the story form"$/ do + When %{we fill in the story scenario with 'this is our stories scenario'} +end + Then /^there should be a list of stories$/ do response.should have_selector(:div) do |content| content.should have_selector(:ul) do |list| diff --git a/features/support/paths.rb b/features/support/paths.rb index c59246cd..42820626 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -12,6 +12,8 @@ def path_to(page_name) '/' when /project show/ project_path(@project) + when /new feature/ + new_feature_path when /export feature/ export_feature_path @feature when /import project/ diff --git a/public/javascripts/form.js b/public/javascripts/form.js index 9c378f50..698a5516 100644 --- a/public/javascripts/form.js +++ b/public/javascripts/form.js @@ -31,8 +31,9 @@ $(document).ready(function() { if ($form.hasClass('hidden') == false) { // here is where we make our necessary form response for all our AJAX based responses $('#wrapper').append($form.hide()); - $('view form').insertBefore('#wrapper form') - .addClass('ui-widget ui-widget-content ui-corner-all'); + $('