From 912c1ced423df4d0d0a109ecffa829e1c1c5fe9b Mon Sep 17 00:00:00 2001 From: Georgy Steshin Date: Sun, 21 Jan 2024 12:20:58 +0200 Subject: [PATCH] Fixes after MR --- .buildkite/jobs/pipeline.android_rn_71.yml | 1 + .../action/GetAttributesActionTest.kt | 2 -- detox/android/rninfo.gradle | 2 -- detox/test/e2e/03.actions.test.js | 4 ++-- detox/test/e2e/33.attributes.test.js | 4 ++-- detox/test/e2e/detox.config-android.js | 2 +- detox/test/e2e/utils/custom-it.js | 14 +++++++----- .../utils/rn-consts}/rn-consts.js | 0 detox/test/ios/Podfile | 22 ++++++++----------- detox/test/src/Screens/ActionsScreen.js | 9 ++++---- detox/test/src/Screens/AttributesScreen.js | 8 +++---- .../demo-react-native/android/settings.gradle | 2 +- examples/demo-react-native/ios/Podfile | 2 +- 13 files changed, 34 insertions(+), 38 deletions(-) rename detox/test/{src/helpers => e2e/utils/rn-consts}/rn-consts.js (100%) diff --git a/.buildkite/jobs/pipeline.android_rn_71.yml b/.buildkite/jobs/pipeline.android_rn_71.yml index 43861094f0..86b06155b1 100644 --- a/.buildkite/jobs/pipeline.android_rn_71.yml +++ b/.buildkite/jobs/pipeline.android_rn_71.yml @@ -6,6 +6,7 @@ REACT_NATIVE_VERSION: 0.71.10 DETOX_DISABLE_POD_INSTALL: true DETOX_DISABLE_POSTINSTALL: true + SKIP_UNIT_TESTS: true artifact_paths: - "/Users/builder/work/coverage/**/*.lcov" - "/Users/builder/work/**/allure-report-*.html" diff --git a/detox/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt b/detox/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt index 6975b71108..cb5d9481e6 100644 --- a/detox/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +++ b/detox/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt @@ -197,8 +197,6 @@ class GetAttributesActionTest { on { progress } doReturn 50 } - progressBar. - val resultJson = perform(progressBar) assertThat(resultJson.opt("value")).isEqualTo(0.5) }*/ diff --git a/detox/android/rninfo.gradle b/detox/android/rninfo.gradle index 6f5e454b8f..3bf5c739e5 100644 --- a/detox/android/rninfo.gradle +++ b/detox/android/rninfo.gradle @@ -34,6 +34,4 @@ if (hasProperty('project')) { isRN71OrHigher: rnMajorVer >= 71, isRN72OrHigher: rnMajorVer >= 72, ] -} else { - println "settings.gradle RNInfo: detected React Native version: $rnVersion (major=$rnMajorVer)" } diff --git a/detox/test/e2e/03.actions.test.js b/detox/test/e2e/03.actions.test.js index c0e78ac04e..315db569f0 100644 --- a/detox/test/e2e/03.actions.test.js +++ b/detox/test/e2e/03.actions.test.js @@ -1,5 +1,5 @@ -const { itRNVersionOrBelow } = require('./utils/custom-it'); const driver = require('./drivers/actions-driver').actionsScreenDriver; +const custom = require('./utils/custom-it'); describe('Actions', () => { beforeEach(async () => { @@ -213,7 +213,7 @@ describe('Actions', () => { await expect(element(by.id('UniqueId007'))).toBeVisible(); }); - itRNVersionOrBelow(71)('should adjust legacy slider and assert its value', async () => { + custom.it.skipFromRNVersion(71)('should adjust legacy slider and assert its value', async () => { const reactSliderId = 'legacySliderWithASimpleID'; await expect(element(by.id(reactSliderId))).toHaveSliderPosition(0.25); await element(by.id(reactSliderId)).adjustSliderToPosition(0.75); diff --git a/detox/test/e2e/33.attributes.test.js b/detox/test/e2e/33.attributes.test.js index 05a51b7bed..ad24149b50 100644 --- a/detox/test/e2e/33.attributes.test.js +++ b/detox/test/e2e/33.attributes.test.js @@ -1,6 +1,6 @@ const { device, element, by } = require('detox'); const expect = require('expect').default; -const { describeRNVersionOrBelow } = require('./utils/custom-it'); +const { custom } = require('./utils/custom-it'); describe('Attributes', () => { /** @type {Detox.IndexableNativeElement} */ @@ -157,7 +157,7 @@ describe('Attributes', () => { }); }); - describeRNVersionOrBelow(71)('of a legacy slider', () => { + custom.describe.skipFromRNVersion(71)('of a legacy slider', () => { beforeAll(() => useMatcher(by.id('legacySliderId'))); it(':ios: should have a string percent .value, and .normalizedSliderPosition', () => { diff --git a/detox/test/e2e/detox.config-android.js b/detox/test/e2e/detox.config-android.js index 892c7776b1..2ab6fb00cc 100644 --- a/detox/test/e2e/detox.config-android.js +++ b/detox/test/e2e/detox.config-android.js @@ -1,5 +1,5 @@ const _ = require('lodash'); -const { rnVersion } = require('../src/helpers/rn-consts'); +const { rnVersion } = require('./utils/rn-consts/rn-consts'); const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1); const isRNVersionBellow71 = (rnVersion.minor < 71); diff --git a/detox/test/e2e/utils/custom-it.js b/detox/test/e2e/utils/custom-it.js index 6222a4123d..e837b60d64 100644 --- a/detox/test/e2e/utils/custom-it.js +++ b/detox/test/e2e/utils/custom-it.js @@ -1,13 +1,18 @@ const _ = require('lodash'); -const rnMinorVer = require('../../src/helpers/rn-consts').rnVersion.minor; +const rnMinorVer = require('./rn-consts/rn-consts').rnVersion.minor; const _it = { withFailureIf: { android: (spec, specFn) => runOrExpectFailByPredicates(spec, specFn, platformIs('android')), iOSWithRNLessThan67: (spec, specFn) => runOrExpectFailByPredicates(spec, specFn, platformIs('ios'), rnVerLessThan(67)), }, + skipFromRNVersion: (version) => skipFromRNVersion(version), }; +const _describe = { + describeFromRNVersion: (version) => describeFromRNVersion(version), +} + function runOrExpectFailByPredicates(spec, specFn, ...predicateFuncs) { it(spec, async function() { if (allPredicatesTrue(predicateFuncs)) { @@ -23,7 +28,7 @@ function runOrExpectFailByPredicates(spec, specFn, ...predicateFuncs) { * Run the test only if the RN version is {version} or below. Otherwise, skip it. * @returns it or it.skip functions */ -function itRNVersionOrBelow(version) { +function skipFromRNVersion(version) { if (parseInt(rnMinorVer) <= version) { return it; } else { @@ -36,7 +41,7 @@ function itRNVersionOrBelow(version) { * @param version * @returns describe or describe.skip functions */ -function describeRNVersionOrBelow(version) { +function describeFromRNVersion(version) { if (parseInt(rnMinorVer) <= version) { return describe; } else { @@ -62,6 +67,5 @@ const runSpec = (specFn) => specFn(); module.exports = { it: _it, - itRNVersionOrBelow, - describeRNVersionOrBelow + describe: describe, }; diff --git a/detox/test/src/helpers/rn-consts.js b/detox/test/e2e/utils/rn-consts/rn-consts.js similarity index 100% rename from detox/test/src/helpers/rn-consts.js rename to detox/test/e2e/utils/rn-consts/rn-consts.js diff --git a/detox/test/ios/Podfile b/detox/test/ios/Podfile index b94b89fe44..e9ec0d500d 100644 --- a/detox/test/ios/Podfile +++ b/detox/test/ios/Podfile @@ -46,7 +46,7 @@ setup_permissions([ def shared_pods config = use_native_modules! - if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.(68|69|70).*/) + if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.(70).*/) # Flags change depending on the env values. flags = get_default_flags() @@ -106,20 +106,16 @@ post_install do |installer| config = use_native_modules! - if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.6[6,7,8,9].*/) - react_native_post_install(installer) - else - react_native_post_install( - installer, - config[:reactNativePath], - # Set `mac_catalyst_enabled` to `true` in order to apply patches - # necessary for Mac Catalyst builds - :mac_catalyst_enabled => false - ) - end + react_native_post_install( + installer, + config[:reactNativePath], + # Set `mac_catalyst_enabled` to `true` in order to apply patches + # necessary for Mac Catalyst builds + :mac_catalyst_enabled => false + ) # See https://github.com/wix/Detox/pull/3035#discussion_r774747705 - if !ENV["REACT_NATIVE_VERSION"] || ENV["REACT_NATIVE_VERSION"].match(/0.(66|67|68|69|70|72).*/) + if !ENV["REACT_NATIVE_VERSION"] || ENV["REACT_NATIVE_VERSION"].match(/0.(70|72).*/) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end diff --git a/detox/test/src/Screens/ActionsScreen.js b/detox/test/src/Screens/ActionsScreen.js index 6fb335f220..a105e87e8b 100644 --- a/detox/test/src/Screens/ActionsScreen.js +++ b/detox/test/src/Screens/ActionsScreen.js @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -const { rnVersion } = require('../helpers/rn-consts'); import { Text, BackHandler, @@ -16,11 +15,11 @@ import { import TextInput from '../Views/TextInput'; import Slider from '@react-native-community/slider'; -const isLegacyRNVersion = (parseInt(rnVersion.minor) <= 71); - let LegacySlider; -if (isLegacyRNVersion) { +try { LegacySlider = require('react-native').Slider; +} catch (e) { + LegacySlider = undefined; } const DoubleTapsText = requireNativeComponent('DetoxDoubleTapsTextView'); @@ -182,7 +181,7 @@ export default class ActionsScreen extends Component { { - isLegacyRNVersion && + LegacySlider && diff --git a/detox/test/src/Screens/AttributesScreen.js b/detox/test/src/Screens/AttributesScreen.js index 2d4eb4d907..ea0e59afe8 100644 --- a/detox/test/src/Screens/AttributesScreen.js +++ b/detox/test/src/Screens/AttributesScreen.js @@ -8,14 +8,14 @@ import { } from 'react-native'; import CheckBox from '@react-native-community/checkbox'; import Slider from '@react-native-community/slider'; -import { rnVersion } from '../helpers/rn-consts'; import {default as DatePicker} from '@react-native-community/datetimepicker'; -const isLegacyRNVersion = (parseInt(rnVersion.minor) <= 71); let LegacySlider; -if (isLegacyRNVersion) { +try { LegacySlider = require('react-native').Slider; +} catch (e) { + LegacySlider = undefined; } export default class AttributesScreen extends Component { @@ -80,7 +80,7 @@ export default class AttributesScreen extends Component { }} autoFocus={false} /> - {isLegacyRNVersion && } + {LegacySlider && } ); diff --git a/examples/demo-react-native/android/settings.gradle b/examples/demo-react-native/android/settings.gradle index 541e24099d..ca091cf2fb 100644 --- a/examples/demo-react-native/android/settings.gradle +++ b/examples/demo-react-native/android/settings.gradle @@ -5,7 +5,7 @@ include ':app' println("RNInfo: rootDir=$rootDir") def rnMajorVer = getRnMajorVersion(rootDir) -println "[settings] RNInfo: detected React Native version: (major=$rnMajorVer)" +println("[settings] RNInfo: detected React Native version: (major=$rnMajorVer)") if (rnMajorVer < 72) { includeBuild('../node_modules/react-native-gradle-plugin') diff --git a/examples/demo-react-native/ios/Podfile b/examples/demo-react-native/ios/Podfile index efe7c24b80..cb87b5d2c1 100644 --- a/examples/demo-react-native/ios/Podfile +++ b/examples/demo-react-native/ios/Podfile @@ -35,7 +35,7 @@ target 'example' do ) # See https://github.com/wix/Detox/pull/3035#discussion_r774747705 - if !ENV["REACT_NATIVE_VERSION"] || ENV["REACT_NATIVE_VERSION"].match(/0.(66|67|68|69|70|72).*/) + if !ENV["REACT_NATIVE_VERSION"] || ENV["REACT_NATIVE_VERSION"].match(/0.(70|72).*/) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end