diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml deleted file mode 100644 index 9d1f94a29..000000000 --- a/.azure-pipelines.yml +++ /dev/null @@ -1,347 +0,0 @@ -# https://github.com/actions/virtual-environments/tree/main/images/macos -variables: - MIN_VM_IMAGE: macOS-10.14 - MIN_XCODE_VERSION: 10.2 - # Xcode 10.0 did not have Apple TV - MIN_TV_XCODE_VERSION: 10.2 - MIN_TV_PLATFORM_VERSION: 12.2 - MIN_TV_DEVICE_NAME: Apple TV - MIN_PLATFORM_VERSION: 12.2 - MIN_IPHONE_DEVICE_NAME: iPhone X - MIN_IPAD_DEVICE_NAME: iPad Air 2 - MAX_VM_IMAGE: macOS-10.15 - MAX_XCODE_VERSION: 12.4 - MAX_PLATFORM_VERSION: 14.4 - MAX_PLATFORM_VERSION_TV: 14.3 - MAX_IPHONE_DEVICE_NAME: iPhone 11 Pro Max - MAX_TV_DEVICE_NAME: Apple TV 4K - MAX_IPAD_DEVICE_NAME: iPad Pro (11-inch) (2nd generation) - DEFAULT_NODE_VERSION: "12.x" - DEFAULT_RUBY_VERSION: "2.7" - - -pool: - vmImage: "$(MAX_VM_IMAGE)" - - -parameters: -- name: integrationJobs - type: object - default: - - action: int_test_1 - dest: iphone - - action: int_test_2 - dest: iphone - - action: int_test_3 - dest: iphone - - action: int_test_1 - dest: ipad - - action: int_test_2 - dest: ipad - - action: int_test_3 - dest: ipad - - -stages: -- stage: Unit_Tests_And_Linters - jobs: - - job: Node_Unit_Tests - steps: - - template: azure-templates/node_setup_steps.yml - - script: npm install - - script: npm run test - - # region Build - - template: ./azure-templates/base_job.yml - parameters: - name: Generic_iOS_Build_Max_Xcode - action: build - target: runner - sdk: sim - dest: generic - codeSign: no - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: Generic_tvOS_Build_Max_Xcode - action: build - target: tv_runner - sdk: tv_sim - dest: tv_generic - codeSign: no - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: iOS_Build_Max_Xcode - action: build - target: runner - sdk: sim - iphoneModel: $(MAX_IPHONE_DEVICE_NAME) - ipadModel: $(MAX_IPAD_DEVICE_NAME) - iosVersion: $(MAX_PLATFORM_VERSION) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: tvOS_Build_Max_Xcode - action: build - target: tv_runner - sdk: tv_sim - tvModel: $(MAX_TV_DEVICE_NAME) - tvVersion: $(MAX_PLATFORM_VERSION_TV) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: Generic_iOS_Build_Min_Xcode - action: build - target: runner - sdk: sim - dest: generic - codeSign: no - xcodeVersion: $(MIN_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - extraXcArgs: IPHONEOS_DEPLOYMENT_TARGET=$(MIN_PLATFORM_VERSION) - - template: ./azure-templates/base_job.yml - parameters: - name: Generic_tvOS_Build_Min_Xcode - action: build - target: tv_runner - dest: tv_generic - sdk: tv_sim - codeSign: no - xcodeVersion: $(MIN_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: iOS_Build_Min_Xcode - action: build - target: runner - sdk: sim - iphoneModel: $(MIN_IPHONE_DEVICE_NAME) - ipadModel: $(MIN_IPAD_DEVICE_NAME) - iosVersion: $(MIN_PLATFORM_VERSION) - xcodeVersion: $(MIN_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: tvOS_Build_Min_Xcode - action: build - target: tv_runner - sdk: tv_sim - dest: tv - tvModel: $(MIN_TV_DEVICE_NAME) - tvVersion: $(MIN_TV_PLATFORM_VERSION) - xcodeVersion: $(MIN_TV_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - # endregion - - # region Analyze - - template: ./azure-templates/base_job.yml - parameters: - name: iOS_Lib_Analyze_Max_Xcode - action: analyze - sdk: sim - target: lib - iphoneModel: $(MAX_IPHONE_DEVICE_NAME) - ipadModel: $(MAX_IPAD_DEVICE_NAME) - iosVersion: $(MAX_PLATFORM_VERSION) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: iOS_Runner_Analyze_Max_Xcode - action: analyze - sdk: sim - target: runner - iphoneModel: $(MAX_IPHONE_DEVICE_NAME) - ipadModel: $(MAX_IPAD_DEVICE_NAME) - iosVersion: $(MAX_PLATFORM_VERSION) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: tvOS_Lib_Analyze_Max_Xcode - action: analyze - target: tv_lib - sdk: tv_sim - tvModel: $(MAX_TV_DEVICE_NAME) - tvVersion: $(MAX_PLATFORM_VERSION_TV) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: tvOS_Runner_Analyze_Max_Xcode - action: analyze - target: tv_runner - sdk: tv_sim - tvModel: $(MAX_TV_DEVICE_NAME) - tvVersion: $(MAX_PLATFORM_VERSION_TV) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: iOS_Lib_Analyze_Min_Xcode - action: analyze - target: lib - sdk: sim - iphoneModel: $(MIN_IPHONE_DEVICE_NAME) - ipadModel: $(MIN_IPAD_DEVICE_NAME) - iosVersion: $(MIN_PLATFORM_VERSION) - xcodeVersion: $(MIN_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: iOS_Runner_Analyze_Min_Xcode - action: analyze - target: runner - sdk: sim - iphoneModel: $(MIN_IPHONE_DEVICE_NAME) - ipadModel: $(MIN_IPAD_DEVICE_NAME) - iosVersion: $(MIN_PLATFORM_VERSION) - xcodeVersion: $(MIN_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: tvOS_Lib_Analyze_Min_Xcode - action: analyze - target: tv_lib - sdk: tv_sim - tvModel: $(MIN_TV_DEVICE_NAME) - tvVersion: $(MIN_TV_PLATFORM_VERSION) - xcodeVersion: $(MIN_TV_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: tvOS_Runner_Analyze_Min_Xcode - action: analyze - target: tv_runner - sdk: tv_sim - tvModel: $(MIN_TV_DEVICE_NAME) - tvVersion: $(MIN_TV_PLATFORM_VERSION) - xcodeVersion: $(MIN_TV_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - # endregion - - # region Unit Tests - - template: ./azure-templates/base_job.yml - parameters: - name: iPhone_Unit_Test_Max_Xcode - action: unit_test - dest: iphone - target: lib - sdk: sim - iphoneModel: $(MAX_IPHONE_DEVICE_NAME) - ipadModel: $(MAX_IPAD_DEVICE_NAME) - iosVersion: $(MAX_PLATFORM_VERSION) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: iPad_Unit_Test_Max_Xcode - action: unit_test - dest: ipad - target: lib - sdk: sim - iphoneModel: $(MAX_IPHONE_DEVICE_NAME) - ipadModel: $(MAX_IPAD_DEVICE_NAME) - iosVersion: $(MAX_PLATFORM_VERSION) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: tvOS_Unit_Test_Max_Xcode - action: tv_unit_test - dest: tv - target: tv_lib - sdk: tv_sim - tvModel: $(MAX_TV_DEVICE_NAME) - tvVersion: $(MAX_PLATFORM_VERSION_TV) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: iPhone_Unit_Test_Min_Xcode - action: unit_test - dest: iphone - target: lib - sdk: sim - iphoneModel: $(MIN_IPHONE_DEVICE_NAME) - ipadModel: $(MIN_IPAD_DEVICE_NAME) - iosVersion: $(MIN_PLATFORM_VERSION) - xcodeVersion: $(MIN_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: iPad_Unit_Test_Min_Xcode - action: unit_test - dest: ipad - target: lib - sdk: sim - iphoneModel: $(MIN_IPHONE_DEVICE_NAME) - ipadModel: $(MIN_IPAD_DEVICE_NAME) - iosVersion: $(MIN_PLATFORM_VERSION) - xcodeVersion: $(MIN_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - - template: ./azure-templates/base_job.yml - parameters: - name: tvOS_Unit_Test_Min_Xcode - action: tv_unit_test - target: tv_lib - sdk: tv_sim - tvModel: $(MIN_TV_DEVICE_NAME) - tvVersion: $(MIN_TV_PLATFORM_VERSION) - xcodeVersion: $(MIN_TV_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - # endregion - -- stage: Integration_Tests - jobs: - - - job: Node_Integration_Tests - variables: - # XCODE_VERSION: $(MAX_XCODE_VERSION) - # DEVICE_NAME: $(MAX_IPHONE_DEVICE_NAME) - # PLATFORM_VERSION: $(MAX_PLATFORM_VERSION) - XCODE_VERSION: 11.7 - DEVICE_NAME: iPhone 11 Pro Max - PLATFORM_VERSION: 13.7 - steps: - - template: azure-templates/node_setup_steps.yml - - script: npm install - - template: azure-templates/bootstrap_steps.yml - - script: npm run e2e-test - - # region Integration Tests Max Xcode - - ${{ each job in parameters.integrationJobs }}: - - template: ./azure-templates/base_job.yml - parameters: - name: ${{ job.dest }}_${{ job.action }}_Max_Xcode - action: ${{ job.action }} - dest: ${{ job.dest }} - target: lib - sdk: sim - iphoneModel: $(MAX_IPHONE_DEVICE_NAME) - ipadModel: $(MAX_IPAD_DEVICE_NAME) - iosVersion: $(MAX_PLATFORM_VERSION) - xcodeVersion: $(MAX_XCODE_VERSION) - vmImage: $(MAX_VM_IMAGE) - # endregion - - # region Integration Tests Min Xcode - - ${{ each job in parameters.integrationJobs }}: - - template: ./azure-templates/base_job.yml - parameters: - name: ${{ job.dest }}_${{ job.action }}_Min_Xcode - action: ${{ job.action }} - dest: ${{ job.dest }} - target: lib - sdk: sim - iphoneModel: $(MIN_IPHONE_DEVICE_NAME) - ipadModel: $(MIN_IPAD_DEVICE_NAME) - iosVersion: $(MIN_PLATFORM_VERSION) - xcodeVersion: $(MIN_XCODE_VERSION) - vmImage: $(MIN_VM_IMAGE) - # endregion diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 4671072fa..000000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -Resources -coverage diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 8a056219d..000000000 --- a/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "appium" -} diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index e18089046..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,4 +0,0 @@ -**Warning:** - -These issues are not tracked. Please create new issues in the main Appium -repository: https://github.com/appium/appium/issues/new diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index efc8b6d5b..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: 2 -updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "11:00" - open-pull-requests-limit: 10 - commit-message: - prefix: "chore" - include: "scope" diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 9cf949503..000000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 8c5f46efa..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,35 +0,0 @@ -# Contributing to WebDriverAgent -We want to make contributing to this project as easy and transparent as -possible. - -## Pull Requests -We actively welcome your pull requests. - -1. Fork the repo and create your branch from `master`. -2. If you've added code that should be tested, add tests -3. If you've changed APIs, update the documentation. -4. Ensure the test suite passes. -5. Make sure your code lints. -6. If you haven't already, complete the Contributor License Agreement ("CLA"). - -## Contributor License Agreement ("CLA") -In order to accept your pull request, we need you to submit a CLA. You only need -to do this once to work on any of Facebook's open source projects. - -Complete your CLA here: - -## Issues -We use GitHub issues to track public bugs. Please ensure your description is -clear and has sufficient instructions to be able to reproduce the issue. - -Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe -disclosure of security bugs. In those cases, please go through the process -outlined on that page and do not file a public issue. - -## Coding Style -* 2 spaces for indentation rather than tabs -* 80 character line length - -## License -By contributing to WebDriverAgent, you agree that your contributions will be licensed -under its [BSD license](LICENSE). diff --git a/Fastlane/Fastfile b/Fastlane/Fastfile deleted file mode 100644 index 39bb9f491..000000000 --- a/Fastlane/Fastfile +++ /dev/null @@ -1,34 +0,0 @@ -XC_PROJECT = File.absolute_path('../WebDriverAgent.xcodeproj') -RETRIES = 3 - -lane :test do - test_run_block = lambda do |testrun_info| - failed_test_count = testrun_info[:failed].size - - if failed_test_count > 0 - UI.important("Failed tests count: #{failed_test_count}") - - try_attempt = testrun_info[:try_count] - if try_attempt < RETRIES - UI.header("Re-running failing tests (attempt #{try_attempt} of #{RETRIES})") - reset_simulator_contents - end - end - end - - # https://docs.fastlane.tools/actions/scan/ - result = multi_scan( - project: XC_PROJECT, - try_count: RETRIES, - fail_build: false, - scheme: ENV['SCHEME'], - sdk: ENV['SDK'], - destination: ENV['DEST'], - testrun_completed_block: test_run_block - ) - unless result[:failed_testcount].zero? - msg = "There are #{result[:failed_testcount]} legitimate failing tests" - UI.message(msg) - raise msg - end -end \ No newline at end of file diff --git a/Fastlane/Pluginfile b/Fastlane/Pluginfile deleted file mode 100644 index 139f3a778..000000000 --- a/Fastlane/Pluginfile +++ /dev/null @@ -1,5 +0,0 @@ -# Autogenerated by fastlane -# -# Ensure this file is checked in to source control! - -gem 'fastlane-plugin-test_center' diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 2ccf2ecb1..000000000 --- a/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source "https://rubygems.org" - -gem "fastlane" -plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') -eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index c6e765de0..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,191 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - CFPropertyList (3.0.2) - addressable (2.7.0) - public_suffix (>= 2.0.2, < 5.0) - atomos (0.1.3) - aws-eventstream (1.1.0) - aws-partitions (1.381.0) - aws-sdk-core (3.109.1) - aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.239.0) - aws-sigv4 (~> 1.1) - jmespath (~> 1.0) - aws-sdk-kms (1.39.0) - aws-sdk-core (~> 3, >= 3.109.0) - aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.83.0) - aws-sdk-core (~> 3, >= 3.109.0) - aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.1) - aws-sigv4 (1.2.2) - aws-eventstream (~> 1, >= 1.0.2) - babosa (1.0.4) - claide (1.0.3) - colored (1.2) - colored2 (3.1.2) - colorize (0.8.1) - commander-fastlane (4.4.6) - highline (~> 1.7.2) - declarative (0.0.20) - declarative-option (0.1.0) - digest-crc (0.6.1) - rake (~> 13.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) - dotenv (2.7.6) - emoji_regex (3.0.0) - excon (0.76.0) - faraday (1.0.1) - multipart-post (>= 1.2, < 3) - faraday-cookie_jar (0.0.7) - faraday (>= 0.8.0) - http-cookie (~> 1.0.0) - faraday_middleware (1.0.0) - faraday (~> 1.0) - fastimage (2.2.0) - fastlane (2.162.0) - CFPropertyList (>= 2.3, < 4.0.0) - addressable (>= 2.3, < 3.0.0) - aws-sdk-s3 (~> 1.0) - babosa (>= 1.0.3, < 2.0.0) - bundler (>= 1.12.0, < 3.0.0) - colored - commander-fastlane (>= 4.4.6, < 5.0.0) - dotenv (>= 2.1.1, < 3.0.0) - emoji_regex (>= 0.1, < 4.0) - excon (>= 0.71.0, < 1.0.0) - faraday (~> 1.0) - faraday-cookie_jar (~> 0.0.6) - faraday_middleware (~> 1.0) - fastimage (>= 2.1.0, < 3.0.0) - gh_inspector (>= 1.1.2, < 2.0.0) - google-api-client (>= 0.37.0, < 0.39.0) - google-cloud-storage (>= 1.15.0, < 2.0.0) - highline (>= 1.7.2, < 2.0.0) - json (< 3.0.0) - jwt (>= 2.1.0, < 3) - mini_magick (>= 4.9.4, < 5.0.0) - multipart-post (~> 2.0.0) - plist (>= 3.1.0, < 4.0.0) - rubyzip (>= 2.0.0, < 3.0.0) - security (= 0.1.3) - simctl (~> 1.6.3) - slack-notifier (>= 2.0.0, < 3.0.0) - terminal-notifier (>= 2.0.0, < 3.0.0) - terminal-table (>= 1.4.5, < 2.0.0) - tty-screen (>= 0.6.3, < 1.0.0) - tty-spinner (>= 0.8.0, < 1.0.0) - word_wrap (~> 1.0.0) - xcodeproj (>= 1.13.0, < 2.0.0) - xcpretty (~> 0.3.0) - xcpretty-travis-formatter (>= 0.0.3) - fastlane-plugin-test_center (3.14.4) - colorize - json - plist - trainer - xcodeproj - xctest_list (>= 1.2.1) - gh_inspector (1.1.3) - google-api-client (0.38.0) - addressable (~> 2.5, >= 2.5.1) - googleauth (~> 0.9) - httpclient (>= 2.8.1, < 3.0) - mini_mime (~> 1.0) - representable (~> 3.0) - retriable (>= 2.0, < 4.0) - signet (~> 0.12) - google-cloud-core (1.5.0) - google-cloud-env (~> 1.0) - google-cloud-errors (~> 1.0) - google-cloud-env (1.3.3) - faraday (>= 0.17.3, < 2.0) - google-cloud-errors (1.0.1) - google-cloud-storage (1.29.1) - addressable (~> 2.5) - digest-crc (~> 0.4) - google-api-client (~> 0.33) - google-cloud-core (~> 1.2) - googleauth (~> 0.9) - mini_mime (~> 1.0) - googleauth (0.14.0) - faraday (>= 0.17.3, < 2.0) - jwt (>= 1.4, < 3.0) - memoist (~> 0.16) - multi_json (~> 1.11) - os (>= 0.9, < 2.0) - signet (~> 0.14) - highline (1.7.10) - http-cookie (1.0.3) - domain_name (~> 0.5) - httpclient (2.8.3) - jmespath (1.4.0) - json (2.3.1) - jwt (2.2.2) - memoist (0.16.2) - mini_magick (4.10.1) - mini_mime (1.0.2) - multi_json (1.15.0) - multipart-post (2.0.0) - nanaimo (0.3.0) - naturally (2.2.0) - os (1.1.1) - plist (3.5.0) - public_suffix (4.0.6) - rake (13.0.1) - representable (3.0.4) - declarative (< 0.1.0) - declarative-option (< 0.2.0) - uber (< 0.2.0) - retriable (3.1.2) - rouge (2.0.7) - rubyzip (2.3.0) - security (0.1.3) - signet (0.14.0) - addressable (~> 2.3) - faraday (>= 0.17.3, < 2.0) - jwt (>= 1.5, < 3.0) - multi_json (~> 1.10) - simctl (1.6.8) - CFPropertyList - naturally - slack-notifier (2.3.2) - terminal-notifier (2.0.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - trainer (0.9.1) - fastlane (>= 2.25.0) - plist (>= 3.1.0, < 4.0.0) - tty-cursor (0.7.1) - tty-screen (0.8.1) - tty-spinner (0.9.3) - tty-cursor (~> 0.7) - uber (0.1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.7) - unicode-display_width (1.7.0) - word_wrap (1.0.0) - xcodeproj (1.19.0) - CFPropertyList (>= 2.3.3, < 4.0) - atomos (~> 0.1.3) - claide (>= 1.0.2, < 2.0) - colored2 (~> 3.1) - nanaimo (~> 0.3.0) - xcpretty (0.3.0) - rouge (~> 2.0.7) - xcpretty-travis-formatter (1.0.0) - xcpretty (~> 0.2, >= 0.0.7) - xctest_list (1.2.1) - -PLATFORMS - ruby - -DEPENDENCIES - fastlane - fastlane-plugin-test_center - -BUNDLED WITH - 1.17.2 diff --git a/Scripts/build.sh b/Scripts/build.sh deleted file mode 100755 index b4f445ce0..000000000 --- a/Scripts/build.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. -# - -set -ex - -function define_xc_macros() { - XC_MACROS="CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO" - - case "$TARGET" in - "lib" ) XC_TARGET="WebDriverAgentLib";; - "runner" ) XC_TARGET="WebDriverAgentRunner";; - "tv_lib" ) XC_TARGET="WebDriverAgentLib_tvOS";; - "tv_runner" ) XC_TARGET="WebDriverAgentRunner_tvOS";; - *) echo "Unknown TARGET"; exit 1 ;; - esac - - case "${DEST:-}" in - "iphone" ) XC_DESTINATION="name=`echo $IPHONE_MODEL | tr -d "'"`,OS=$IOS_VERSION";; - "ipad" ) XC_DESTINATION="name=`echo $IPAD_MODEL | tr -d "'"`,OS=$IOS_VERSION";; - "tv" ) XC_DESTINATION="name=`echo $TV_MODEL | tr -d "'"`,OS=$TV_VERSION";; - "generic" ) XC_DESTINATION="generic/platform=iOS";; - "tv_generic" ) XC_DESTINATION="generic/platform=tvOS" XC_MACROS="${XC_MACROS} ARCHS=arm64";; # tvOS only supports arm64 - esac - - case "$ACTION" in - "build" ) XC_ACTION="build";; - "analyze" ) - XC_ACTION="analyze" - XC_MACROS="${XC_MACROS} CLANG_ANALYZER_OUTPUT=plist-html CLANG_ANALYZER_OUTPUT_DIR=\"$(pwd)/clang\"" - ;; - "unit_test" ) XC_ACTION="test -only-testing:UnitTests";; - "tv_unit_test" ) XC_ACTION="test -only-testing:UnitTests_tvOS";; - esac - - case "$SDK" in - "sim" ) XC_SDK="iphonesimulator";; - "device" ) XC_SDK="iphoneos";; - "tv_sim" ) XC_SDK="appletvsimulator";; - "tv_device" ) XC_SDK="appletvos";; - *) echo "Unknown SDK"; exit 1 ;; - esac - - case "${CODE_SIGN:-}" in - "no" ) XC_MACROS="${XC_MACROS} CODE_SIGNING_ALLOWED=NO";; - esac -} - -function analyze() { - xcbuild - if [[ -z $(find clang -name "*.html") ]]; then - echo "Static Analyzer found no issues" - else - echo "Static Analyzer found some issues" - exit 1 - fi -} - -function xcbuild() { - destination="" - output_command=cat - if [ $(which xcpretty) ] ; then - output_command=xcpretty - fi - if [[ -n "$XC_DESTINATION" ]]; then - xcodebuild \ - -project "WebDriverAgent.xcodeproj" \ - -scheme "$XC_TARGET" \ - -sdk "$XC_SDK" \ - -destination "$XC_DESTINATION" \ - $XC_ACTION \ - $XC_MACROS $EXTRA_XC_ARGS \ - | $output_command && exit ${PIPESTATUS[0]} - else - xcodebuild \ - -project "WebDriverAgent.xcodeproj" \ - -scheme "$XC_TARGET" \ - -sdk "$XC_SDK" \ - $XC_ACTION \ - $XC_MACROS $EXTRA_XC_ARGS \ - | $output_command && exit ${PIPESTATUS[0]} - fi -} - -function fastlane_test() { - if [[ -n "$XC_DESTINATION" ]]; then - SDK="$XC_SDK" DEST="$XC_DESTINATION" SCHEME="$1" bundle exec fastlane test - else - SDK="$XC_SDK" SCHEME="$1" bundle exec fastlane test - fi -} - -define_xc_macros -case "$ACTION" in - "analyze" ) analyze ;; - "int_test_1" ) fastlane_test IntegrationTests_1 ;; - "int_test_2" ) fastlane_test IntegrationTests_2 ;; - "int_test_3" ) fastlane_test IntegrationTests_3 ;; - *) xcbuild ;; -esac diff --git a/Scripts/fetch-prebuilt-wda.js b/Scripts/fetch-prebuilt-wda.js deleted file mode 100644 index 82673188f..000000000 --- a/Scripts/fetch-prebuilt-wda.js +++ /dev/null @@ -1,61 +0,0 @@ -const path = require('path'); -const axios = require('axios'); -const { asyncify } = require('asyncbox'); -const { logger, fs, mkdirp, net } = require('appium-support'); -const _ = require('lodash'); -const B = require('bluebird'); - -const log = logger.getLogger('WDA'); - -async function fetchPrebuiltWebDriverAgentAssets () { - const tag = require('../package.json').version; - log.info(`Getting links to webdriveragent release ${tag}`); - const downloadUrl = `https://api.github.com/repos/appium/webdriveragent/releases/tags/v${tag}`; - log.info(`Getting WDA release ${downloadUrl}`); - let releases; - try { - releases = (await axios({ - url: downloadUrl, - headers: { - 'user-agent': 'appium', - 'accept': 'application/json, */*', - }, - })).data; - } catch (e) { - throw new Error(`Could not fetch endpoint ${downloadUrl}. Reason: ${e.message}`); - } - - const webdriveragentsDir = path.resolve(__dirname, '..', 'prebuilt-agents'); - log.info(`Creating webdriveragents directory at: ${webdriveragentsDir}`); - await fs.rimraf(webdriveragentsDir); - await mkdirp(webdriveragentsDir); - - // Define a method that does a streaming download of an asset - async function downloadAgent (url, targetPath) { - try { - await net.downloadFile(url, targetPath); - } catch (err) { - throw new Error(`Problem downloading webdriveragent from url ${url}: ${err.message}`); - } - } - - log.info(`Downloading assets to: ${webdriveragentsDir}`); - const agentsDownloading = []; - for (const asset of releases.assets) { - const url = asset.browser_download_url; - log.info(`Downloading: ${url}`); - try { - const nameOfAgent = _.last(url.split('/')); - agentsDownloading.push(downloadAgent(url, path.join(webdriveragentsDir, nameOfAgent))); - } catch (ign) { } - } - - // Wait for them all to finish - return await B.all(agentsDownloading); -} - -if (require.main === module) { - asyncify(fetchPrebuiltWebDriverAgentAssets); -} - -module.exports = fetchPrebuiltWebDriverAgentAssets; diff --git a/azure-templates/base_job.yml b/azure-templates/base_job.yml deleted file mode 100644 index e3b62c0d5..000000000 --- a/azure-templates/base_job.yml +++ /dev/null @@ -1,36 +0,0 @@ -parameters: - name: '' - action: '' - target: '' - dest: '' - sdk: '' - iphoneModel: '' - ipadModel: '' - tvModel: '' - iosVersion: '' - xcodeVersion: '' - tvVersion: '' - vmImage: '' - extraXcArgs: '' - - -jobs: - - job: ${{ parameters.name }} - pool: - vmImage: ${{ parameters.vmImage }} - variables: - ACTION: ${{ parameters.action }} - TARGET: ${{ parameters.target }} - DEST: ${{ parameters.dest }} - SDK: ${{ parameters.sdk }} - CODE_SIGN: ${{ parameters.codeSign }} - IPHONE_MODEL: ${{ parameters.iphoneModel }} - TV_MODEL: ${{ parameters.tvModel }} - IPAD_MODEL: ${{ parameters.ipadModel }} - IOS_VERSION: ${{ parameters.iosVersion }} - XCODE_VERSION: ${{ parameters.xcodeVersion }} - TV_VERSION: ${{ parameters.tvVersion }} - EXTRA_XC_ARGS: ${{ parameters.extraXcArgs }} - steps: - - template: bootstrap_steps.yml - - script: ./Scripts/build.sh diff --git a/azure-templates/bootstrap_steps.yml b/azure-templates/bootstrap_steps.yml deleted file mode 100644 index 085e617cd..000000000 --- a/azure-templates/bootstrap_steps.yml +++ /dev/null @@ -1,9 +0,0 @@ -steps: - - task: UseRubyVersion@0 - inputs: - versionSpec: "$(DEFAULT_RUBY_VERSION)" - addToPath: true - - script: bundle update --bundler - - script: bundle install - - script: sudo xcode-select --switch "/Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer" - - script: mkdir -p ./Resources/WebDriverAgent.bundle diff --git a/azure-templates/node_setup_steps.yml b/azure-templates/node_setup_steps.yml deleted file mode 100644 index 2da7b6b18..000000000 --- a/azure-templates/node_setup_steps.yml +++ /dev/null @@ -1,4 +0,0 @@ -steps: - - task: NodeTool@0 - inputs: - versionSpec: "$(DEFAULT_NODE_VERSION)" diff --git a/ci-jobs/build.yml b/ci-jobs/build.yml deleted file mode 100644 index 36daddb73..000000000 --- a/ci-jobs/build.yml +++ /dev/null @@ -1,19 +0,0 @@ -jobs: - - job: create_github_release - steps: - - task: GithubRelease@0 - inputs: - action: create - githubConnection: appiumbot - repositoryName: appium/WebDriverAgent - addChangeLog: false - - template: ./templates/build.yml - parameters: - vmImage: 'macOS-10.15' - name: 'macOS_10_15' - excludeXcode: '10.3.0,10.3,11.3,11.4,12' - - template: ./templates/build.yml - parameters: - # Exclude Xcode versions that were already covered in 10.15 - excludeXcode: '11.1,11.2.1,11.2,11.3.1,11.3,11' - name: 'macOS_10_14' \ No newline at end of file diff --git a/ci-jobs/scripts/azure-print-tag-name.js b/ci-jobs/scripts/azure-print-tag-name.js deleted file mode 100644 index 447152979..000000000 --- a/ci-jobs/scripts/azure-print-tag-name.js +++ /dev/null @@ -1,3 +0,0 @@ - -const branch = process.env.BUILD_SOURCEBRANCH || ''; -console.log(branch.replace(/^refs\/tags\//, '')); // eslint-disable-line no-console \ No newline at end of file diff --git a/ci-jobs/scripts/build-webdriveragent.js b/ci-jobs/scripts/build-webdriveragent.js deleted file mode 100644 index cccf5b23c..000000000 --- a/ci-jobs/scripts/build-webdriveragent.js +++ /dev/null @@ -1,92 +0,0 @@ -const path = require('path'); -const os = require('os'); -const { asyncify } = require('asyncbox'); -const { logger, fs, mkdirp, zip } = require('appium-support'); -const { exec } = require('teen_process'); -const xcode = require('appium-xcode'); - -const log = new logger.getLogger('WDABuild'); -const rootDir = path.resolve(__dirname, '..', '..'); - -async function buildWebDriverAgent (xcodeVersion) { - // Get Xcode version - xcodeVersion = xcodeVersion || await xcode.getVersion(); - log.info(`Building bundle for Xcode version '${xcodeVersion}'`); - - // Clear WebDriverAgent from derived data - const derivedDataPath = path.resolve(os.homedir(), 'Library', 'Developer', - 'Xcode', 'DerivedData'); - log.info(`Clearing contents of '${derivedDataPath}/WebDriverAgent-*'`); - for (const wdaPath of - await fs.glob('WebDriverAgent-*', {cwd: derivedDataPath, absolute: true}) - ) { - log.info(`Deleting existing WDA: '${wdaPath}'`); - await fs.rimraf(wdaPath); - } - - // Clean and build - log.info('Running ./Scripts/build.sh'); - let env = {TARGET: 'runner', SDK: 'sim'}; - try { - await exec('/bin/bash', ['./Scripts/build.sh'], {env, cwd: rootDir}); - } catch (e) { - log.error(`===FAILED TO BUILD FOR ${xcodeVersion}`); - log.error(e.stdout); - log.error(e.stderr); - log.error(e.message); - throw e; - } - - // Create bundles folder - const pathToBundles = path.resolve(rootDir, 'bundles'); - await mkdirp(pathToBundles); - - // Start creating zip - const uncompressedDir = path.resolve(rootDir, 'uncompressed'); - await fs.rimraf(uncompressedDir); - await mkdirp(uncompressedDir); - log.info('Creating zip'); - - // Move contents of the root to folder called "uncompressed" - await exec('rsync', [ - '-av', '.', uncompressedDir, - '--exclude', 'node_modules', - '--exclude', 'build', - '--exclude', 'ci-jobs', - '--exclude', 'lib', - '--exclude', 'test', - '--exclude', 'bundles', - '--exclude', 'azure-templates', - ], {cwd: rootDir}); - - // Move DerivedData/WebDriverAgent-* from Library to "uncompressed" folder - const wdaPath = (await fs.glob(`${derivedDataPath}/WebDriverAgent-*`))[0]; - await mkdirp(path.resolve(uncompressedDir, 'DerivedData')); - await fs.rename(wdaPath, path.resolve(uncompressedDir, 'DerivedData', 'WebDriverAgent')); - - // Compress the "uncompressed" bundle as a Zip - const pathToZip = path.resolve(pathToBundles, `webdriveragent-xcode_${xcodeVersion}.zip`); - await zip.toArchive( - pathToZip, {cwd: path.join(rootDir, 'uncompressed')} - ); - log.info(`Zip bundled at "${pathToZip}"`); - - // Now just zip the .app and place it in the root directory - // This zip file will be published to NPM - const wdaAppBundle = 'WebDriverAgentRunner-Runner.app'; - const appBundlePath = path.join(uncompressedDir, 'DerivedData', 'WebDriverAgent', - 'Build', 'Products', 'Debug-iphonesimulator', wdaAppBundle); - const appBundleZipPath = path.join(rootDir, `${wdaAppBundle}.zip`); - await fs.rimraf(appBundleZipPath); - log.info(`Created './${wdaAppBundle}.zip'`); - await zip.toArchive(appBundleZipPath, {cwd: appBundlePath}); - log.info(`Zip bundled at "${appBundleZipPath}"`); - // Clean up the uncompressed directory - await fs.rimraf(uncompressedDir); -} - -if (require.main === module) { - asyncify(buildWebDriverAgent); -} - -module.exports = buildWebDriverAgent; diff --git a/ci-jobs/scripts/build-webdriveragents.js b/ci-jobs/scripts/build-webdriveragents.js deleted file mode 100644 index 2eabdbd82..000000000 --- a/ci-jobs/scripts/build-webdriveragents.js +++ /dev/null @@ -1,57 +0,0 @@ -const buildWebDriverAgent = require('./build-webdriveragent'); -const { asyncify } = require('asyncbox'); -const { fs, logger } = require('appium-support'); -const { exec } = require('teen_process'); -const path = require('path'); - -const log = new logger.getLogger('WDABuild'); - -async function buildAndUploadWebDriverAgents () { - // Get all xcode paths from /Applications/ - const xcodePaths = (await fs.readdir('/Applications/')) - .filter((file) => file.toLowerCase().startsWith('xcode_')); - - // Determine which xcodes need to be skipped - let excludedXcodeArr = (process.env.EXCLUDE_XCODE || '').replace(/\s/g, '').split(','); - log.info(`Will skip xcode versions: '${excludedXcodeArr}'`); - - for (let xcodePath of xcodePaths) { - if (xcodePath.includes('beta')) { - log.info(`Skipping beta Xcode '${xcodePath}'`); - continue; - } - - // Skip if .0 because redundant (example: skip 11.4.0 because it already does 11.4) - const [, , patch] = xcodePath.split('.'); - if (patch === '0') { - log.info(`Skipping xcode '${xcodePath}'`); - continue; - } - - // Build webdriveragent for this xcode version - log.info(`Running xcode-select for '${xcodePath}'`); - await exec('sudo', ['xcode-select', '-s', `/Applications/${xcodePath}/Contents/Developer`]); - const xcodeVersion = path.parse(xcodePath).name.split('_', 2)[1]; - - if (excludedXcodeArr.includes(xcodeVersion)) { - log.info(`Skipping xcode version '${xcodeVersion}'`); - continue; - } - - log.info('Building webdriveragent for xcode version', xcodeVersion); - try { - await buildWebDriverAgent(xcodeVersion); - } catch (e) { - log.error(`Skipping build for '${xcodeVersion} due to error: ${e}'`); - } - } - - // Divider log line - log.info('\n'); -} - -if (require.main === module) { - asyncify(buildAndUploadWebDriverAgents); -} - -module.exports = buildAndUploadWebDriverAgents; diff --git a/ci-jobs/templates/build.yml b/ci-jobs/templates/build.yml deleted file mode 100644 index 380709258..000000000 --- a/ci-jobs/templates/build.yml +++ /dev/null @@ -1,41 +0,0 @@ -parameters: - vmImage: 'macOS-10.14' - name: macOS_10_14 - excludeXcode: $(excludeXcode) -jobs: - - job: ${{ parameters.name }} - variables: - EXCLUDE_XCODE: ${{ parameters.excludeXcode }} - pool: - vmImage: ${{ parameters.vmImage }} - dependsOn: create_github_release - steps: - - script: node ./ci-jobs/scripts/azure-print-tag-name - displayName: Print Tag Name - - script: ls /Applications/ - displayName: List Installed Applications - - task: NodeTool@0 - inputs: - versionSpec: '12.x' - - script: npm install - displayName: Install Node Modules - - script: bundle update --bundler - displayName: Update Bundler - - script: bundle install - displayName: Install Ruby dependencies - - script: mkdir -p Resources/WebDriverAgent.bundle - displayName: Make Resources Folder - - script: node ./ci-jobs/scripts/build-webdriveragents.js - displayName: Build WebDriverAgents - - script: ls ./bundles - displayName: List WDA Bundles - - task: PublishPipelineArtifact@0 - inputs: - targetPath: bundles/ - artifactName: ${{ parameters.name }} - - script: | - brew install ghr - ghr $(node ./ci-jobs/scripts/azure-print-tag-name) bundles/ - env: - GITHUB_TOKEN: $(GITHUB_TOKEN) - displayName: Upload to GitHub Releases diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 6df51b30d..000000000 --- a/gulpfile.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -const gulp = require('gulp'); -const boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp); - - -boilerplate({ - build: 'appium-webdriveragent', - projectRoot: __dirname, -}); - -gulp.task('install:dependencies', gulp.series('transpile', function installDependencies () { - // we cannot require `fetchDependencies` at the top level because it has not - // necessarily been transpiled at that point - const { checkForDependencies } = require('./build'); - return checkForDependencies(); -})); diff --git a/index.js b/index.js deleted file mode 100644 index de3ba4136..000000000 --- a/index.js +++ /dev/null @@ -1,29 +0,0 @@ -import * as dependencies from './lib/check-dependencies'; -import * as proxies from './lib/no-session-proxy'; -import * as driver from './lib/webdriveragent'; -import * as constants from './lib/constants'; -import * as utils from './lib/utils'; -import { asyncify } from 'asyncbox'; - - -const { checkForDependencies, bundleWDASim } = dependencies; -const { NoSessionProxy } = proxies; -const { WebDriverAgent } = driver; -const { WDA_BUNDLE_ID, BOOTSTRAP_PATH, WDA_BASE_URL, WDA_RUNNER_BUNDLE_ID, PROJECT_FILE } = constants; -const { resetTestProcesses } = utils; - - -// When run as a command line utility, this should check for the dependencies -if (require.main === module) { - asyncify(checkForDependencies); -} - -export { - WebDriverAgent, - NoSessionProxy, - checkForDependencies, bundleWDASim, - resetTestProcesses, - BOOTSTRAP_PATH, WDA_BUNDLE_ID, - WDA_RUNNER_BUNDLE_ID, PROJECT_FILE, - WDA_BASE_URL, -}; diff --git a/package.json b/package.json deleted file mode 100644 index 03831882e..000000000 --- a/package.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "name": "appium-webdriveragent", - "version": "3.8.0", - "description": "Package bundling WebDriverAgent", - "main": "build/index.js", - "scripts": { - "test": "gulp once", - "e2e-test": "npm run build && _FORCE_LOGS=1 npx mocha -t 0 -R spec build/test/functional --exit", - "clean": "rm -rf node_modules && rm -f package-lock.json && npm install", - "install:dependencies": "gulp install:dependencies", - "build": "gulp transpile", - "prepare": "gulp prepublish", - "prepublishOnly": "npm run bundle", - "lint": "gulp lint", - "lint:fix": "gulp eslint --fix", - "precommit-msg": "echo 'Pre-commit checks...' && exit 0", - "precommit-test": "gulp lint", - "bundle": "node ./ci-jobs/scripts/build-webdriveragent.js", - "fetch-prebuilt-wda": "node ./Scripts/fetch-prebuilt-wda" - }, - "bin": { - "appium-wda-bootstrap": "./build/index.js" - }, - "pre-commit": [ - "precommit-msg", - "precommit-test" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/appium/WebDriverAgent.git" - }, - "keywords": [ - "Appium", - "iOS", - "WebDriver", - "Selenium", - "WebDriverAgent" - ], - "author": "appium", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/appium/WebDriverAgent/issues" - }, - "homepage": "https://github.com/appium/WebDriverAgent#readme", - "devDependencies": { - "appium-gulp-plugins": "^5.0.0", - "appium-test-support": "^1.3.1", - "appium-xcode": "^3.8.0", - "chai": "^4.2.0", - "chai-as-promised": "^7.1.1", - "eslint-config-appium": "^4.0.1", - "glob": "^7.1.0", - "gulp": "^4.0.2", - "ios-uicatalog": "^3.5.0", - "mocha": "^8.0.1", - "pre-commit": "^1.2.2", - "sinon": "^10.0.0", - "wd": "^1.11.4" - }, - "dependencies": { - "@babel/runtime": "^7.0.0", - "appium-base-driver": "^7.0.0", - "appium-ios-simulator": "^3.14.0", - "appium-support": "^2.46.0", - "async-lock": "^1.0.0", - "asyncbox": "^2.5.3", - "axios": "^0.x", - "bluebird": "^3.5.5", - "lodash": "^4.17.11", - "node-simctl": "^6.0.2", - "source-map-support": "^0.5.12", - "teen_process": "^1.14.1" - }, - "files": [ - "index.js", - "lib", - "build/index.js", - "build/lib", - "Scripts/build.sh", - "Scripts/fetch-prebuilt-wda.js", - "Cartfile", - "Cartfile.resolved", - "Configurations", - "PrivateHeaders", - "WebDriverAgent.xcodeproj", - "WebDriverAgentLib", - "WebDriverAgentRunner", - "WebDriverAgentTests", - "XCTWebDriverAgentLib", - "WebDriverAgentRunner-Runner.app.zip" - ] -} diff --git a/test/functional/desired.js b/test/functional/desired.js deleted file mode 100644 index 34becd74e..000000000 --- a/test/functional/desired.js +++ /dev/null @@ -1,147 +0,0 @@ -import _ from 'lodash'; -import path from 'path'; -import glob from 'glob'; -import fs from 'fs'; -import { system, util } from 'appium-support'; - - -// translate integer environment variable to a boolean 0=false, !0=true -function checkFeatureInEnv (envArg) { - let feature = parseInt(process.env[envArg], 10); - if (isNaN(feature)) { - feature = process.env[envArg]; - } - return !!feature; -} - -const PLATFORM_VERSION = process.env.PLATFORM_VERSION ? process.env.PLATFORM_VERSION : '11.3'; -const LAUNCH_WITH_IDB = process.env.LAUNCH_WITH_IDB; - -// If it's real device cloud, don't set a device name. Use dynamic device allocation. -const DEVICE_NAME = process.env.DEVICE_NAME - ? process.env.DEVICE_NAME - : process.env.SAUCE_RDC - ? undefined - : util.compareVersions(PLATFORM_VERSION, '>=', '13.0') ? 'iPhone 8' : 'iPhone 6'; - -const SHOW_XCODE_LOG = checkFeatureInEnv('SHOW_XCODE_LOG'); -const REAL_DEVICE = checkFeatureInEnv('REAL_DEVICE'); -let XCCONFIG_FILE = process.env.XCCONFIG_FILE; -if (REAL_DEVICE && !XCCONFIG_FILE) { - // no xcconfig file specified, so try to find in the root directory of the package - // this happens once, at the start of a test run, so using sync method is ok - let cwd = path.resolve(__dirname, '..', '..', '..'); - let files = glob.sync('*.xcconfig', { cwd }); - if (files.length) { - XCCONFIG_FILE = path.resolve(cwd, _.first(files)); - } -} - -// Had to make these two optional dependencies so the tests -// can still run in linux -let uiCatalogPath; -if (system.isMac() && !process.env.CLOUD) { - // iOS 13+ need a slightly different app to be able to get the correct automation - uiCatalogPath = parseInt(PLATFORM_VERSION, 10) >= 13 - ? require('ios-uicatalog').uiKitCatalog.absolute - : require('ios-uicatalog').uiCatalog.absolute; -} - -const apps = {}; - -const CLOUD = process.env.CLOUD; - -if (REAL_DEVICE) { - if (CLOUD) { - apps.testAppId = 1; - } else { - apps.uiCatalogApp = uiCatalogPath.iphoneos; - } -} else { - if (CLOUD) { - apps.uiCatalogApp = 'http://appium.github.io/appium/assets/UICatalog9.4.app.zip'; - apps.touchIdApp = null; // TODO: Upload this to appium.io - } else { - apps.uiCatalogApp = uiCatalogPath.iphonesimulator; - apps.touchIdApp = path.resolve('.', 'test', 'assets', 'TouchIDExample.app'); - } -} - -const REAL_DEVICE_CAPS = REAL_DEVICE ? { - udid: 'auto', - xcodeConfigFile: XCCONFIG_FILE, - webkitResponseTimeout: 30000, - testobject_app_id: apps.testAppId, - testobject_api_key: process.env.SAUCE_RDC_ACCESS_KEY, - testobject_remote_appium_url: process.env.APPIUM_STAGING_URL, // TODO: Once RDC starts supporting this again, re-insert this -} : {}; - -let GENERIC_CAPS = { - platformName: 'iOS', - platformVersion: PLATFORM_VERSION, - deviceName: DEVICE_NAME, - automationName: 'XCUITest', - launchWithIDB: !!LAUNCH_WITH_IDB, - noReset: true, - maxTypingFrequency: 30, - clearSystemFiles: true, - showXcodeLog: SHOW_XCODE_LOG, - wdaLaunchTimeout: (60 * 1000 * 4), - wdaConnectionTimeout: (60 * 1000 * 8), - useNewWDA: true, - simulatorStartupTimeout: 240000, -}; - -if (process.env.CLOUD) { - GENERIC_CAPS.platformVersion = process.env.CLOUD_PLATFORM_VERSION; - GENERIC_CAPS.build = process.env.SAUCE_BUILD; - GENERIC_CAPS.showIOSLog = false; - GENERIC_CAPS[process.env.APPIUM_BUNDLE_CAP || 'appium-version'] = {'appium-url': 'sauce-storage:appium.zip'}; - // TODO: If it's SAUCE_RDC add the appium staging URL - - // `name` will be set during session initialization -} - -// on Travis, when load is high, the app often fails to build, -// and tests fail, so use static one in assets if necessary, -// but prefer to have one build locally -// only do this for sim, since real device one needs to be built with dev creds -if (!REAL_DEVICE && !process.env.CLOUD) { - // this happens a single time, at load-time for the test suite, - // so sync method is not overly problematic - if (!fs.existsSync(apps.uiCatalogApp)) { - apps.uiCatalogApp = path.resolve('.', 'test', 'assets', - `${parseInt(PLATFORM_VERSION, 10) >= 13 ? 'UIKitCatalog' : 'UICatalog'}-iphonesimulator.app`); - } - if (!fs.existsSync(apps.iosTestApp)) { - apps.iosTestApp = path.resolve('.', 'test', 'assets', 'TestApp-iphonesimulator.app'); - } -} - -const UICATALOG_CAPS = _.defaults({ - app: apps.uiCatalogApp, -}, GENERIC_CAPS, REAL_DEVICE_CAPS); - -const UICATALOG_SIM_CAPS = _.defaults({ - app: apps.uiCatalogApp, -}, GENERIC_CAPS); -delete UICATALOG_SIM_CAPS.noReset; // do not want to have no reset on the tests that use this - -const W3C_CAPS = { - capabilities: { - alwaysMatch: UICATALOG_CAPS, - firstMatch: [{}], - } -}; - -let TVOS_CAPS = _.defaults({ - platformName: 'tvOS', - bundleId: 'com.apple.TVSettings', - deviceName: 'Apple TV' -}, GENERIC_CAPS); - -export { - UICATALOG_CAPS, UICATALOG_SIM_CAPS, - PLATFORM_VERSION, DEVICE_NAME, W3C_CAPS, - TVOS_CAPS -}; diff --git a/test/functional/helpers/session.js b/test/functional/helpers/session.js deleted file mode 100644 index 49cd1131c..000000000 --- a/test/functional/helpers/session.js +++ /dev/null @@ -1,164 +0,0 @@ -import wd from 'wd'; -import { startServer } from '../../..'; -import { util } from 'appium-support'; -import _ from 'lodash'; -import axios from 'axios'; - - -const {SAUCE_RDC, SAUCE_EMUSIM, CLOUD} = process.env; - -function getPort () { - if (SAUCE_EMUSIM || SAUCE_RDC) { - return 80; - } - return 4994; -} - -function getHost () { - if (SAUCE_RDC) { - return 'appium.staging.testobject.org'; - } else if (SAUCE_EMUSIM) { - return 'ondemand.saucelabs.com'; - } - - return process.env.REAL_DEVICE ? util.localIp() : 'localhost'; -} - -const HOST = getHost(); -const PORT = getPort(); -// on CI the timeout needs to be long, mostly so WDA can be built the first time -const MOCHA_TIMEOUT = 60 * 1000 * (process.env.CI ? 0 : 4); -const WDA_PORT = 8200; - -let driver, server; - -if (CLOUD) { - before(function () { - process.env.SAUCE_JOB_NAME = `${process.env.TRAVIS_JOB_NUMBER || 'Suite'}: ${this.test.parent.suites[0].title}`; - }); - - // on Sauce Labs we need to track the status of the job - afterEach(function () { - if (driver) { - let fullTitle; - if (!driver.name) { - // traverse the title tree to get the whole thing - let titles = []; - const currentTest = this.currentTest; - titles.push(currentTest.title); - let parent = currentTest.parent; - while (parent) { - if (parent.title) { - titles.push(parent.title); - } - parent = parent.parent; - } - fullTitle = titles.reverse().join('/'); - - // construct the name for the job - driver.name = `${process.env.TRAVIS_JOB_NUMBER || 'Suite'}: ${_.first(titles)}`; - } - - // check for the first failure - if (!driver.errored && this.currentTest.state !== 'passed') { - // add the first failed job title to the name of the job - driver.name += ` (${fullTitle})`; - // and fail the whole job - driver.errored = true; - } - } - - // wd puts info into the error object that mocha can't display easily - if (this.currentTest.err) { - console.error('ERROR:', JSON.stringify(this.currentTest.err, null, 2)); // eslint-disable-line - } - }); -} - -async function initDriver () { // eslint-disable-line require-await - const config = {host: HOST, port: PORT}; - driver = CLOUD - ? await wd.promiseChainRemote(config, process.env.SAUCE_USERNAME, process.env.SAUCE_ACCESS_KEY) - : await wd.promiseChainRemote(config); - driver.name = undefined; - driver.errored = false; - return driver; -} - -async function initServer () { - server = await startServer(PORT, HOST); -} - -function getServer () { - return server; -} - -async function initWDA (caps) { - // first, see if this is necessary - try { - await axios({url: `http://${HOST}:${WDA_PORT}/status`, timeout: 5000}); - } catch (err) { - // easiest way to initialize WDA is to go through a test startup - // otherwise every change to the system would require a change here - const desiredCaps = Object.assign({ - autoLaunch: false, - wdaLocalPort: WDA_PORT, - }, caps); - await driver.init(desiredCaps); - await driver.quit(); - } -} - -async function initSession (caps) { - if (!CLOUD) { - await initServer(); - } - - if (CLOUD) { - // on cloud tests, we want to set the `name` capability - if (!caps.name) { - caps.name = process.env.SAUCE_JOB_NAME || process.env.TRAVIS_JOB_NUMBER || 'unnamed'; - } - } - - await initDriver(); - - if (process.env.USE_WEBDRIVERAGENTURL) { - await initWDA(caps); - caps = Object.assign({ - webDriverAgentUrl: `http://${HOST}:${WDA_PORT}`, - wdaLocalPort: WDA_PORT, - }, caps); - } - - const serverRes = await driver.init(caps); - if (!caps.udid && !caps.fullReset && serverRes[1].udid) { - caps.udid = serverRes[1].udid; - } - - return driver; -} - -async function deleteSession () { - try { - if (CLOUD) { - await driver.sauceJobUpdate({ - name: driver.name, - passed: !driver.errored, - }); - } - } catch (ign) {} - - try { - await driver.quit(); - } catch (ign) { - } finally { - driver = undefined; - } - - try { - await server.close(); - } catch (ign) {} -} - -export { initDriver, initSession, deleteSession, getServer, HOST, PORT, MOCHA_TIMEOUT }; diff --git a/test/functional/helpers/simulator.js b/test/functional/helpers/simulator.js deleted file mode 100644 index 4dd7359df..000000000 --- a/test/functional/helpers/simulator.js +++ /dev/null @@ -1,41 +0,0 @@ -import _ from 'lodash'; -import Simctl from 'node-simctl'; -import { retryInterval } from 'asyncbox'; -import { killAllSimulators as simKill } from 'appium-ios-simulator'; -import { resetTestProcesses } from '../../../lib/utils'; - - -async function killAllSimulators () { - if (process.env.CLOUD) { - return; - } - - const simctl = new Simctl(); - const allDevices = _.flatMap(_.values(await simctl.getDevices())); - const bootedDevices = allDevices.filter((device) => device.state === 'Booted'); - - for (const {udid} of bootedDevices) { - // It is necessary to stop the corresponding xcodebuild process before killing - // the simulator, otherwise it will be automatically restarted - await resetTestProcesses(udid, true); - simctl.udid = udid; - await simctl.shutdownDevice(); - } - await simKill(); -} - -async function shutdownSimulator (device) { - // stop XCTest processes if running to avoid unexpected side effects - await resetTestProcesses(device.udid, true); - await device.shutdown(); -} - -async function deleteDeviceWithRetry (udid) { - const simctl = new Simctl({udid}); - try { - await retryInterval(10, 1000, simctl.deleteDevice.bind(simctl)); - } catch (ign) {} -} - - -export { killAllSimulators, shutdownSimulator, deleteDeviceWithRetry }; diff --git a/test/functional/webdriveragent-derived-data-path-e2e-specs.js b/test/functional/webdriveragent-derived-data-path-e2e-specs.js deleted file mode 100644 index fe9284601..000000000 --- a/test/functional/webdriveragent-derived-data-path-e2e-specs.js +++ /dev/null @@ -1,62 +0,0 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; -import { getSimulator } from 'appium-ios-simulator'; -import { shutdownSimulator, deleteDeviceWithRetry } from './helpers/simulator'; -import Simctl from 'node-simctl'; -import { MOCHA_TIMEOUT, initSession, deleteSession } from './helpers/session'; -import { UICATALOG_SIM_CAPS } from './desired'; -import path from 'path'; -import fs from 'fs'; - - -const SIM_DEVICE_NAME = 'xcuitestDriverTest'; -const TEMP_FOLDER = '/tmp/WebDriverAgent'; - -chai.should(); -chai.use(chaiAsPromised); - -describe('WebDriverAgent Derived Data Path', function () { - this.timeout(MOCHA_TIMEOUT); - - let baseCaps; - let caps; - - let driver; - before(async function () { - const udid = await new Simctl().createDevice( - SIM_DEVICE_NAME, - UICATALOG_SIM_CAPS.deviceName, - UICATALOG_SIM_CAPS.platformVersion - ); - baseCaps = Object.assign({}, UICATALOG_SIM_CAPS, {udid}); - caps = Object.assign({ - usePrebuiltWDA: true, - agentPath: path.join(TEMP_FOLDER, 'WebDriverAgent.xcodeproj'), - derivedDataPath: path.join(TEMP_FOLDER, 'DerivedData', 'WebDriverAgent') - }, baseCaps); - // copy existing WebDriverAgent to the selected derivedDataPath folder - const wda_path = path.join(process.cwd(), 'WebDriverAgent'); - fs.symlinkSync(wda_path, TEMP_FOLDER); - }); - after(async function () { - const sim = await getSimulator(caps.udid); - await shutdownSimulator(sim); - await deleteDeviceWithRetry(caps.udid); - // delete created tmp folder - fs.unlinkSync(TEMP_FOLDER); - }); - - afterEach(async function () { - // try to get rid of the driver, so if a test fails the rest of the - // tests aren't compromised - await deleteSession(); - }); - - if (!process.env.REAL_DEVICE) { - it.skip('should start and stop a session', async function () { - driver = await initSession(caps, this); - let els = await driver.elementsByClassName('XCUIElementTypeWindow'); - els.length.should.be.at.least(1); - }); - } -}); diff --git a/test/functional/webdriveragent-e2e-specs.js b/test/functional/webdriveragent-e2e-specs.js deleted file mode 100644 index 0885ef052..000000000 --- a/test/functional/webdriveragent-e2e-specs.js +++ /dev/null @@ -1,119 +0,0 @@ -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; -import Simctl from 'node-simctl'; -import { getVersion } from 'appium-xcode'; -import { getSimulator } from 'appium-ios-simulator'; -import { killAllSimulators, shutdownSimulator } from './helpers/simulator'; -import { SubProcess } from 'teen_process'; -import { PLATFORM_VERSION, DEVICE_NAME } from './desired'; -import { retryInterval } from 'asyncbox'; -import { WebDriverAgent } from '../..'; -import axios from 'axios'; - - -const SIM_DEVICE_NAME = 'webDriverAgentTest'; - -const MOCHA_TIMEOUT = 60 * 1000 * (process.env.CI ? 0 : 4); - -chai.should(); -chai.use(chaiAsPromised); - -let testUrl = 'http://localhost:8100/tree'; - -function getStartOpts (device) { - return { - device, - platformVersion: PLATFORM_VERSION, - host: 'localhost', - port: 8100, - realDevice: false, - showXcodeLog: true, - wdaLaunchTimeout: 60 * 3 * 1000, - simulatorStartupTimeout: 60 * 4 * 1000, - }; -} - - -describe('WebDriverAgent', function () { - this.timeout(MOCHA_TIMEOUT); - - let xcodeVersion; - before(async function () { - // Don't do these tests on Sauce Labs - if (process.env.CLOUD) { - this.skip(); - } - - xcodeVersion = await getVersion(true); - }); - describe('with fresh sim', function () { - let device; - let simctl; - - before(async function () { - simctl = new Simctl(); - simctl.udid = await simctl.createDevice( - SIM_DEVICE_NAME, - DEVICE_NAME, - PLATFORM_VERSION - ); - device = await getSimulator(simctl.udid); - }); - - after(async function () { - this.timeout(MOCHA_TIMEOUT); - - await shutdownSimulator(device); - - await simctl.deleteDevice(); - }); - - describe('with running sim', function () { - this.timeout(6 * 60 * 1000); - beforeEach(async function () { - await killAllSimulators(); - await device.run(); - }); - afterEach(async function () { - try { - await retryInterval(5, 1000, async function () { - await shutdownSimulator(device); - }); - } catch (ign) {} - }); - - it('should launch agent on a sim', async function () { - const agent = new WebDriverAgent(xcodeVersion, getStartOpts(device)); - - await agent.launch('sessionId'); - await axios({url: testUrl}).should.be.eventually.rejected; - await agent.quit(); - }); - - it('should fail if xcodebuild fails', async function () { - // short timeout - this.timeout(35 * 1000); - - const agent = new WebDriverAgent(xcodeVersion, getStartOpts(device)); - - agent.xcodebuild.createSubProcess = async function () { // eslint-disable-line require-await - let args = [ - '-workspace', - `${this.agentPath}dfgs`, - // '-scheme', - // 'XCTUITestRunner', - // '-destination', - // `id=${this.device.udid}`, - // 'test' - ]; - return new SubProcess('xcodebuild', args, {detached: true}); - }; - - await agent.launch('sessionId') - .should.eventually.be.rejectedWith('xcodebuild failed'); - - await agent.quit(); - }); - }); - }); -}); diff --git a/test/unit/utils-specs.js b/test/unit/utils-specs.js deleted file mode 100644 index 72761b60e..000000000 --- a/test/unit/utils-specs.js +++ /dev/null @@ -1,162 +0,0 @@ -import { getXctestrunFilePath, getAdditionalRunContent, getXctestrunFileName } from '../../lib/utils'; -import { PLATFORM_NAME_IOS, PLATFORM_NAME_TVOS } from '../../lib/constants'; -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; -import { withMocks } from 'appium-test-support'; -import { fs } from 'appium-support'; -import path from 'path'; -import { fail } from 'assert'; - -chai.should(); -chai.use(chaiAsPromised); - -describe('utils', function () { - describe('#getXctestrunFilePath', withMocks({fs}, function (mocks) { - const platformVersion = '12.0'; - const sdkVersion = '12.2'; - const udid = 'xxxxxyyyyyyzzzzzz'; - const bootstrapPath = 'path/to/data'; - const platformName = PLATFORM_NAME_IOS; - - afterEach(function () { - mocks.verify(); - }); - - it('should return sdk based path with udid', async function () { - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`)) - .returns(true); - mocks.fs.expects('copyFile') - .never(); - const deviceInfo = {isRealDevice: true, udid, platformVersion, platformName}; - await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath) - .should.eventually.equal(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`)); - }); - - it('should return sdk based path without udid, copy them', async function () { - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`)) - .returns(false); - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphoneos${sdkVersion}-arm64.xctestrun`)) - .returns(true); - mocks.fs.expects('copyFile') - .withExactArgs( - path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphoneos${sdkVersion}-arm64.xctestrun`), - path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`) - ) - .returns(true); - const deviceInfo = {isRealDevice: true, udid, platformVersion}; - await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath) - .should.eventually.equal(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`)); - }); - - it('should return platform based path', async function () { - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`)) - .returns(false); - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-x86_64.xctestrun`)) - .returns(false); - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`)) - .returns(true); - mocks.fs.expects('copyFile') - .never(); - const deviceInfo = {isRealDevice: false, udid, platformVersion}; - await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath) - .should.eventually.equal(path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`)); - }); - - it('should return platform based path without udid, copy them', async function () { - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`)) - .returns(false); - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-x86_64.xctestrun`)) - .returns(false); - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`)) - .returns(false); - mocks.fs.expects('exists') - .withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${platformVersion}-x86_64.xctestrun`)) - .returns(true); - mocks.fs.expects('copyFile') - .withExactArgs( - path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${platformVersion}-x86_64.xctestrun`), - path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`) - ) - .returns(true); - - const deviceInfo = {isRealDevice: false, udid, platformVersion}; - await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath) - .should.eventually.equal(path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`)); - }); - - it('should raise an exception because of no files', async function () { - const expected = path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-x86_64.xctestrun`); - mocks.fs.expects('exists').exactly(4).returns(false); - - const deviceInfo = {isRealDevice: false, udid, platformVersion}; - try { - await getXctestrunFilePath(deviceInfo, sdkVersion, bootstrapPath); - fail(); - } catch (err) { - err.message.should.equal(`If you are using 'useXctestrunFile' capability then you need to have a xctestrun file (expected: '${expected}')`); - } - }); - })); - - describe('#getAdditionalRunContent', function () { - it('should return ios format', function () { - const wdaPort = getAdditionalRunContent(PLATFORM_NAME_IOS, 8000); - wdaPort.WebDriverAgentRunner - .EnvironmentVariables.USE_PORT - .should.equal(8000); - }); - - it('should return tvos format', function () { - const wdaPort = getAdditionalRunContent(PLATFORM_NAME_TVOS, '9000'); - wdaPort.WebDriverAgentRunner_tvOS - .EnvironmentVariables.USE_PORT - .should.equal('9000'); - }); - }); - - describe('#getXctestrunFileName', function () { - const platformVersion = '12.0'; - const udid = 'xxxxxyyyyyyzzzzzz'; - - it('should return ios format, real device', function () { - const platformName = 'iOs'; - const deviceInfo = {isRealDevice: true, udid, platformVersion, platformName}; - - getXctestrunFileName(deviceInfo, '10.2.0').should.equal( - 'WebDriverAgentRunner_iphoneos10.2.0-arm64.xctestrun'); - }); - - it('should return ios format, simulator', function () { - const platformName = 'ios'; - const deviceInfo = {isRealDevice: false, udid, platformVersion, platformName}; - - getXctestrunFileName(deviceInfo, '10.2.0').should.equal( - 'WebDriverAgentRunner_iphonesimulator10.2.0-x86_64.xctestrun'); - }); - - it('should return tvos format, real device', function () { - const platformName = 'tVos'; - const deviceInfo = {isRealDevice: true, udid, platformVersion, platformName}; - - getXctestrunFileName(deviceInfo, '10.2.0').should.equal( - 'WebDriverAgentRunner_tvOS_appletvos10.2.0-arm64.xctestrun'); - }); - - it('should return tvos format, simulator', function () { - const platformName = 'tvOS'; - const deviceInfo = {isRealDevice: false, udid, platformVersion, platformName}; - - getXctestrunFileName(deviceInfo, '10.2.0').should.equal( - 'WebDriverAgentRunner_tvOS_appletvsimulator10.2.0-x86_64.xctestrun'); - }); - }); -}); diff --git a/test/unit/webdriveragent-specs.js b/test/unit/webdriveragent-specs.js deleted file mode 100644 index bfdeab9f9..000000000 --- a/test/unit/webdriveragent-specs.js +++ /dev/null @@ -1,341 +0,0 @@ -import { WebDriverAgent, BOOTSTRAP_PATH } from '../..'; -import * as utils from '../../lib/utils'; -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; -import path from 'path'; -import _ from 'lodash'; -import sinon from 'sinon'; - - -chai.should(); -chai.use(chaiAsPromised); - -const fakeConstructorArgs = { - device: 'some sim', - platformVersion: '9', - host: 'me', - port: '5000', - realDevice: false -}; - -const defaultAgentPath = path.resolve(BOOTSTRAP_PATH, 'WebDriverAgent.xcodeproj'); -const customBootstrapPath = '/path/to/wda'; -const customAgentPath = '/path/to/some/agent/WebDriverAgent.xcodeproj'; -const customDerivedDataPath = '/path/to/some/agent/DerivedData/'; - -describe('Constructor', function () { - it('should have a default wda agent if not specified', function () { - let agent = new WebDriverAgent({}, fakeConstructorArgs); - agent.bootstrapPath.should.eql(BOOTSTRAP_PATH); - agent.agentPath.should.eql(defaultAgentPath); - }); - it('should have custom wda bootstrap and default agent if only bootstrap specified', function () { - let agent = new WebDriverAgent({}, _.defaults({ - bootstrapPath: customBootstrapPath, - }, fakeConstructorArgs)); - agent.bootstrapPath.should.eql(customBootstrapPath); - agent.agentPath.should.eql(path.resolve(customBootstrapPath, 'WebDriverAgent.xcodeproj')); - }); - it('should have custom wda bootstrap and agent if both specified', function () { - let agent = new WebDriverAgent({}, _.defaults({ - bootstrapPath: customBootstrapPath, - agentPath: customAgentPath, - }, fakeConstructorArgs)); - agent.bootstrapPath.should.eql(customBootstrapPath); - agent.agentPath.should.eql(customAgentPath); - }); - it('should have custom derivedDataPath if specified', function () { - let agent = new WebDriverAgent({}, _.defaults({ - derivedDataPath: customDerivedDataPath - }, fakeConstructorArgs)); - agent.xcodebuild.derivedDataPath.should.eql(customDerivedDataPath); - }); -}); - -describe('launch', function () { - it('should use webDriverAgentUrl override and return current status', async function () { - const override = 'http://mockurl:8100/'; - const args = Object.assign({}, fakeConstructorArgs); - args.webDriverAgentUrl = override; - const agent = new WebDriverAgent({}, args); - const wdaStub = sinon.stub(agent, 'getStatus'); - wdaStub.callsFake(function () { - return {build: 'data'}; - }); - - await agent.launch('sessionId').should.eventually.eql({build: 'data'}); - agent.url.href.should.eql(override); - agent.jwproxy.server.should.eql('mockurl'); - agent.jwproxy.port.should.eql('8100'); - agent.jwproxy.base.should.eql(''); - agent.noSessionProxy.server.should.eql('mockurl'); - agent.noSessionProxy.port.should.eql('8100'); - agent.noSessionProxy.base.should.eql(''); - wdaStub.reset(); - }); -}); - -describe('use wda proxy url', function () { - it('should use webDriverAgentUrl wda proxy url', async function () { - const override = 'http://127.0.0.1:8100/aabbccdd'; - const args = Object.assign({}, fakeConstructorArgs); - args.webDriverAgentUrl = override; - const agent = new WebDriverAgent({}, args); - const wdaStub = sinon.stub(agent, 'getStatus'); - wdaStub.callsFake(function () { - return {build: 'data'}; - }); - - await agent.launch('sessionId').should.eventually.eql({build: 'data'}); - - agent.url.port.should.eql('8100'); - agent.url.hostname.should.eql('127.0.0.1'); - agent.url.path.should.eql('/aabbccdd'); - agent.jwproxy.server.should.eql('127.0.0.1'); - agent.jwproxy.port.should.eql('8100'); - agent.jwproxy.base.should.eql('/aabbccdd'); - agent.noSessionProxy.server.should.eql('127.0.0.1'); - agent.noSessionProxy.port.should.eql('8100'); - agent.noSessionProxy.base.should.eql('/aabbccdd'); - }); -}); - -describe('get url', function () { - it('should use default WDA listening url', function () { - const args = Object.assign({}, fakeConstructorArgs); - const agent = new WebDriverAgent({}, args); - agent.url.href.should.eql('http://127.0.0.1:8100/'); - }); - it('should use default WDA listening url with emply base url', function () { - const wdaLocalPort = '9100'; - const wdaBaseUrl = ''; - - const args = Object.assign({}, fakeConstructorArgs); - args.wdaBaseUrl = wdaBaseUrl; - args.wdaLocalPort = wdaLocalPort; - - const agent = new WebDriverAgent({}, args); - agent.url.href.should.eql('http://127.0.0.1:9100/'); - }); - it('should use customised WDA listening url', function () { - const wdaLocalPort = '9100'; - const wdaBaseUrl = 'http://mockurl'; - - const args = Object.assign({}, fakeConstructorArgs); - args.wdaBaseUrl = wdaBaseUrl; - args.wdaLocalPort = wdaLocalPort; - - const agent = new WebDriverAgent({}, args); - agent.url.href.should.eql('http://mockurl:9100/'); - }); - it('should use customised WDA listening url with slash', function () { - const wdaLocalPort = '9100'; - const wdaBaseUrl = 'http://mockurl/'; - - const args = Object.assign({}, fakeConstructorArgs); - args.wdaBaseUrl = wdaBaseUrl; - args.wdaLocalPort = wdaLocalPort; - - const agent = new WebDriverAgent({}, args); - agent.url.href.should.eql('http://mockurl:9100/'); - }); - it('should use the given webDriverAgentUrl and ignore other params', function () { - const args = Object.assign({}, fakeConstructorArgs); - args.wdaBaseUrl = 'http://mockurl/'; - args.wdaLocalPort = '9100'; - args.webDriverAgentUrl = 'https://127.0.0.1:8100/'; - - const agent = new WebDriverAgent({}, args); - agent.url.href.should.eql('https://127.0.0.1:8100/'); - }); -}); - -describe('setupCaching()', function () { - let wda; - let wdaStub; - let wdaStubUninstall; - const getTimestampStub = sinon.stub(utils, 'getWDAUpgradeTimestamp'); - - beforeEach(function () { - wda = new WebDriverAgent('1'); - wdaStub = sinon.stub(wda, 'getStatus'); - wdaStubUninstall = sinon.stub(wda, 'uninstall'); - }); - - afterEach(function () { - for (const stub of [wdaStub, wdaStubUninstall, getTimestampStub]) { - if (stub) { - stub.reset(); - } - } - }); - - it('should not call uninstall since no Running WDA', async function () { - wdaStub.callsFake(function () { - return null; - }); - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.notCalled.should.be.true; - _.isUndefined(wda.webDriverAgentUrl).should.be.true; - }); - - it('should not call uninstall since running WDA has only time', async function () { - wdaStub.callsFake(function () { - return {build: { time: 'Jun 24 2018 17:08:21' }}; - }); - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.notCalled.should.be.true; - wda.webDriverAgentUrl.should.equal('http://127.0.0.1:8100/'); - }); - - it('should call uninstall once since bundle id is not default without updatedWDABundleId capability', async function () { - wdaStub.callsFake(function () { - return {build: { time: 'Jun 24 2018 17:08:21', productBundleIdentifier: 'com.example.WebDriverAgent' }}; - }); - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.calledOnce.should.be.true; - _.isUndefined(wda.webDriverAgentUrl).should.be.true; - }); - - it('should call uninstall once since bundle id is different with updatedWDABundleId capability', async function () { - wdaStub.callsFake(function () { - return {build: { time: 'Jun 24 2018 17:08:21', productBundleIdentifier: 'com.example.different.WebDriverAgent' }}; - }); - - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.calledOnce.should.be.true; - _.isUndefined(wda.webDriverAgentUrl).should.be.true; - }); - - it('should not call uninstall since bundle id is equal to updatedWDABundleId capability', async function () { - wda = new WebDriverAgent('1', { updatedWDABundleId: 'com.example.WebDriverAgent' }); - wdaStub = sinon.stub(wda, 'getStatus'); - wdaStubUninstall = sinon.stub(wda, 'uninstall'); - - wdaStub.callsFake(function () { - return {build: { time: 'Jun 24 2018 17:08:21', productBundleIdentifier: 'com.example.WebDriverAgent' }}; - }); - - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.notCalled.should.be.true; - wda.webDriverAgentUrl.should.equal('http://127.0.0.1:8100/'); - }); - - it('should call uninstall if current revision differs from the bundled one', async function () { - wdaStub.callsFake(function () { - return {build: { upgradedAt: '1' }}; - }); - getTimestampStub.callsFake(() => '2'); - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.calledOnce.should.be.true; - }); - - it('should not call uninstall if current revision is the same as the bundled one', async function () { - wdaStub.callsFake(function () { - return {build: { upgradedAt: '1' }}; - }); - getTimestampStub.callsFake(() => '1'); - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.notCalled.should.be.true; - }); - - it('should not call uninstall if current revision cannot be retrieved from WDA status', async function () { - wdaStub.callsFake(function () { - return {build: {}}; - }); - getTimestampStub.callsFake(() => '1'); - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.notCalled.should.be.true; - }); - - it('should not call uninstall if current revision cannot be retrieved from the file system', async function () { - wdaStub.callsFake(function () { - return {build: { upgradedAt: '1' }}; - }); - getTimestampStub.callsFake(() => null); - wdaStubUninstall.callsFake(_.noop); - - await wda.setupCaching(); - wdaStub.calledOnce.should.be.true; - wdaStubUninstall.notCalled.should.be.true; - }); - - describe('uninstall', function () { - let device; - let wda; - let deviceGetBundleIdsStub; - let deviceRemoveAppStub; - - beforeEach(function () { - device = { - getUserInstalledBundleIdsByBundleName: () => {}, - removeApp: () => {} - }; - wda = new WebDriverAgent('1', {device}); - deviceGetBundleIdsStub = sinon.stub(device, 'getUserInstalledBundleIdsByBundleName'); - deviceRemoveAppStub = sinon.stub(device, 'removeApp'); - }); - - afterEach(function () { - for (const stub of [deviceGetBundleIdsStub, deviceRemoveAppStub]) { - if (stub) { - stub.reset(); - } - } - }); - - it('should not call uninstall', async function () { - deviceGetBundleIdsStub.callsFake(() => []); - - await wda.uninstall(); - deviceGetBundleIdsStub.calledOnce.should.be.true; - deviceRemoveAppStub.notCalled.should.be.true; - }); - - it('should call uninstall once', async function () { - const uninstalledBundIds = []; - deviceGetBundleIdsStub.callsFake(() => ['com.appium.WDA1']); - deviceRemoveAppStub.callsFake((id) => uninstalledBundIds.push(id)); - - await wda.uninstall(); - deviceGetBundleIdsStub.calledOnce.should.be.true; - deviceRemoveAppStub.calledOnce.should.be.true; - uninstalledBundIds.should.eql(['com.appium.WDA1']); - }); - - it('should call uninstall twice', async function () { - const uninstalledBundIds = []; - deviceGetBundleIdsStub.callsFake(() => ['com.appium.WDA1', 'com.appium.WDA2']); - deviceRemoveAppStub.callsFake((id) => uninstalledBundIds.push(id)); - - await wda.uninstall(); - deviceGetBundleIdsStub.calledOnce.should.be.true; - deviceRemoveAppStub.calledTwice.should.be.true; - uninstalledBundIds.should.eql(['com.appium.WDA1', 'com.appium.WDA2']); - }); - }); -});