Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to the method element_is_not_hidden #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gem/lib/frank-cucumber/frank_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def wait_for_nothing_to_be_animating( timeout = false )
# a better name for this method would be element_exists_and_is_not_hidden
def element_is_not_hidden(selector)
matches = frankly_map( selector, 'FEX_isVisible' )
matches.delete(false)
matches.delete(0)
!matches.empty?
end

Expand Down
75 changes: 75 additions & 0 deletions gem/test/frank_helper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
require_relative 'test_helper.rb'

class HelperForTesting
include Frank::Cucumber::FrankHelper

def mock_frank_server
RR.mock(@mock_frank_server = Object.new)
end

private
def frank_server
@mock_frank_server
end
end

describe "frank helper" do
the_helper = nil

before do
the_helper = HelperForTesting.new
end

def successful_response_array(array)
%Q{ { "outcome": "SUCCESS", "results": #{array} } }
end

describe "when determining visibility of selector" do

def setup_the_helper_mock_result_array(helper, array)
operation_map = Frank::Cucumber::Gateway.build_operation_map("FEX_isVisible", [])
helper.mock_frank_server.send_post('map',
:query => anything,
:operation => operation_map,
:selector_engine => anything) { successful_response_array(array) }
end

it "correctly processes no value case" do
selector = "NoView"
setup_the_helper_mock_result_array(the_helper, [])
the_helper.element_is_not_hidden( selector ).must_equal(false)
end

it "filters out the only invisible element" do
selector = "SingleView"
setup_the_helper_mock_result_array(the_helper, [0])
the_helper.element_is_not_hidden( selector ).must_equal(false)
end

it "keeps the only visible element" do
selector = "SingleView"
setup_the_helper_mock_result_array(the_helper, [1])
the_helper.element_is_not_hidden( selector ).must_equal(true)
end

it "filters out invisible elements out of multiple candidates" do
selector = "MultipleViews"
setup_the_helper_mock_result_array(the_helper, [0, 0, 0, 0, 0])
the_helper.element_is_not_hidden( selector ).must_equal(false)
end

it "keeps all the visible elements" do
selector = "MultipleViews"
setup_the_helper_mock_result_array(the_helper, [1, 1, 1])
the_helper.element_is_not_hidden( selector ).must_equal(true)
end

it "only filters out invisible and keeps all the visible elements" do
selector = "MultipleViews"
setup_the_helper_mock_result_array(the_helper, [1, 0, 1, 0, 1])
the_helper.element_is_not_hidden( selector ).must_equal(true)
end

end

end