1+ import { compileModsAsync } from 'expo/config-plugins' ;
2+ import withJPush from '../src' ;
13import {
24 ANDROID_MANIFEST_PATH ,
35 APP_BUILD_GRADLE_PATH ,
@@ -9,6 +11,7 @@ import {
911 readFixtureFile ,
1012 registerAndroidFixtureLifecycleHooks ,
1113} from './androidFixture' ;
14+ import { createExpoConfig , createPluginProps } from './testProps' ;
1215
1316registerAndroidFixtureLifecycleHooks ( ) ;
1417
@@ -201,4 +204,96 @@ describe('native Android config mods', () => {
201204 )
202205 ) . toBe ( 1 ) ;
203206 } ) ;
207+
208+ it ( 'keeps Android config values isolated across independently configured plugin instances' , async ( ) => {
209+ const projectRootA = createProjectRoot ( ) ;
210+ const projectRootB = createProjectRoot ( ) ;
211+ const configA = withJPush (
212+ createExpoConfig ( ) ,
213+ createPluginProps ( { packageName : 'com.example.alpha' } )
214+ ) ;
215+ const configB = withJPush (
216+ createExpoConfig ( ) ,
217+ createPluginProps ( {
218+ packageName : 'com.example.beta' ,
219+ vendorChannels : { huawei : { enabled : true } } ,
220+ } )
221+ ) ;
222+
223+ await compileModsAsync ( configA , {
224+ projectRoot : projectRootA ,
225+ platforms : [ 'android' ] ,
226+ } ) ;
227+ await compileModsAsync ( configB , {
228+ projectRoot : projectRootB ,
229+ platforms : [ 'android' ] ,
230+ } ) ;
231+
232+ const appBuildGradleA = readFixtureFile ( projectRootA , APP_BUILD_GRADLE_PATH ) ;
233+ const appBuildGradleB = readFixtureFile ( projectRootB , APP_BUILD_GRADLE_PATH ) ;
234+ const gradlePropertiesA = readFixtureFile (
235+ projectRootA ,
236+ GRADLE_PROPERTIES_PATH
237+ ) ;
238+ const gradlePropertiesB = readFixtureFile (
239+ projectRootB ,
240+ GRADLE_PROPERTIES_PATH
241+ ) ;
242+
243+ expect ( appBuildGradleA ) . toContain ( '"com.example.alpha"' ) ;
244+ expect ( appBuildGradleA ) . not . toContain (
245+ "implementation 'com.huawei.hms:push:6.13.0.300'"
246+ ) ;
247+ expect ( gradlePropertiesA ) . not . toContain ( 'apmsInstrumentationEnabled=false' ) ;
248+
249+ expect ( appBuildGradleB ) . toContain ( '"com.example.beta"' ) ;
250+ expect ( appBuildGradleB ) . toContain (
251+ "implementation 'com.huawei.hms:push:6.13.0.300'"
252+ ) ;
253+ expect ( gradlePropertiesB ) . toContain ( 'apmsInstrumentationEnabled=false' ) ;
254+ } ) ;
255+
256+ it ( 'does not inject Huawei or FCM integrations when their enabled flags are false' , async ( ) => {
257+ const projectRoot = createProjectRoot ( ) ;
258+
259+ await compileAndroidMods ( projectRoot , {
260+ vendorChannels : {
261+ huawei : { enabled : false } ,
262+ fcm : { enabled : false } ,
263+ } ,
264+ } ) ;
265+
266+ const appBuildGradle = readFixtureFile ( projectRoot , APP_BUILD_GRADLE_PATH ) ;
267+ const projectBuildGradle = readFixtureFile (
268+ projectRoot ,
269+ PROJECT_BUILD_GRADLE_PATH
270+ ) ;
271+ const gradleProperties = readFixtureFile (
272+ projectRoot ,
273+ GRADLE_PROPERTIES_PATH
274+ ) ;
275+
276+ expect ( appBuildGradle ) . not . toContain (
277+ "implementation 'com.huawei.hms:push:6.13.0.300'"
278+ ) ;
279+ expect ( appBuildGradle ) . not . toContain (
280+ "implementation 'com.google.firebase:firebase-messaging:24.1.0'"
281+ ) ;
282+ expect ( appBuildGradle ) . not . toContain (
283+ "apply plugin: 'com.google.gms.google-services'"
284+ ) ;
285+ expect ( appBuildGradle ) . not . toContain (
286+ "apply plugin: 'com.huawei.agconnect'"
287+ ) ;
288+ expect ( projectBuildGradle ) . not . toContain (
289+ "classpath 'com.google.gms:google-services:4.4.0'"
290+ ) ;
291+ expect ( projectBuildGradle ) . not . toContain (
292+ "classpath 'com.huawei.agconnect:agcp:1.9.3.302'"
293+ ) ;
294+ expect ( projectBuildGradle ) . not . toContain (
295+ "maven { url 'https://developer.huawei.com/repo/' }"
296+ ) ;
297+ expect ( gradleProperties ) . not . toContain ( 'apmsInstrumentationEnabled=false' ) ;
298+ } ) ;
204299} ) ;
0 commit comments