@@ -149,6 +149,69 @@ describe(addAndroidAuth0Manifest, () => {
149149 }
150150 expect ( check ( ) ) . toMatchSnapshot ( ) ;
151151 } ) ;
152+
153+ it ( `should correctly add pathPrefix to Android manifest with application ID` , ( ) => {
154+ const config = getConfig ( ) ;
155+ const result = addAndroidAuth0Manifest (
156+ [ { domain : 'sample.auth0.com' } ] ,
157+ config ,
158+ 'com.auth0.testapp'
159+ ) ;
160+
161+ // Access the RedirectActivity to check if the pathPrefix is correctly added
162+ const mainApplication = AndroidConfig . Manifest . getMainApplicationOrThrow (
163+ result . modResults
164+ ) ;
165+ const redirectActivity = mainApplication . activity ?. find (
166+ ( activity ) =>
167+ activity . $ [ 'android:name' ] ===
168+ 'com.auth0.android.provider.RedirectActivity'
169+ ) ;
170+
171+ const intentFilter = redirectActivity ?. [ 'intent-filter' ] ?. [ 0 ] ;
172+ const dataElement = intentFilter ?. data ?. [ 0 ] ;
173+
174+ expect ( dataElement ) . toBeDefined ( ) ;
175+ expect ( dataElement ?. $ [ 'android:pathPrefix' ] ) . toBe (
176+ '/android/com.auth0.testapp/callback'
177+ ) ;
178+ expect ( dataElement ?. $ [ 'android:scheme' ] ) . toBe ( 'com.auth0.testapp.auth0' ) ;
179+ expect ( dataElement ?. $ [ 'android:host' ] ) . toBe ( 'sample.auth0.com' ) ;
180+ } ) ;
181+
182+ it ( `should correctly add pathPrefix to Android manifest with custom scheme` , ( ) => {
183+ const config = getConfig ( ) ;
184+ const result = addAndroidAuth0Manifest (
185+ [
186+ {
187+ domain : 'sample.auth0.com' ,
188+ customScheme : 'com.custom.scheme' ,
189+ } ,
190+ ] ,
191+ config ,
192+ 'com.auth0.testapp'
193+ ) ;
194+
195+ // Access the RedirectActivity to check if the pathPrefix is correctly added
196+ const mainApplication = AndroidConfig . Manifest . getMainApplicationOrThrow (
197+ result . modResults
198+ ) ;
199+ const redirectActivity = mainApplication . activity ?. find (
200+ ( activity ) =>
201+ activity . $ [ 'android:name' ] ===
202+ 'com.auth0.android.provider.RedirectActivity'
203+ ) ;
204+
205+ const intentFilter = redirectActivity ?. [ 'intent-filter' ] ?. [ 0 ] ;
206+ const dataElement = intentFilter ?. data ?. [ 0 ] ;
207+
208+ expect ( dataElement ) . toBeDefined ( ) ;
209+ expect ( dataElement ?. $ [ 'android:pathPrefix' ] ) . toBe (
210+ '/android/com.auth0.testapp/callback'
211+ ) ;
212+ expect ( dataElement ?. $ [ 'android:scheme' ] ) . toBe ( 'com.custom.scheme' ) ;
213+ expect ( dataElement ?. $ [ 'android:host' ] ) . toBe ( 'sample.auth0.com' ) ;
214+ } ) ;
152215} ) ;
153216
154217describe ( addIOSAuth0ConfigInInfoPList , ( ) => {
0 commit comments