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

Update RN pipeline to use Maze Runner v7 #1886

Merged
merged 7 commits into from
Dec 8, 2022
Merged
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 docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ services:
- ./test/react-native-cli/features/:/app/features

react-native-maze-runner:
image: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-v6-cli
image: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-v7-cli
environment:
BUILDKITE:
BUILDKITE_BRANCH:
Expand Down
2 changes: 1 addition & 1 deletion test/react-native/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

gem 'cocoapods'

gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v6.9.1'
gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v7.7.0'

# Use a branch of Maze Runner
#gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', branch: 'tms/use-maze-check'
Expand Down
48 changes: 26 additions & 22 deletions test/react-native/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
GIT
remote: https://github.com/bugsnag/maze-runner
revision: 912006496701a0b70191470d8ec612367e5f4b4f
tag: v6.9.1
revision: 07e5d231773bc740b1d8de4d5c311b5c73f86e12
tag: v7.7.0
specs:
bugsnag-maze-runner (6.9.1)
appium_lib (~> 11.2.0)
bugsnag-maze-runner (7.7.0)
appium_lib (~> 12.0)
appium_lib_core (~> 5.4.0)
bugsnag (~> 6.24)
cucumber (~> 7.1)
cucumber-expressions (~> 6.0.0)
Expand All @@ -13,7 +14,7 @@ GIT
os (~> 1.0.0)
rake (~> 12.3.3)
rubyzip (~> 2.3.2)
selenium-webdriver (~> 3.11)
selenium-webdriver (~> 4.0)
test-unit (~> 3.5.2)
webrick (~> 1.7.0)

Expand All @@ -33,18 +34,18 @@ GEM
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
appium_lib (11.2.0)
appium_lib_core (~> 4.1)
appium_lib (12.0.1)
appium_lib_core (~> 5.0)
nokogiri (~> 1.8, >= 1.8.1)
tomlrb (~> 1.1)
appium_lib_core (4.7.1)
tomlrb (>= 1.1, < 3.0)
appium_lib_core (5.4.0)
faye-websocket (~> 0.11.0)
selenium-webdriver (~> 3.14, >= 3.14.1)
selenium-webdriver (~> 4.2, < 4.6)
atomos (0.1.3)
bugsnag (6.24.2)
bugsnag (6.25.0)
concurrent-ruby (~> 1.0)
builder (3.2.4)
childprocess (3.0.0)
childprocess (4.1.0)
claide (1.1.0)
cocoapods (1.11.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -136,38 +137,41 @@ GEM
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2022.0105)
mini_portile2 (2.7.1)
mini_portile2 (2.8.0)
minitest (5.15.0)
molinillo (0.8.0)
multi_test (0.1.2)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
nokogiri (1.13.1)
mini_portile2 (~> 2.7.0)
nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
optimist (3.0.1)
os (1.0.1)
power_assert (2.0.1)
power_assert (2.0.2)
public_suffix (4.0.6)
racc (1.6.0)
racc (1.6.1)
rake (12.3.3)
rexml (3.2.5)
ruby-macho (2.5.1)
rubyzip (2.3.2)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
selenium-webdriver (4.5.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sys-uname (1.2.2)
ffi (~> 1.1)
test-unit (3.5.3)
test-unit (3.5.5)
power_assert
tomlrb (1.3.0)
tomlrb (2.0.3)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
webrick (1.7.0)
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
48 changes: 31 additions & 17 deletions test/react-native/features/steps/react-native-steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,42 @@
}
end

Then('the app is not running') do
Maze::Wait.new(interval: 1, timeout: 10).until do
case Maze::Helper.get_current_platform
when 'ios'
state = Maze.driver.app_state('org.reactjs.native.example.reactnative')
$logger.info "The app is #{state}"
state == :not_running
when 'android'
state = Maze.driver.app_state('com.reactnative')
$logger.info "The app is #{state}"
# workaround for faulty app state detection in appium v1.23 and lower on
# Android where an app that is not running is detected to be running in
# the background
state == :not_running || state == :running_in_background
end
# Waits for up to 10 seconds for the app to stop running. It seems that Appium doesn't always
# get the state correct (e.g. when backgrounding the app, or on old Android versions), so we
# don't fail if it still says running after the time allowed.
def wait_for_app_state(expected_state)
max_attempts = 20
attempts = 0
state = get_app_state
until (attempts >= max_attempts) || state == expected_state
attempts += 1
state = get_app_state
sleep 0.5
end
$logger.warn "App state #{state} instead of #{expected_state} after 10s" unless state == expected_state
state
Comment on lines +23 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is equivalent:

Suggested change
max_attempts = 20
attempts = 0
state = get_app_state
until (attempts >= max_attempts) || state == expected_state
attempts += 1
state = get_app_state
sleep 0.5
end
$logger.warn "App state #{state} instead of #{expected_state} after 10s" unless state == expected_state
state
wait = Maze::Wait.new(interval: 0.5, timeout: 10)
state = get_app_state
success = wait.until do
state = get_app_state
state == expected_state
end
$logger.warn "App state #{state} instead of #{expected_state} after 10s" unless success
state

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I shall try to remember to update this the next time I'm there, rather than suffer a full rebuild on CI right now.

end

def get_app_state
case Maze::Helper.get_current_platform
when 'ios'
Maze.driver.app_state('org.reactjs.native.example.reactnative')
when 'android'
Maze.driver.app_state('com.reactnative')
end
end

When('I relaunch the app after a crash') do
# Wait for the app to stop running before relaunching
step 'the app is not running'
state = wait_for_app_state :not_running
# TODO: Really we should be using terminate_app/activate_app with the newer Appium client,
# but for some reason they seem to make some scenarios flaky (presumably due to the
# nature of how/when they close the app).
if state != :not_running
Maze.driver.close_app
# Maze.driver.terminate_app Maze.driver.app_id
end
Maze.driver.launch_app
# Maze.driver.activate_app Maze.driver.app_id
end

When('I clear any error dialogue') do
Expand Down
13 changes: 9 additions & 4 deletions test/react-native/features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
Maze.config.receive_requests_wait = 30
end

Before('@android_only') do |scenario|
skip_this_scenario("Skipping scenario") if Maze.driver.capabilities["os"].eql?('ios')
Before do
# See https://www.browserstack.com/docs/app-automate/appium/troubleshooting/app-orientation-issues
Maze.driver.set_rotation(:portrait)
end

Before('@ios_only') do |scenario|
skip_this_scenario("Skipping scenario") if Maze.driver.capabilities["os"].eql?('android')
Before('@android_only') do |_scenario|
skip_this_scenario("Skipping scenario") unless Maze::Helper.get_current_platform == 'android'
end

Before('@ios_only') do |_scenario|
skip_this_scenario("Skipping scenario") unless Maze::Helper.get_current_platform == 'ios'
end

Before('@navigation') do |scenario|
Expand Down