@@ -43,6 +43,22 @@ test(`should get correct canonical subscription URL for staging environment`, as
4343 t . is ( stagingUrls [ 0 ] . host , new URL ( `https://test.${ stagingDomain } ` ) . host ) ;
4444} ) ;
4545
46+
47+ test ( `should get correct canonical subscription URL when api.staging.onesignal.com is used` , async t => {
48+ const stagingDomain = "staging.onesignal.com" ;
49+ ( < any > global ) . __API_ORIGIN__ = `api.${ stagingDomain } ` ;
50+ const config = TestEnvironment . getFakeAppConfig ( ) ;
51+ config . subdomain = 'test' ;
52+ config . httpUseOneSignalCom = true ;
53+
54+ const browser = await TestEnvironment . stubDomEnvironment ( ) ;
55+ browser . changeURL ( window , `http://${ stagingDomain } ` ) ;
56+
57+ const stagingUrlsOsTcDomain = AltOriginManager . getCanonicalSubscriptionUrls ( config , EnvironmentKind . Staging ) ;
58+ t . is ( stagingUrlsOsTcDomain . length , 1 ) ;
59+ t . is ( stagingUrlsOsTcDomain [ 0 ] . host , new URL ( `https://test.${ stagingDomain } ` ) . host ) ;
60+ } ) ;
61+
4662test ( `should get correct canonical subscription URL for production environment` , async t => {
4763 const config = TestEnvironment . getFakeAppConfig ( ) ;
4864 config . subdomain = 'test' ;
@@ -60,6 +76,24 @@ test(`should get correct canonical subscription URL for production environment`,
6076 t . is ( prodUrls [ 0 ] . host , new URL ( 'https://test.os.tc' ) . host ) ;
6177} ) ;
6278
79+ test ( `should get correct canonical subscription URL for production environment with api. prefix` , async t => {
80+ ( < any > global ) . __API_ORIGIN__ = `api.onesignal.com` ;
81+ const config = TestEnvironment . getFakeAppConfig ( ) ;
82+ config . subdomain = 'test' ;
83+ config . httpUseOneSignalCom = true ;
84+
85+ const prodUrlsOsTcDomain = AltOriginManager . getCanonicalSubscriptionUrls ( config , EnvironmentKind . Production ) ;
86+ t . is ( prodUrlsOsTcDomain . length , 2 ) ;
87+ t . is ( prodUrlsOsTcDomain [ 0 ] . host , new URL ( 'https://test.os.tc' ) . host ) ;
88+ t . is ( prodUrlsOsTcDomain [ 1 ] . host , new URL ( 'https://test.onesignal.com' ) . host ) ;
89+
90+ config . httpUseOneSignalCom = false ;
91+
92+ const prodUrls = AltOriginManager . getCanonicalSubscriptionUrls ( config , EnvironmentKind . Production ) ;
93+ t . is ( prodUrls . length , 1 ) ;
94+ t . is ( prodUrls [ 0 ] . host , new URL ( 'https://test.os.tc' ) . host ) ;
95+ } ) ;
96+
6397function setupDiscoverAltOriginTest ( t : any ) {
6498 const appConfig = TestEnvironment . getFakeAppConfig ( ) ;
6599 appConfig . subdomain = 'test' ;
0 commit comments