[PATCH] JS test example cucumber

Tomáš Hrčka thrcka at redhat.com
Wed Aug 1 06:35:27 UTC 2012


---
 src/config/cucumber.yml                           |  2 +-
 src/features/js/pretty_filter_view_switch.feature | 64 +++++++++++++++++++++++
 src/features/step_definitions/custom_web_steps.rb |  5 ++
 src/features/step_definitions/web_steps.rb        |  2 +-
 src/features/support/paths.rb                     |  4 ++
 src/spec/requests/pretty_filter_switches_spec.rb  | 19 +++++++
 6 files changed, 94 insertions(+), 2 deletions(-)
 create mode 100644 src/features/js/pretty_filter_view_switch.feature
 create mode 100644 src/spec/requests/pretty_filter_switches_spec.rb

diff --git a/src/config/cucumber.yml b/src/config/cucumber.yml
index 49823b3..8b2ee74 100644
--- a/src/config/cucumber.yml
+++ b/src/config/cucumber.yml
@@ -3,7 +3,7 @@ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
 rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
 std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
 %>
-default: <%= std_opts %> features
+default: <%= std_opts %> -r features
 wip: --tags @wip:3 --wip features
 rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
 junit: --format junit --out results/ features
diff --git a/src/features/js/pretty_filter_view_switch.feature b/src/features/js/pretty_filter_view_switch.feature
new file mode 100644
index 0000000..6af92ef
--- /dev/null
+++ b/src/features/js/pretty_filter_view_switch.feature
@@ -0,0 +1,64 @@
+Feature: Switch pretty filter view on Pools page
+  In order to use JS enhanced UI
+  As an user
+  I want to be able to switch between view types and tabs
+
+  Background:
+    Given I am an authorised user
+    And I am logged in
+    And a pool "Default" exists
+
+  @javascript
+  Scenario: Switch from pretty to filter view
+    Given I am on the pools page
+    And I should see selected "pretty_view"
+    When I follow "filter_view"
+    Then I should see selected "filter_view"
+    Then I should see "Pool name" within ".flat.checkbox_table"
+    When I follow "pretty_view"
+    And I should see selected "pretty_view"
+    Then I should see "Default" within "#pools-list"
+
+  @javascript
+  Scenario: Switch tabs and from filter pretty view
+    Given I am on the pools page
+    And I should see selected "pretty_view"
+    And I follow "filter_view"
+    And I should see selected "filter_view"
+    And I should see "Pool name" within ".flat.checkbox_table"
+    And I follow link with ID "details_deployments"
+    And I should see selected "filter_view"
+    When I follow "pretty_view"
+    And I should see selected "pretty_view"
+    Then I should see "Default" within "#pools-list"
+
+  @javascript
+  Scenario: Switch tabs and filter to pretty view
+    Given I am on the pools index filter view
+    Then I should see "Pool name" within ".flat.checkbox_table"
+    And I follow link with ID "details_deployments"
+    Then show me the page
+    And I should see selected "filter_view"
+    When I follow "pretty_view"
+    And I should see selected "pretty_view"
+    Then I should see "Default" within "#pools-list"
+
+  @javascript
+  Scenario: Switch tabs and filter to pretty view
+    Given I am on the pools index filter view
+    Then I should see "Pool name" within ".flat.checkbox_table"
+    And I follow link with ID "details_instances"
+    And I should see selected "filter_view"
+    When I follow "pretty_view"
+    And I should see selected "pretty_view"
+    Then I should see "Default" within "#pools-list"
+
+  @javascript
+  Scenario: Switch tabs and filter to pretty view
+    Given I am on the pools index filter view
+    Then I should see "Pool name" within ".flat.checkbox_table"
+    And I follow link with ID "details_pools"
+    And I should see selected "filter_view"
+    When I follow "pretty_view"
+    And I should see selected "pretty_view"
+    Then I should see "Default" within "#pools-list"
diff --git a/src/features/step_definitions/custom_web_steps.rb b/src/features/step_definitions/custom_web_steps.rb
index 10079b5..2d6c052 100644
--- a/src/features/step_definitions/custom_web_steps.rb
+++ b/src/features/step_definitions/custom_web_steps.rb
@@ -16,3 +16,8 @@
 When /^(?:|I )follow link with ID "([^"]*)"$/ do |link_id|
   click_link(link_id)
 end
+
+Then /^I should see selected "(.*?)"$/ do |active_class|
+  page.should have_css("##{active_class}.active")#"view-toggle.active.pretty.view-toggle")
+end
+
diff --git a/src/features/step_definitions/web_steps.rb b/src/features/step_definitions/web_steps.rb
index 236a801..3bb4ec6 100644
--- a/src/features/step_definitions/web_steps.rb
+++ b/src/features/step_definitions/web_steps.rb
@@ -57,7 +57,7 @@ When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
 end
 
 Given /^(?:|I )am on (.+)$/ do |page_name|
-  page.driver.header 'Accept-Language', 'en-US'
+  #page.driver.header 'Accept-Language', 'en-US'
   visit path_to(page_name)
 end
 
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index f809a8c..9ae07ec 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -176,6 +176,10 @@ module NavigationHelpers
       pool = Pool.find_by_name($1)
       pool_path(pool, :view => 'filter')
 
+    when /^the pools index filter view$/
+      pools_path(:view => 'filter')
+    when /^the pools index pretty view$/
+      pools_path(:view => 'pretty')
     when /^the my user page$/
       user_path(user)
 
diff --git a/src/spec/requests/pretty_filter_switches_spec.rb b/src/spec/requests/pretty_filter_switches_spec.rb
new file mode 100644
index 0000000..c34d0d9
--- /dev/null
+++ b/src/spec/requests/pretty_filter_switches_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe "PrettyFilterSwitches" do
+  before do
+    @user = FactoryGirl.create :tuser
+  end
+
+  describe "Pools" do
+    it "should switch from pretty to filter", :js => true do
+      visit root_path
+      fill_in "login", :with => @user.login
+      fill_in "password", :with => "secret"
+      click_button "Login"
+      visit root_path
+      #click_button "#filter_view"
+      save_and_open_page
+    end
+  end
+end
-- 
1.7.11.2




More information about the aeolus-devel mailing list