Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions modules/intentIqIdSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@

function verifyIdType(value: number): number {
if (value === 0 || value === 1 || value === 3 || value === 4) return value;
return -1;

Check warning on line 230 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

230 line is not covered with tests
}

function appendPartnersFirstParty(url: string, configParams: any): string {
Expand Down Expand Up @@ -273,7 +273,7 @@
+d[3]
);
} catch (e) {
return NaN;

Check warning on line 276 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

276 line is not covered with tests
}
}

Expand Down Expand Up @@ -474,11 +474,16 @@
const cmpData = getCmpData();
const gdprDetected = cmpData.gdprString;
firstPartyData = tryParse(readData(FIRST_PARTY_KEY_FINAL, allowedStorage) as string);
actualABGroup = defineABTestingGroup(configParams, partnerData?.terminationCause);
if (groupChanged) groupChanged(actualABGroup, partnerData?.terminationCause);
const currentBrowserLowerCase = detectBrowser();
const browserBlackList = typeof configParams.browserBlackList === 'string' ? configParams.browserBlackList.toLowerCase() : '';
const isBlacklisted = browserBlackList?.includes(currentBrowserLowerCase);

if (!isBlacklisted) {
actualABGroup = defineABTestingGroup(configParams, partnerData?.terminationCause);
if (groupChanged) groupChanged(actualABGroup, partnerData?.terminationCause);
} else {
actualABGroup = undefined;
}
let newUser = false;

setGamReporting(gamObjectReference, gamParameterName, actualABGroup, isBlacklisted);
Expand Down Expand Up @@ -539,7 +544,7 @@
if (chSupported) {
chPromise = fetchAndHandleCH();
chPromise.catch((err: any) => {
logError('fetchAndHandleCH failed', err);

Check warning on line 547 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

547 line is not covered with tests
});
} else {
clientHints = '';
Expand All @@ -555,8 +560,8 @@
if (typeof partnerData.failCount === 'number') failCount = partnerData.failCount;
if (typeof partnerData.noDataCounter === 'number') noDataCount = partnerData.noDataCounter;
if (partnerData.wsrvcll) {
partnerData.wsrvcll = false;
storeData(PARTNER_DATA_KEY, JSON.stringify(partnerData), allowedStorage, firstPartyData);

Check warning on line 564 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

563-564 lines are not covered with tests
}

if (partnerData.data) {
Expand Down Expand Up @@ -623,7 +628,7 @@
.then((ch: any) => buildAndSendPixel(ch || ''));
}
} else {
buildAndSendPixel('');

Check warning on line 631 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

631 line is not covered with tests
}
return;
}
Expand Down Expand Up @@ -686,7 +691,7 @@
};
if (callbackTimeoutID) clearTimeout(callbackTimeoutID);
if ('cttl' in respJson) {
partnerData.cttl = respJson.cttl;

Check warning on line 694 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

694 line is not covered with tests
} else partnerData.cttl = HOURS_72;

if ('tc' in respJson) {
Expand Down Expand Up @@ -727,7 +732,7 @@
}
// If data is empty, means we should save as INVALID_ID
if (respJson.data === '') {
respJson.data = INVALID_ID;

Check warning on line 735 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

735 line is not covered with tests
} else {
// If data is a single string, assume it is an id with source intentiq.com
if (respJson.data && typeof respJson.data === 'string') {
Expand All @@ -742,7 +747,7 @@
}

if ('sid' in respJson) {
partnerData.siteId = respJson.sid;

Check warning on line 750 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

750 line is not covered with tests
}

if ('spd' in respJson) {
Expand All @@ -751,14 +756,14 @@
}

if ('abTestUuid' in respJson) {
if ('ls' in respJson && respJson.ls === true) {
partnerData.abTestUuid = respJson.abTestUuid;

Check warning on line 760 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

759-760 lines are not covered with tests
}
}

if ('gpr' in respJson) {
// GAM prediction reporting
partnerData.gpr = respJson.gpr;

Check warning on line 766 in modules/intentIqIdSystem.ts

View workflow job for this annotation

GitHub Actions / Coverage

766 line is not covered with tests
} else {
delete partnerData.gpr; // remove prediction flag in case server doesn't provide it
}
Expand Down
73 changes: 73 additions & 0 deletions test/spec/modules/intentIqIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,79 @@
expect(groupChangedSpy.calledWith(usedGroup)).to.be.true;
});

it('should NOT call groupChanged when the current browser is blacklisted', async function () {
const groupChangedSpy = sinon.spy();
const blk = detectBrowser();
const configParams = {
params: {
...defaultConfigParams.params,
browserBlackList: blk,
groupChanged: groupChangedSpy
}
};

intentIqIdSubmodule.getId(configParams);
await waitForClientHints();

expect(groupChangedSpy.called).to.be.false;
});

it('should not mark a test group on the sync pixel when the current browser is blacklisted', async function () {
const blk = detectBrowser();
const configParams = {
params: {
...defaultConfigParams.params,
browserBlackList: blk
}
};

intentIqIdSubmodule.getId(configParams);
await waitForClientHints();

const pixelRequest = server.requests[0];
expect(pixelRequest).to.exist;
expect(pixelRequest.url).to.include('at=20');
expect(pixelRequest.url).to.not.include('testGroup=');
expect(pixelRequest.url).to.include('isInTestGroup=false');
});


Check failure on line 2068 in test/spec/modules/intentIqIdSystem_spec.js

View workflow job for this annotation

GitHub Actions / Run linter

More than 1 blank line not allowed
it('should NOT call groupChanged when the current browser is blacklisted', async function () {
const groupChangedSpy = sinon.spy();
const blk = detectBrowser();
const configParams = {
params: {
...defaultConfigParams.params,
browserBlackList: blk,
groupChanged: groupChangedSpy
}
};

intentIqIdSubmodule.getId(configParams);
await waitForClientHints();

expect(groupChangedSpy.called).to.be.false;
});

it('should not mark a test group on the sync pixel when the current browser is blacklisted', async function () {
const blk = detectBrowser();
const configParams = {
params: {
...defaultConfigParams.params,
browserBlackList: blk
}
};

intentIqIdSubmodule.getId(configParams);
await waitForClientHints();

const pixelRequest = server.requests[0];
expect(pixelRequest).to.exist;
expect(pixelRequest.url).to.include('at=20');
expect(pixelRequest.url).to.not.include('testGroup=');
expect(pixelRequest.url).to.include('isInTestGroup=false');
});

it('should include testPercentage with configured abPercentage in AT=39 URL', async function () {
const callBackSpy = sinon.spy();
const configParams = {
Expand Down
Loading