From 4e59dcf57e1da0774012e1ff699036a6f42be701 Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Wed, 13 Dec 2023 08:16:48 -0500 Subject: [PATCH] test(ios): Cavy: podspec location + AGP8 compat; ios no channels without the Cavy patch auto-linking fails as it requires the podspec at module root in modern react-native, and it has apparently been failing long enough that a bit of android-specific testing crept out of the android-specific testing area this also prepares the cavy native reporter for AGP8 --- tests_react_native/ios/Podfile.lock | 6 ++ .../patches/cavy-native-reporter+0.1.3.patch | 55 +++++++++++++++++++ tests_react_native/specs/notification.spec.ts | 3 +- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 tests_react_native/patches/cavy-native-reporter+0.1.3.patch diff --git a/tests_react_native/ios/Podfile.lock b/tests_react_native/ios/Podfile.lock index a32beb17..92630941 100644 --- a/tests_react_native/ios/Podfile.lock +++ b/tests_react_native/ios/Podfile.lock @@ -1,5 +1,7 @@ PODS: - boost (1.76.0) + - CavyNativeReporter (0.1.3): + - React-Core - DoubleConversion (1.1.6) - FBLazyVector (0.69.12) - FBReactNativeSpec (0.69.12): @@ -358,6 +360,7 @@ PODS: DEPENDENCIES: - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) + - CavyNativeReporter (from `../node_modules/cavy-native-reporter`) - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) @@ -412,6 +415,8 @@ SPEC REPOS: EXTERNAL SOURCES: boost: :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" + CavyNativeReporter: + :path: "../node_modules/cavy-native-reporter" DoubleConversion: :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" FBLazyVector: @@ -487,6 +492,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: a7c83b31436843459a1961bfd74b96033dc77234 + CavyNativeReporter: 22479f189ecd26513573801d005244bd47abb188 DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 FBLazyVector: 6fab494fa11340bd4206edaebed07279a6bafad4 FBReactNativeSpec: 76d7b03876b0ad0b86bc5c84d23af8e64db8e096 diff --git a/tests_react_native/patches/cavy-native-reporter+0.1.3.patch b/tests_react_native/patches/cavy-native-reporter+0.1.3.patch new file mode 100644 index 00000000..b02d0a32 --- /dev/null +++ b/tests_react_native/patches/cavy-native-reporter+0.1.3.patch @@ -0,0 +1,55 @@ +diff --git a/node_modules/cavy-native-reporter/ios/CavyNativeReporter.podspec b/node_modules/cavy-native-reporter/CavyNativeReporter.podspec +similarity index 81% +rename from node_modules/cavy-native-reporter/ios/CavyNativeReporter.podspec +rename to node_modules/cavy-native-reporter/CavyNativeReporter.podspec +index dd101c9..1019194 100644 +--- a/node_modules/cavy-native-reporter/ios/CavyNativeReporter.podspec ++++ b/node_modules/cavy-native-reporter/CavyNativeReporter.podspec +@@ -1,4 +1,4 @@ +-package = JSON.parse(File.read(File.join(__dir__, (File.join('..', 'package.json'))))) ++package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) + + Pod::Spec.new do |s| + s.name = "CavyNativeReporter" +@@ -10,7 +10,7 @@ Pod::Spec.new do |s| + s.author = { "author" => "dev@pixielabs.io" } + s.platform = :ios, "7.0" + s.source = { :git => "https://github.com/pixielabs/cavy-native-reporter.git", :tag => "v#{s.version}" } +- s.source_files = "*.{h,m}" ++ s.source_files = "ios/*.{h,m}" + s.requires_arc = true + s.dependency "React-Core" + end +diff --git a/node_modules/cavy-native-reporter/android/build.gradle b/node_modules/cavy-native-reporter/android/build.gradle +index 6c17279..b862d6b 100644 +--- a/node_modules/cavy-native-reporter/android/build.gradle ++++ b/node_modules/cavy-native-reporter/android/build.gradle +@@ -1,17 +1,27 @@ + + buildscript { ++ // The Android Gradle plugin is only required when opening the android folder stand-alone. ++ // This avoids unnecessary downloads and potential conflicts when the library is included as a ++ // module dependency in an application project. ++ if (project == rootProject) { + repositories { + jcenter() + } +- + dependencies { + classpath 'com.android.tools.build:gradle:1.3.1' + } ++ } + } + + apply plugin: 'com.android.library' + + android { ++ def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION ++ // Check AGP version for backward compatibility w/react-native versions still on gradle plugin 6 ++ if (agpVersion.tokenize('.')[0].toInteger() >= 7) { ++ namespace = "com.cavynativereporter" ++ } ++ + compileSdkVersion 28 + buildToolsVersion "28.0.3" + diff --git a/tests_react_native/specs/notification.spec.ts b/tests_react_native/specs/notification.spec.ts index c7e40c67..c87aba78 100644 --- a/tests_react_native/specs/notification.spec.ts +++ b/tests_react_native/specs/notification.spec.ts @@ -55,9 +55,8 @@ export function NotificationSpec(spec: TestScope): void { const customSoundChannel = await notifee.getChannel('new_custom_sound'); console.warn('customSoundChannel looks like: ' + JSON.stringify(customSoundChannel)); - expect(customSoundChannel).not.null; - if (Platform.OS === 'android' && customSoundChannel) { + expect(customSoundChannel).not.null; expect(customSoundChannel.soundURI).contains('horse.mp3'); expect(customSoundChannel.sound).equals('horse.mp3'); }