@@ -714,6 +714,78 @@ describe('EppoPrecomputedClient E2E test', () => {
714714 pollAfterFailedInitialization ? red : 'default' ,
715715 ) ;
716716 } ) ;
717+
718+ describe ( 'Enhanced SDK Token with encoded subdomain' , ( ) => {
719+ let urlsRequested : string [ ] = [ ] ;
720+
721+ beforeEach ( ( ) => {
722+ urlsRequested = [ ] ;
723+ global . fetch = jest . fn ( ( url ) => {
724+ urlsRequested . push ( url . toString ( ) ) ;
725+ return Promise . resolve ( {
726+ ok : true ,
727+ status : 200 ,
728+ json : ( ) => Promise . resolve ( precomputedResponse ) ,
729+ } as Response ) ;
730+ } ) ;
731+ } ) ;
732+
733+ it ( 'should request from the encoded subdomain' , async ( ) => {
734+ const client = new EppoPrecomputedClient ( {
735+ precomputedFlagStore : new MemoryOnlyConfigurationStore < PrecomputedFlag > ( ) ,
736+ subject,
737+ requestParameters : {
738+ apiKey : 'zCsQuoHJxVPp895.Y3M9ZXhwZXJpbWVudA==' , // subdomain=experiment
739+ sdkName : 'js-client-sdk-common' ,
740+ sdkVersion : '1.0.0' ,
741+ } ,
742+ } ) ;
743+
744+ await client . fetchPrecomputedFlags ( ) ;
745+
746+ expect ( urlsRequested ) . toHaveLength ( 1 ) ;
747+ expect ( urlsRequested [ 0 ] ) . toContain (
748+ 'https://experiment.fs-edge-assignment.eppo.cloud/assignments?apiKey=zCsQuoHJxVPp895.Y3M9ZXhwZXJpbWVudA%3D%3D&sdkName=js-client-sdk-common&sdkVersion=1.0.0' ,
749+ ) ;
750+ } ) ;
751+
752+ it ( 'should request from the default domain if the encoded subdomain is not present' , async ( ) => {
753+ const client = new EppoPrecomputedClient ( {
754+ precomputedFlagStore : new MemoryOnlyConfigurationStore < PrecomputedFlag > ( ) ,
755+ subject,
756+ requestParameters : {
757+ apiKey : 'old style key' ,
758+ sdkName : 'js-client-sdk-common' ,
759+ sdkVersion : '1.0.0' ,
760+ } ,
761+ } ) ;
762+
763+ await client . fetchPrecomputedFlags ( ) ;
764+
765+ expect ( urlsRequested ) . toHaveLength ( 1 ) ;
766+ expect ( urlsRequested [ 0 ] ) . toEqual (
767+ 'https://fs-edge-assignment.eppo.cloud/assignments?apiKey=old+style+key&sdkName=js-client-sdk-common&sdkVersion=1.0.0' ,
768+ ) ;
769+ } ) ;
770+
771+ it ( 'should request from the provided baseUrl if present' , async ( ) => {
772+ const client = new EppoPrecomputedClient ( {
773+ precomputedFlagStore : new MemoryOnlyConfigurationStore < PrecomputedFlag > ( ) ,
774+ subject,
775+ requestParameters : {
776+ apiKey : 'zCsQuoHJxVPp895.Y3M9ZXhwZXJpbWVudA==' , // subdomain=experiment
777+ sdkName : 'js-client-sdk-common' ,
778+ sdkVersion : '1.0.0' ,
779+ baseUrl : 'https://custom-base-url.com' ,
780+ } ,
781+ } ) ;
782+
783+ await client . fetchPrecomputedFlags ( ) ;
784+
785+ expect ( urlsRequested ) . toHaveLength ( 1 ) ;
786+ expect ( urlsRequested [ 0 ] ) . toContain ( 'https://custom-base-url.com' ) ;
787+ } ) ;
788+ } ) ;
717789 } ) ;
718790
719791 describe ( 'Obfuscated precomputed flags' , ( ) => {
0 commit comments