diff --git a/src/Rokt-Kit.js b/src/Rokt-Kit.js index ce29f00..1730adf 100644 --- a/src/Rokt-Kit.js +++ b/src/Rokt-Kit.js @@ -435,9 +435,15 @@ var constructor = function () { function isPartnerInLocalLauncherTestGroup() { return ( window.mParticle.config && - window.mParticle.config.isLocalLauncherEnabled + window.mParticle.config.isLocalLauncherEnabled && + _isAssignedToSampleGroup() ); } + + function _isAssignedToSampleGroup() { + var LOCAL_LAUNCHER_TEST_GROUP_THRESHOLD = 0.5; + return Math.random() > LOCAL_LAUNCHER_TEST_GROUP_THRESHOLD; + } }; function generateIntegrationName(customIntegrationName) { diff --git a/test/src/tests.js b/test/src/tests.js index 459d04b..fc073a4 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -566,6 +566,7 @@ describe('Rokt Forwarder', () => { }, }; window.mParticle.config = undefined; + Math.random = () => 1; }); it('should create a remote launcher if the partner is not in the local launcher test group', async () => { @@ -598,6 +599,44 @@ describe('Rokt Forwarder', () => { window.mParticle.Rokt.createLocalLauncherCalled.should.equal(true); }); + it('should create a remote launcher if the partner is in the local launcher test group but the random number is below the thresholds', async () => { + window.mParticle.config = { + isLocalLauncherEnabled: true, + }; + + Math.random = () => 0; + + await window.mParticle.forwarder.init( + { accountId: '123456' }, + reportService.cb, + true, + null, + {} + ); + + window.mParticle.Rokt.createLauncherCalled.should.equal(true); + window.mParticle.Rokt.createLocalLauncherCalled.should.equal(false); + }); + + it('should create a local launcher if the partner is in the local launcher test group but the random number is above the thresholds', async () => { + window.mParticle.config = { + isLocalLauncherEnabled: true, + }; + + Math.random = () => 1; + + await window.mParticle.forwarder.init( + { accountId: '123456' }, + reportService.cb, + true, + null, + {} + ); + + window.mParticle.Rokt.createLauncherCalled.should.equal(false); + window.mParticle.Rokt.createLocalLauncherCalled.should.equal(true); + }); + it('should call attachKit', async () => { await window.mParticle.forwarder.init( { accountId: '123456' },