diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml new file mode 100644 index 0000000..0bbbf1e --- /dev/null +++ b/.github/workflows/e2e-tests.yaml @@ -0,0 +1,97 @@ +name: React Native iOS E2E Tests + +on: + pull_request: + branches: [ main, develop ] + push: + branches: [ main, develop ] + workflow_dispatch: + +jobs: + test-ios: + name: e2e-ios-test + runs-on: macos-latest-xlarge + env: + DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer + MAESTRO_ENVIRONMENT: ios + WEATHER_API_KEY: ${{ secrets.WEATHER_API_KEY }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: true + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' + + - name: Install dependencies + run: | + yarn install --frozen-lockfile + cd ios && bundle install + + - name: Install CocoaPods + run: | + cd ios + pod install + cd .. + + - name: Install Maestro CLI + run: | + curl -Ls "https://get.maestro.mobile.dev" | bash + brew tap facebook/fb + brew install facebook/fb/idb-companion + + - name: Add Maestro to path + run: | + echo "${HOME}/.maestro/bin" >> $GITHUB_PATH + echo "Verifying Maestro installation..." + $HOME/.maestro/bin/maestro --version + + - name: List available simulators + run: xcrun simctl list devices + + - name: Build and Run iOS App + run: | + npx react-native run-ios --mode=Release --simulator="iPhone 15" + sleep 90 # Increased wait time to ensure app is fully launched + + - name: Check Simulator status + run: xcrun simctl list devices | grep Booted + + - name: Check Maestro environment + run: echo $MAESTRO_ENVIRONMENT + + - name: Run Maestro tests + run: | + echo "Running Maestro tests..." + export MAESTRO_DRIVER_STARTUP_TIMEOUT=240000 + export MAESTRO_CLI_NO_ANALYTICS=1 + $HOME/.maestro/bin/maestro test e2e/main-flow-ios.yaml + + - name: Upload Maestro logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: maestro-ios-logs + path: ~/.maestro/logs + + - name: Upload Maestro artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: maestro-screenshots + path: ~/.maestro/tests/**/*.png + + - name: Upload build logs and app + if: always() + uses: actions/upload-artifact@v4 + with: + name: ios-build-logs-and-app + path: ios/build \ No newline at end of file diff --git a/.gitignore b/.gitignore index e434836..4bf1372 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ yarn-error.log **/fastlane/Preview.html **/fastlane/screenshots **/fastlane/test_output +ios/fastlane/ # Bundle artifact *.jsbundle diff --git a/Gemfile b/Gemfile index 8d72c37..1595bff 100644 --- a/Gemfile +++ b/Gemfile @@ -7,3 +7,4 @@ ruby ">= 2.6.10" # bound in the template on Cocoapods with next React Native release. gem 'cocoapods', '>= 1.13', '< 1.15' gem 'activesupport', '>= 6.1.7.5', '< 7.1.0' +gem "fastlane" diff --git a/Gemfile.lock b/Gemfile.lock index fd340c8..7dc5875 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,18 +5,35 @@ GEM base64 nkf rexml - activesupport (6.1.7.8) + activesupport (7.0.8.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) + artifactory (3.0.17) atomos (0.1.3) + aws-eventstream (1.3.0) + aws-partitions (1.986.0) + aws-sdk-core (3.209.1) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.9) + jmespath (~> 1, >= 1.6.1) + aws-sdk-kms (1.94.0) + aws-sdk-core (~> 3, >= 3.207.0) + aws-sigv4 (~> 1.5) + aws-sdk-s3 (1.167.0) + aws-sdk-core (~> 3, >= 3.207.0) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.5) + aws-sigv4 (1.10.0) + aws-eventstream (~> 1, >= 1.0.2) + babosa (1.0.4) base64 (0.2.0) claide (1.1.0) cocoapods (1.14.3) @@ -56,42 +73,202 @@ GEM nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.2.0) + colored (1.2) colored2 (3.1.2) - concurrent-ruby (1.3.3) + commander (4.6.0) + highline (~> 2.0.0) + concurrent-ruby (1.3.4) + declarative (0.0.20) + digest-crc (0.6.5) + rake (>= 12.0.0, < 14.0.0) + domain_name (0.6.20240107) + dotenv (2.8.1) + emoji_regex (3.2.3) escape (0.0.4) ethon (0.16.0) ffi (>= 1.15.0) + excon (0.112.0) + faraday (1.10.4) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) + ruby2_keywords (>= 0.0.4) + faraday-cookie_jar (0.0.7) + faraday (>= 0.8.0) + http-cookie (~> 1.0.0) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (1.0.2) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) + faraday_middleware (1.2.1) + faraday (~> 1.0) + fastimage (2.3.1) + fastlane (2.224.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.8, < 3.0.0) + artifactory (~> 3.0) + aws-sdk-s3 (~> 1.0) + babosa (>= 1.0.3, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored (~> 1.2) + commander (~> 4.6) + 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-apis-androidpublisher_v3 (~> 0.3) + google-apis-playcustomapp_v1 (~> 0.1) + google-cloud-env (>= 1.6.0, < 2.0.0) + google-cloud-storage (~> 1.31) + highline (~> 2.0) + http-cookie (~> 1.0.5) + json (< 3.0.0) + jwt (>= 2.1.0, < 3) + mini_magick (>= 4.9.4, < 5.0.0) + multipart-post (>= 2.0.0, < 3.0.0) + naturally (~> 2.2) + optparse (>= 0.1.1, < 1.0.0) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 2.0.0, < 3.0.0) + security (= 0.1.5) + simctl (~> 1.6.3) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (~> 3) + 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, < 2.0.0) ffi (1.17.0) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) + google-apis-androidpublisher_v3 (0.54.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-core (0.11.3) + addressable (~> 2.5, >= 2.5.1) + googleauth (>= 0.16.2, < 2.a) + httpclient (>= 2.8.1, < 3.a) + mini_mime (~> 1.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.a) + rexml + google-apis-iamcredentials_v1 (0.17.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-playcustomapp_v1 (0.13.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-storage_v1 (0.31.0) + google-apis-core (>= 0.11.0, < 2.a) + google-cloud-core (1.7.1) + google-cloud-env (>= 1.0, < 3.a) + google-cloud-errors (~> 1.0) + google-cloud-env (1.6.0) + faraday (>= 0.17.3, < 3.0) + google-cloud-errors (1.4.0) + google-cloud-storage (1.47.0) + addressable (~> 2.8) + digest-crc (~> 0.4) + google-apis-iamcredentials_v1 (~> 0.1) + google-apis-storage_v1 (~> 0.31.0) + google-cloud-core (~> 1.6) + googleauth (>= 0.16.2, < 2.a) + mini_mime (~> 1.0) + googleauth (1.8.1) + faraday (>= 0.17.3, < 3.a) + jwt (>= 1.4, < 3.0) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (>= 0.16, < 2.a) + highline (2.0.3) + http-cookie (1.0.7) + domain_name (~> 0.5) httpclient (2.8.3) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) + jmespath (1.6.2) json (2.7.2) - minitest (5.24.1) + jwt (2.9.3) + base64 + mini_magick (4.13.2) + mini_mime (1.1.5) + minitest (5.25.1) molinillo (0.8.0) + multi_json (1.15.0) + multipart-post (2.4.1) nanaimo (0.3.0) nap (1.1.0) + naturally (2.2.1) netrc (0.11.0) nkf (0.2.0) + optparse (0.5.0) + os (1.1.4) + plist (3.7.1) public_suffix (4.0.7) - rexml (3.2.9) - strscan + rake (13.2.1) + representable (3.2.0) + declarative (< 0.1.0) + trailblazer-option (>= 0.1.1, < 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rexml (3.3.8) + rouge (2.0.7) ruby-macho (2.5.1) - strscan (3.1.0) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) + security (0.1.5) + signet (0.19.0) + addressable (~> 2.8) + faraday (>= 0.17.5, < 3.a) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.10) + CFPropertyList + naturally + terminal-notifier (2.0.0) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + trailblazer-option (0.1.2) + tty-cursor (0.7.1) + tty-screen (0.8.2) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) typhoeus (1.4.1) ethon (>= 0.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - xcodeproj (1.24.0) + uber (0.1.0) + unicode-display_width (2.6.0) + word_wrap (1.0.0) + xcodeproj (1.25.1) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) - rexml (~> 3.2.4) - zeitwerk (2.6.17) + rexml (>= 3.3.6, < 4.0) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.1) + xcpretty (~> 0.2, >= 0.0.7) PLATFORMS ruby @@ -99,9 +276,10 @@ PLATFORMS DEPENDENCIES activesupport (>= 6.1.7.5, < 7.1.0) cocoapods (>= 1.13, < 1.15) + fastlane RUBY VERSION - ruby 2.6.10p210 + ruby 3.3.4p94 BUNDLED WITH - 1.17.2 + 2.5.11 diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile new file mode 100644 index 0000000..7553d2a --- /dev/null +++ b/android/fastlane/Fastfile @@ -0,0 +1,21 @@ + +default_platform(:android) + +# platform :android do +# desc "Build development APK" +# lane :build_dev do +# gradle( +# task: "clean assembleDebug", +# project_dir: "./" +# ) +# end +# end + + +platform :android do + desc "Build and install the app" + lane :build_and_install do + gradle(task: "assembleDebug") + gradle(task: "installDebug") + end +end \ No newline at end of file diff --git a/android/fastlane/README.md b/android/fastlane/README.md new file mode 100644 index 0000000..927b202 --- /dev/null +++ b/android/fastlane/README.md @@ -0,0 +1,32 @@ +fastlane documentation +---- + +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +```sh +xcode-select --install +``` + +For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane) + +# Available Actions + +## Android + +### android build_dev + +```sh +[bundle exec] fastlane android build_dev +``` + +Build development APK + +---- + +This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. + +More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools). + +The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/e2e/main-flow-ios.yaml b/e2e/main-flow-ios.yaml index 6c89ac9..e2b4787 100644 --- a/e2e/main-flow-ios.yaml +++ b/e2e/main-flow-ios.yaml @@ -1,9 +1,19 @@ -appId: com.weatherapp +appId: com.weatherApp.callstack --- - launchApp +- waitForAnimationToEnd: + timeout: 30000 +- takeScreenshot: after_launch_and_wait +- tapOn: + text: "Allow While Using App" +- takeScreenshot: after_tap_allow +- assertVisible: + id: "WeatherListItem-pressable" +- takeScreenshot: after_assert_visible - tapOn: id: 'WeatherListItem-pressable' index: 0 +- takeScreenshot: after_first_tap - tapOn: text: "Weather" - stopApp \ No newline at end of file diff --git a/ios/Fastlane/Fastfile b/ios/Fastlane/Fastfile new file mode 100644 index 0000000..af45462 --- /dev/null +++ b/ios/Fastlane/Fastfile @@ -0,0 +1,43 @@ +default_platform(:ios) + +platform :ios do + desc "Build the app for simulator with debugging" + lane :build_for_testing do + cocoapods + + puts "Current directory: #{Dir.pwd}" + puts "Xcode version: #{`xcodebuild -version`}" + + derived_data_path = File.expand_path("./derived_data") + output_directory = File.join(derived_data_path, "Build", "Products") + puts "Derived data path: #{derived_data_path}" + puts "Output directory: #{output_directory}" + + gym( + scheme: "weatherApp", + workspace: "weatherApp.xcworkspace", + configuration: "Debug", + destination: "generic/platform=iOS Simulator", + derived_data_path: derived_data_path, + output_directory: output_directory, + output_name: "weatherApp", + skip_archive: true, + skip_package_ipa: true, + include_symbols: false, + include_bitcode: false, + buildlog_path: derived_data_path, + xcargs: "MODULEMAP_FILE=$(pwd)/Pods/Headers/Public/RCTDeprecation/RCTDeprecation.modulemap", + verbose: true + ) + + puts "Contents of derived data directory:" + puts `find #{derived_data_path} -name "*.app"` + + app_path = Dir.glob("#{output_directory}/Debug-iphonesimulator/*.app").first + if app_path + puts "App built successfully at: #{app_path}" + else + UI.user_error!("No .app file found in output directory") + end + end +end \ No newline at end of file diff --git a/ios/Fastlane/README.md b/ios/Fastlane/README.md new file mode 100644 index 0000000..e2ad1e2 --- /dev/null +++ b/ios/Fastlane/README.md @@ -0,0 +1,32 @@ +fastlane documentation +---- + +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +```sh +xcode-select --install +``` + +For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane) + +# Available Actions + +## iOS + +### ios build_for_testing + +```sh +[bundle exec] fastlane ios build_for_testing +``` + +Build the app for simulator with debugging + +---- + +This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. + +More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools). + +The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 9bd7b67..651e965 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -935,6 +935,10 @@ PODS: - React-Mapbuffer (0.74.5): - glog - React-debug + - react-native-config (1.5.3): + - react-native-config/App (= 1.5.3) + - react-native-config/App (1.5.3): + - React-Core - react-native-safe-area-context (4.10.8): - React-Core - React-nativeconfig (0.74.5) @@ -1168,7 +1172,7 @@ PODS: - React-utils (= 0.74.5) - RNPermissions (4.1.5): - React-Core - - RNScreens (3.34.0): + - RNScreens (3.29.0): - DoubleConversion - glog - hermes-engine @@ -1184,7 +1188,6 @@ PODS: - React-ImageManager - React-NativeModulesApple - React-RCTFabric - - React-RCTImage - React-rendererdebug - React-utils - ReactCommon/turbomodule/bridging @@ -1228,6 +1231,7 @@ DEPENDENCIES: - React-jsitracing (from `../node_modules/react-native/ReactCommon/hermes/executor/`) - React-logger (from `../node_modules/react-native/ReactCommon/logger`) - React-Mapbuffer (from `../node_modules/react-native/ReactCommon`) + - react-native-config (from `../node_modules/react-native-config`) - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) - React-nativeconfig (from `../node_modules/react-native/ReactCommon`) - React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`) @@ -1323,6 +1327,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/logger" React-Mapbuffer: :path: "../node_modules/react-native/ReactCommon" + react-native-config: + :path: "../node_modules/react-native-config" react-native-safe-area-context: :path: "../node_modules/react-native-safe-area-context" React-nativeconfig: @@ -1411,6 +1417,7 @@ SPEC CHECKSUMS: React-jsitracing: 3b6060bbf5317663667e1dd93560c7943ab86ccc React-logger: 257858bd55f3a4e1bc0cf07ddc8fb9faba6f8c7c React-Mapbuffer: 6c1cacdbf40b531f549eba249e531a7d0bfd8e7f + react-native-config: 8f7283449bbb048902f4e764affbbf24504454af react-native-safe-area-context: b7daa1a8df36095a032dff095a1ea8963cb48371 React-nativeconfig: ba9a2e54e2f0882cf7882698825052793ed4c851 React-NativeModulesApple: 8d11ff8955181540585c944cf48e9e7236952697 @@ -1436,7 +1443,7 @@ SPEC CHECKSUMS: React-utils: f242eb7e7889419d979ca0e1c02ccc0ea6e43b29 ReactCommon: f7da14a8827b72704169a48c929bcde802698361 RNPermissions: a4c964f030841f35d918ab3248df9dec9db5f44d - RNScreens: aa943ad421c3ced3ef5a47ede02b0cbfc43a012e + RNScreens: 23dad53fc9db1da2c93e647ae33fd7ce2bd49d60 RNSVG: b986585e367f4a49d8aa43065066cc9c290b3d9b SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 950bbfd7e6f04790fdb51149ed51df41f329fcc8 diff --git a/ios/weatherApp.xcodeproj/project.pbxproj b/ios/weatherApp.xcodeproj/project.pbxproj index 7556c3f..474764b 100644 --- a/ios/weatherApp.xcodeproj/project.pbxproj +++ b/ios/weatherApp.xcodeproj/project.pbxproj @@ -500,7 +500,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = AJNMX63HJN; ENABLE_BITCODE = NO; INFOPLIST_FILE = weatherApp/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = weatherApp; @@ -514,8 +517,9 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = com.weatherApp.callstack; PRODUCT_NAME = weatherApp; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "weatherApp-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -529,7 +533,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = AJNMX63HJN; INFOPLIST_FILE = weatherApp/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = weatherApp; LD_RUNPATH_SEARCH_PATHS = ( @@ -542,8 +549,9 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = com.weatherApp.callstack; PRODUCT_NAME = weatherApp; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "weatherApp-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; diff --git a/ios/weatherApp/Info.plist b/ios/weatherApp/Info.plist index b7b1c7e..16ed186 100644 --- a/ios/weatherApp/Info.plist +++ b/ios/weatherApp/Info.plist @@ -26,7 +26,6 @@ NSAppTransportSecurity - NSAllowsArbitraryLoads NSAllowsLocalNetworking diff --git a/jest-setup.ts b/jest-setup.ts index aa5f7b8..64126e4 100644 --- a/jest-setup.ts +++ b/jest-setup.ts @@ -11,8 +11,8 @@ afterEach(() => server.resetHandlers()); // Clean up after the tests are finished. afterAll(() => server.close()); - jest.mock('react-native-permissions', () => - require('react-native-permissions/mock'), + require('react-native-permissions/mock'), ); - \ No newline at end of file + +jest.setTimeout(30000); diff --git a/jest.config.js b/jest.config.js index f041f2d..e52f030 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,6 +7,6 @@ module.exports = { '\\.svg': '/__mocks__/svgMock.js', }, transformIgnorePatterns: [ - "node_modules/(?!(react-native|@react-native|react-native-permissions)/)" + 'node_modules/(?!(react-native|@react-native|react-native-permissions)/)', ], }; diff --git a/package.json b/package.json index 8d07a8c..28a5144 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", + "lint:fix": "eslint . --fix", "start": "react-native start", "test": "jest", "test-e2e-ios": "maestro test e2e/main-flow-ios.yaml", @@ -15,15 +16,18 @@ "@react-navigation/native": "^6.1.18", "@react-navigation/native-stack": "^6.11.0", "@tanstack/react-query": "^5.51.21", + "add": "^2.0.6", "axios": "^1.7.3", "fast-text-encoding": "^1.0.6", "react": "18.2.0", "react-native": "0.74.5", + "react-native-config": "^1.5.3", "react-native-permissions": "^4.1.5", "react-native-safe-area-context": "^4.10.8", - "react-native-screens": "^3.34.0", + "react-native-screens": "3.29.0", "react-native-svg": "^15.5.0", - "react-native-url-polyfill": "^2.0.0" + "react-native-url-polyfill": "^2.0.0", + "yarn": "^1.22.22" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/src/components/WeatherListItem.tsx b/src/components/WeatherListItem.tsx index 9ba509d..3421fc6 100644 --- a/src/components/WeatherListItem.tsx +++ b/src/components/WeatherListItem.tsx @@ -6,10 +6,10 @@ import {useNavigation} from '@react-navigation/native'; type WeatherListItemProps = { item: Weather; - testID: string; + index: number; }; -const WeatherListItem = ({item, testID}: WeatherListItemProps) => { +const WeatherListItem = ({item, index}: WeatherListItemProps) => { const navigation = useNavigation(); const onPress = () => { @@ -17,8 +17,8 @@ const WeatherListItem = ({item, testID}: WeatherListItemProps) => { }; return ( - - + + ); }; diff --git a/src/screens/WeatherListScreen/WeatherListScreen.tsx b/src/screens/WeatherListScreen/WeatherListScreen.tsx index a9b2174..e851456 100644 --- a/src/screens/WeatherListScreen/WeatherListScreen.tsx +++ b/src/screens/WeatherListScreen/WeatherListScreen.tsx @@ -29,7 +29,7 @@ const WeatherListScreen = () => { const renderItem = useCallback( ({item, index}: {item: Weather; index: number}) => ( - + ), [], ); diff --git a/src/services/weather.ts b/src/services/weather.ts index 69e0c60..b4f3b64 100644 --- a/src/services/weather.ts +++ b/src/services/weather.ts @@ -3,12 +3,13 @@ import {queryOptions} from '@tanstack/react-query'; import {Weather, WeatherListResponse} from '@utils/services.types'; import {CITIES_IDS} from '@utils/constants'; import {Location} from '@utils/location.types'; +import Config from 'react-native-config'; export const apiInstance = axios.create({ baseURL: 'https://api.openweathermap.org/data/2.5', params: { units: 'metric', - appId: process.env.WEATHER_API_KEY, + appId: Config.WEATHER_API_KEY, }, }); diff --git a/src/types/global.ts b/src/types/global.ts new file mode 100644 index 0000000..1d6f8df --- /dev/null +++ b/src/types/global.ts @@ -0,0 +1,8 @@ +declare module 'react-native-config' { + export interface NativeConfig { + WEATHER_API_KEY?: string; + } + + export const Config: NativeConfig; + export default Config; +} diff --git a/yarn.lock b/yarn.lock index 5ba6bb6..a74370f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2504,6 +2504,11 @@ acorn@^8.8.2, acorn@^8.9.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248" integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg== +add@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/add/-/add-2.0.6.tgz#248f0a9f6e5a528ef2295dbeec30532130ae2235" + integrity sha512-j5QzrmsokwWWp6kUcJQySpbG+xfOBqqKnup3OIk1pz+kB/80SLorZ9V8zHFLO92Lcd+hbvq8bT+zOGoPkmBV0Q== + ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" @@ -6288,6 +6293,11 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== +react-native-config@^1.5.3: + version "1.5.3" + resolved "https://registry.yarnpkg.com/react-native-config/-/react-native-config-1.5.3.tgz#1286c0c117adb367a948b31005430146e88c9c2e" + integrity sha512-3D05Abgk5DfDw9w258EzXvX5AkU7eqj3u9H0H0L4gUga4nYg/zuupcrpGbpF4QeXBcJ84jjs6g8JaEP6VBT7Pg== + react-native-dotenv@^3.4.11: version "3.4.11" resolved "https://registry.yarnpkg.com/react-native-dotenv/-/react-native-dotenv-3.4.11.tgz#2e6c4eabd55d5f1bf109b3dd9141dadf9c55cdd4" @@ -6305,10 +6315,10 @@ react-native-safe-area-context@^4.10.8: resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.10.8.tgz#038bd6a4853a38189c186d119302943c8d13f56f" integrity sha512-Jx1lovhvIdYygg0UsMCBUJN0Wvj9GlA5bbcBLzjZf93uJpNHzaiHC4hR280+sNVK1+/pMHEyEkXVHDZE5JWn0w== -react-native-screens@^3.34.0: - version "3.34.0" - resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.34.0.tgz#1291a460c5bc59e2ba581b42d40fa9a58d3b1197" - integrity sha512-8ri3Pd9QcpfXnVckOe/Lnto+BXmSPHV/Q0RB0XW0gDKsCv5wi5k7ez7g1SzgiYHl29MSdiqgjH30zUyOOowOaw== +react-native-screens@3.29.0: + version "3.29.0" + resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.29.0.tgz#1dee0326defbc1d4ef4e68287abb32a8e6b76b29" + integrity sha512-yB1GoAMamFAcYf4ku94uBPn0/ani9QG7NdI98beJ5cet2YFESYYzuEIuU+kt+CNRcO8qqKeugxlfgAa3HyTqlg== dependencies: react-freeze "^1.0.0" warn-once "^0.1.0" @@ -7636,6 +7646,11 @@ yargs@^17.3.1, yargs@^17.6.2, yargs@^17.7.2: y18n "^5.0.5" yargs-parser "^21.1.1" +yarn@^1.22.22: + version "1.22.22" + resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.22.tgz#ac34549e6aa8e7ead463a7407e1c7390f61a6610" + integrity sha512-prL3kGtyG7o9Z9Sv8IPfBNrWTDmXB4Qbes8A9rEzt6wkJV8mUvoirjU0Mp3GGAU06Y0XQyA3/2/RQFVuK7MTfg== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"