Skip to content

Commit

Permalink
DSPX Adapter: Fix userSync problem with passback responses (prebid#7199)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander <avj83@list.ru>
  • Loading branch information
2 people authored and agrandes-tappx committed Sep 29, 2021
1 parent 8bd7ee3 commit 71e8827
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
24 changes: 13 additions & 11 deletions modules/dspxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,19 @@ export const spec = {
}
}

if (syncOptions.iframeEnabled) {
serverResponses[0].body.userSync.iframeUrl.forEach((url) => syncs.push({
type: 'iframe',
url: appendToUrl(url, gdprParams)
}));
}
if (syncOptions.pixelEnabled && serverResponses.length > 0) {
serverResponses[0].body.userSync.imageUrl.forEach((url) => syncs.push({
type: 'image',
url: appendToUrl(url, gdprParams)
}));
if (serverResponses.length > 0 && serverResponses[0].body.userSync) {
if (syncOptions.iframeEnabled) {
serverResponses[0].body.userSync.iframeUrl.forEach((url) => syncs.push({
type: 'iframe',
url: appendToUrl(url, gdprParams)
}));
}
if (syncOptions.pixelEnabled) {
serverResponses[0].body.userSync.imageUrl.forEach((url) => syncs.push({
type: 'image',
url: appendToUrl(url, gdprParams)
}));
}
}
return syncs;
}
Expand Down
23 changes: 23 additions & 0 deletions test/spec/modules/dspxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,27 @@ describe('dspxAdapter', function () {
expect(userSync[2].type).to.be.equal('image');
});
});

describe(`getUserSyncs test usage in passback response`, function () {
let serverResponses;

beforeEach(function () {
serverResponses = [{
body: {
reason: 8002,
status: 'error',
msg: 'passback',
}
}];
});

it(`check for zero array when iframeEnabled`, function () {
expect(spec.getUserSyncs({ iframeEnabled: true })).to.be.an('array');
expect(spec.getUserSyncs({ iframeEnabled: true }, serverResponses).length).to.be.equal(0);
});
it(`check for zero array when iframeEnabled`, function () {
expect(spec.getUserSyncs({ pixelEnabled: true })).to.be.an('array');
expect(spec.getUserSyncs({ pixelEnabled: true }, serverResponses).length).to.be.equal(0);
});
});
});

0 comments on commit 71e8827

Please sign in to comment.