[Git][noosfero/noosfero][master] 6 commits: Fix follow step on selenium

Bráulio Bhavamitra gitlab at mg.gitlab.com
Sun Feb 21 11:52:12 BRT 2016


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
00c832e0 by Braulio Bhavamitra at 2016-02-21T11:51:07-03:00
Fix follow step on selenium

- - - - -
7aa42ede by Braulio Bhavamitra at 2016-02-21T11:51:07-03:00
selenium: Speed up visibility checks

This improves selenium and plugins tasks by more than 10 minutes
See https://blog.codeship.com/faster-rails-tests/

- - - - -
414bafe6 by Braulio Bhavamitra at 2016-02-21T11:51:07-03:00
cucumber: add pry debug step

- - - - -
1a13685c by Braulio Bhavamitra at 2016-02-21T11:51:07-03:00
categories_block: Elements are not clickable on blocks edition

So use the block at the environment page

- - - - -
e43fc83f by Braulio Bhavamitra at 2016-02-21T11:51:07-03:00
manage_categories: Also show Products besides Services

- - - - -
3000e1ea by Braulio Bhavamitra at 2016-02-21T11:51:07-03:00
stoa: call #reset_column_information to refresh table existence

- - - - -


9 changed files:

- features/admin_categories.feature
- features/categories_block.feature
- features/comment.feature
- features/manage_categories.feature
- features/step_definitions/custom_web_steps.rb
- features/step_definitions/web_steps.rb
- features/support/debug.rb
- features/support/env.rb
- plugins/stoa/test/functional/account_controller_test.rb


Changes:

=====================================
features/admin_categories.feature
=====================================
--- a/features/admin_categories.feature
+++ b/features/admin_categories.feature
@@ -45,7 +45,7 @@ Feature: manage categories
     And I should see "Steak"
     When I follow "Hide"
     Then I should not see "Vegetarian"
-    And "Steak" should not be visible within "div"
+    And I should not see "Steak"
 
   @selenium
   Scenario: the show link is available just for categories with category tree


=====================================
features/categories_block.feature
=====================================
--- a/features/categories_block.feature
+++ b/features/categories_block.feature
@@ -44,6 +44,7 @@ Feature: categories_block
     And I follow "Edit" within ".block-outer .categories-block"
     And I check "Product"
     And I press "Save"
+    And I go to /
     Then I should see "Food"
     And I should see "Book"
     And "Vegetarian" should not be visible within "span#category-name"
@@ -62,6 +63,7 @@ Feature: categories_block
     And I follow "Edit" within ".block-outer .categories-block"
     And I check "Product"
     And I press "Save"
+    And I go to /
     Then I should see "Book"
     And "Literature" should not be visible within "span#category-name"
     When I follow "block_2_category_2"


=====================================
features/comment.feature
=====================================
--- a/features/comment.feature
+++ b/features/comment.feature
@@ -96,4 +96,4 @@ Feature: comment
   Scenario: hide post a comment button when clicked
     Given I am on /booking/article-to-comment
     And I follow "Post a comment"
-    Then "Post a comment" should not be visible within "#article"
+    Then "Post comment" should not be visible within "#article"


=====================================
features/manage_categories.feature
=====================================
--- a/features/manage_categories.feature
+++ b/features/manage_categories.feature
@@ -27,5 +27,7 @@ Feature: manage categories
     Then I should not see "Beans"
     And I should not see "Potatoes"
     When I follow "Show"
+    And I wait 0.5 seconds for Services show animation to finish
+    And I follow "Show"
     Then I should see "Beans"
     And I should see "Potatoes"


=====================================
features/step_definitions/custom_web_steps.rb
=====================================
--- a/features/step_definitions/custom_web_steps.rb
+++ b/features/step_definitions/custom_web_steps.rb
@@ -1,13 +1,9 @@
 Then /^"([^"]*)" should not be visible within "([^"]*)"$/ do |text, selector|
-  if page.has_content?(text)
-    page.should have_no_css(selector, :text => text, :visible => false)
-  end
+  page.should have_no_css selector, text: text, visible: false
 end
 
 Then /^"([^"]*)" should be visible within "([^"]*)"$/ do |text, selector|
-  if page.has_content?(text)
-    page.should have_css(selector, :text => text, :visible => false)
-  end
+  page.should have_css selector, text: text, visible: false
 end
 
 Then /^I should see "([^"]*)" link$/ do |text|


=====================================
features/step_definitions/web_steps.rb
=====================================
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -7,7 +7,7 @@
 
 require 'uri'
 require 'cgi'
-require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
+require_relative '../support/paths'
 
 module WithinHelpers
   def with_scope(locator)
@@ -39,37 +39,15 @@ end
 
 When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
   with_scope(selector) do
-    begin
-      click_link(link, :match => :prefer_exact)
-    rescue Selenium::WebDriver::Error::UnknownError => selenium_error
-      if selenium_error.message.start_with? 'Element is not clickable at point'
-        link = find_link(link)
-        href = link[:href]
-        onclick = link[:onClick]
-
-        warn "#{selenium_error.message}\n\n"\
-             "Trying to overcome this by:\n"
-
-        onclick_return = true
-
-        unless onclick.nil?
-          warn "\t* Running onClick JS:\n"\
-               "\t\t'#{onclick}'\n"
-          onclick_return = page.execute_script onclick
-        end
-
-        if onclick_return
-          warn "\t* Redirecting you to the link's href:\n"\
-               "\t\t'#{href}'\n"
-
-          visit href
-        end
-
-        warn "\nGood luck and be careful that this may produce hidden links to work on tests!\n"
-      else
-        raise selenium_error
-      end
+    link   = find :link_or_button, link, match: :prefer_exact
+    # If the link has child elements, then $(link).click() has no effect,
+    # so find the first child and click on it.
+    if Capybara.default_driver == :selenium
+      target = link.all('*').first || link
+    else
+      target = link
     end
+    target.click
   end
 end
 


=====================================
features/support/debug.rb
=====================================
--- a/features/support/debug.rb
+++ b/features/support/debug.rb
@@ -21,3 +21,8 @@ Before do |scenario|
     puts "Can't find debugger or pry to debug"
   end
 end
+
+Then /^I open pry$/ do
+  require'pry';binding.pry
+end
+


=====================================
features/support/env.rb
=====================================
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -65,5 +65,13 @@ Before do
   fixtures_folder = Rails.root.join('test', 'fixtures')
   fixtures = ['environments', 'roles']
   ActiveRecord::Fixtures.create_fixtures(fixtures_folder, fixtures)
+
+  # The same browser session is used across tests, so expire caching
+  # can create changes from scenario to another.
+  e=Environment.default
+  e.home_cache_in_minutes    = 0
+  e.general_cache_in_minutes = 0
+  e.profile_cache_in_minutes = 0
+  e.save
 end
 


=====================================
plugins/stoa/test/functional/account_controller_test.rb
=====================================
--- a/plugins/stoa/test/functional/account_controller_test.rb
+++ b/plugins/stoa/test/functional/account_controller_test.rb
@@ -15,6 +15,7 @@ class AccountControllerTest < ActionController::TestCase
     t.date     "dtanas"
   end
   ActiveRecord::Base.establish_connection(:test)
+  StoaPlugin::UspUser.reset_column_information
 
   def setup
     @controller = AccountController.new



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c7574edc905cb0b5b8afee924b468b13c7107053...3000e1ea9935f201af8e4c87c9a1780033d89b6a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160221/c9216ab0/attachment-0001.html>


More information about the Noosfero-dev mailing list