Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubleshoot test failures #5093

Closed
wants to merge 74 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
8d635ff
Add microadBidAdapter
Feb 15, 2019
3055b90
Remove unnecessary encodeURIComponent from microadBidAdapter
Feb 26, 2019
67fb91b
Submit Advangelists Prebid Adapter
Feb 26, 2019
3ebb916
Submit Advangelists Prebid Adapter 1.1
Feb 27, 2019
4f5c451
Correct procudtion endpoint for prebid
Feb 28, 2019
2dc6d1d
Merge branch 'microad-bid-adapter' of git://github.com/strong-zero/Pr…
Feb 28, 2019
fa3e081
Merge remote-tracking branch 'origin/master' into master-rubicon-clean
Mar 18, 2019
600a46e
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Mar 18, 2019
7f578b3
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 23, 2019
176a312
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 26, 2019
9abf89c
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 13, 2019
6ce04ab
Merge remote-tracking branch 'upstream/master'
Jun 10, 2019
415e2f6
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jun 27, 2019
61fb82c
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 11, 2019
3cc4c67
analytics update with wrapper name
Jul 11, 2019
cd81e02
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
e2b4e04
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
53b5970
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
5c00ed5
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 16, 2019
28848ad
reverted error merge
Jul 16, 2019
ab635ee
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 19, 2019
93308f5
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 24, 2019
1cfd52d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 25, 2019
d619807
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 27, 2019
9893f0f
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 7, 2019
986a251
Merge remote-tracking branch 'upstream/master'
Aug 23, 2019
2cae7c0
Merge branch 'master' of https://github.com/prebid/Prebid.js into ori…
Aug 27, 2019
d7fd252
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 4, 2019
c7c01ba
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 10, 2019
24a28aa
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 10, 2019
7a1a4ec
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Sep 25, 2019
4173d16
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 25, 2019
ca13952
update changed default value of netRevenue to true
Sep 27, 2019
0b6cd48
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 3, 2019
5f0110d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 3, 2019
f930a34
Merge remote-tracking branch 'upstream/master'
Oct 8, 2019
9bff282
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 14, 2019
712ec9e
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
f192f65
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
006f53c
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
0341150
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 31, 2019
fa59897
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 15, 2019
dcff2cf
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 20, 2019
0222ce2
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 24, 2019
227beca
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 25, 2019
dc3ee49
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Dec 4, 2019
9a5a08d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Dec 4, 2019
35ea5d4
Merge branch 'master' of https://github.com/prebid/Prebid.js
Dec 6, 2019
f89b71c
Merge branch 'master' of https://github.com/prebid/Prebid.js
Dec 17, 2019
4e1679b
Re-add rubicon analytics without deprecated getTopWindowUrl util
Dec 17, 2019
fd80acd
Cache referrer on auction_init instead of bid_requested
Dec 17, 2019
2ab26a3
Merge pull request #51 from rubicon-project/rubicon-analytics-3.0
msm0504 Dec 17, 2019
7de7ca6
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Jan 9, 2020
5f1fe06
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jan 9, 2020
60b5ad8
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jan 17, 2020
5f44edd
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Feb 10, 2020
4809354
Merge branch 'master' of https://github.com/prebid/Prebid.js
Feb 10, 2020
8d8bdff
Merge branch 'master' of https://github.com/prebid/Prebid.js
Feb 13, 2020
a1a2318
Merge branch 'master' of https://github.com/prebid/Prebid.js
Feb 19, 2020
ac2ac12
Merge branch 'master' of https://github.com/prebid/Prebid.js
Feb 24, 2020
5ce8787
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Mar 12, 2020
6c2bdec
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 12, 2020
a54a491
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 27, 2020
889178d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 27, 2020
40cba46
Merge branch 'master' of https://github.com/prebid/Prebid.js
Apr 4, 2020
93d8130
fix stubs the navigator userAgent property using sinon
Apr 7, 2020
a9a4148
update lock
Apr 7, 2020
009b792
Merge branch 'master' of https://github.com/prebid/Prebid.js into fix…
May 29, 2020
70e0c8d
update currency to use the mocks/xhr.js server
May 29, 2020
3c80453
update test sinon mocking in user id
May 29, 2020
675dd2b
reverted package change
Jul 6, 2020
b90b12d
revert change
Jul 6, 2020
dab791f
update line ending for consistency
Jul 7, 2020
de24fe3
Merge branch 'master' into fix-pbjs-test-failures
Aug 21, 2020
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
79 changes: 31 additions & 48 deletions test/spec/modules/currency_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,16 @@ import {
currencyRates
} from 'modules/currency.js';

import { server } from 'test/mocks/xhr.js';

var assert = require('chai').assert;
var expect = require('chai').expect;

describe('currency', function () {
let fakeCurrencyFileServer;
let sandbox;
let clock;

let fn = sinon.spy();

beforeEach(function () {
fakeCurrencyFileServer = sinon.fakeServer.create();
});

afterEach(function () {
fakeCurrencyFileServer.restore();
setConfig({});
});

Expand All @@ -52,9 +46,8 @@ describe('currency', function () {
expect(getGlobal().convertCurrency).to.be.a('function');
});
it('results in currencySupportEnabled = true and currencyRates being loaded when configured', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ 'adServerCurrency': 'JPY' });
fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify(getCurrencyRates()));
expect(currencyRates.dataAsOf).to.equal('2017-04-25');
expect(currencySupportEnabled).to.equal(true);
});
Expand All @@ -67,9 +60,9 @@ describe('currency', function () {
setConfig({
'adServerCurrency': 'JPY'
});
fakeCurrencyFileServer.respond();
expect(fakeCurrencyFileServer.requests.length).to.equal(1);
expect(fakeCurrencyFileServer.requests[0].url).to.equal('https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=20030306');
server.requests[0].respond();
expect(server.requests.length).to.equal(1);
expect(server.requests[0].url).to.equal('https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=20030306');

// RESET to request currency file (specifically url value for this test)
setConfig({ 'adServerCurrency': undefined });
Expand All @@ -81,9 +74,8 @@ describe('currency', function () {
'GBP': { 'CNY': 66, 'JPY': 132, 'USD': 264 },
'USD': { 'CNY': 60, 'GBP': 120, 'JPY': 240 }
} });
fakeCurrencyFileServer.respond();
expect(fakeCurrencyFileServer.requests.length).to.equal(2);
expect(fakeCurrencyFileServer.requests[1].url).to.equal('https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=20030306');
server.requests[1].respond();
expect(server.requests[1].url).to.equal('https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=20030306');
});

it('date macro token $$TODAY$$ is replaced by current date (formatted as yyyymmdd)', function () {
Expand All @@ -92,8 +84,8 @@ describe('currency', function () {

// date macro should replace $$TODAY$$ with date when DEFAULT_CURRENCY_RATE_URL is used
setConfig({ 'adServerCurrency': 'JPY' });
fakeCurrencyFileServer.respond();
expect(fakeCurrencyFileServer.requests[0].url).to.equal('https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=20030306');
server.requests[0].respond();
expect(server.requests[0].url).to.equal('https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=20030306');

// RESET to request currency file (specifically url value for this test)
setConfig({ 'adServerCurrency': undefined });
Expand All @@ -103,8 +95,8 @@ describe('currency', function () {
'adServerCurrency': 'JPY',
'conversionRateFile': 'http://test.net/currency.json?date=foobar'
});
fakeCurrencyFileServer.respond();
expect(fakeCurrencyFileServer.requests[1].url).to.equal('http://test.net/currency.json?date=foobar');
server.requests[1].respond();
expect(server.requests[1].url).to.equal('http://test.net/currency.json?date=foobar');

// RESET to request currency file (specifically url value for this test)
setConfig({ 'adServerCurrency': undefined });
Expand All @@ -114,8 +106,8 @@ describe('currency', function () {
'adServerCurrency': 'JPY',
'conversionRateFile': 'http://test.net/currency.json?date=$$TODAY$$'
});
fakeCurrencyFileServer.respond();
expect(fakeCurrencyFileServer.requests[2].url).to.equal('http://test.net/currency.json?date=20030306');
server.requests[2].respond();
expect(server.requests[2].url).to.equal('http://test.net/currency.json?date=20030306');

// RESET to request currency file (specifically url value for this test)
setConfig({ 'adServerCurrency': undefined });
Expand All @@ -125,8 +117,8 @@ describe('currency', function () {
'adServerCurrency': 'JPY',
'conversionRateFile': 'http://test.net/$$TODAY$$/currency.json?date=$$TODAY$$'
});
fakeCurrencyFileServer.respond();
expect(fakeCurrencyFileServer.requests[3].url).to.equal('http://test.net/20030306/currency.json?date=$$TODAY$$');
server.requests[3].respond();
expect(server.requests[3].url).to.equal('http://test.net/20030306/currency.json?date=$$TODAY$$');
});
});

Expand All @@ -141,23 +133,22 @@ describe('currency', function () {
// first conversion should use default rates
expect(getGlobal().convertCurrency(1.0, 'USD', 'EUR')).to.equal(2);
expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(100);
fakeCurrencyFileServer.respond();
server.requests[0].respond();
});
it('uses fetch rates if returned', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify({
'dataAsOf': '2017-04-25',
'conversions': {
'USD': { EUR: 4, JPY: 200 }
}
}));
setConfig({
'adServerCurrency': 'USD',
'defaultRates': {
'USD': { EUR: 2, JPY: 100 }
}
});
// now respond and should use updates rates
fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify({
'dataAsOf': '2017-04-25',
'conversions': {
'USD': {EUR: 4, JPY: 200}
}
}));
expect(getGlobal().convertCurrency(1.0, 'USD', 'EUR')).to.equal(4);
expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(200);
});
Expand Down Expand Up @@ -270,7 +261,7 @@ describe('currency', function () {
});

// default response is 404
fakeCurrencyFileServer.respond();
server.requests[0].respond();

var bid = { cpm: 100, currency: 'JPY', bidder: 'rubicon' };
var innerBid;
Expand All @@ -289,8 +280,6 @@ describe('currency', function () {
it('not run until currency rates file is loaded', function () {
setConfig({});

fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));

var bid = { 'cpm': 1, 'currency': 'USD' };

setConfig({ 'adServerCurrency': 'JPY' });
Expand All @@ -302,7 +291,7 @@ describe('currency', function () {

expect(marker).to.equal(false);

fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify(getCurrencyRates()));
expect(marker).to.equal(true);
});
});
Expand Down Expand Up @@ -345,9 +334,8 @@ describe('currency', function () {
// RESET to request currency file
setConfig({ 'adServerCurrency': undefined });

fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ 'adServerCurrency': 'JPY' });
fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify(getCurrencyRates()));
var bid = { 'cpm': 1, 'currency': 'ABC' };
var innerBid;
addBidResponseHook(function(adCodeId, bid) {
Expand All @@ -357,9 +345,8 @@ describe('currency', function () {
});

it('should result in NO_BID when adServerCurrency is not supported in file', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ 'adServerCurrency': 'ABC' });
fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify(getCurrencyRates()));
var bid = { 'cpm': 1, 'currency': 'GBP' };
var innerBid;
addBidResponseHook(function(adCodeId, bid) {
Expand All @@ -369,9 +356,8 @@ describe('currency', function () {
});

it('should return 1 when currency support is enabled and same currency code is requested as is set to adServerCurrency', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ 'adServerCurrency': 'JPY' });
fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify(getCurrencyRates()));
var bid = { 'cpm': 1, 'currency': 'JPY' };
var innerBid;
addBidResponseHook(function(adCodeId, bid) {
Expand All @@ -382,9 +368,8 @@ describe('currency', function () {
});

it('should return direct conversion rate when fromCurrency is one of the configured bases', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ 'adServerCurrency': 'GBP' });
fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify(getCurrencyRates()));
var bid = { 'cpm': 1, 'currency': 'USD' };
var innerBid;
addBidResponseHook(function(adCodeId, bid) {
Expand All @@ -395,9 +380,8 @@ describe('currency', function () {
});

it('should return reciprocal conversion rate when adServerCurrency is one of the configured bases, but fromCurrency is not', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ 'adServerCurrency': 'GBP' });
fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify(getCurrencyRates()));
var bid = { 'cpm': 1, 'currency': 'CNY' };
var innerBid;
addBidResponseHook(function(adCodeId, bid) {
Expand All @@ -408,9 +392,8 @@ describe('currency', function () {
});

it('should return intermediate conversion rate when neither fromCurrency nor adServerCurrency is one of the configured bases', function () {
fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
setConfig({ 'adServerCurrency': 'CNY' });
fakeCurrencyFileServer.respond();
server.requests[0].respond(200, {}, JSON.stringify(getCurrencyRates()));
var bid = { 'cpm': 1, 'currency': 'JPY' };
var innerBid;
addBidResponseHook(function(adCodeId, bid) {
Expand Down
40 changes: 28 additions & 12 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js';
import {sharedIdSubmodule} from 'modules/sharedIdSystem.js';
import {server} from 'test/mocks/xhr.js';

let assert = require('chai').assert;
let expect = require('chai').expect;
const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT';
const CONSENT_LOCAL_STORAGE_NAME = '_pbjs_userid_consent_data';

Expand Down Expand Up @@ -317,11 +315,12 @@ describe('User ID', function() {
// removed cookie
coreStorage.setCookie('_pbjs_id_optout', '', EXPIRED_COOKIE_DATE);
$$PREBID_GLOBAL$$.requestBids.removeAll();
utils.logInfo.restore();
utils.logInfo.resetHistory();
config.resetConfig();
});

after(function() {
after(function () {
utils.logInfo.restore();
coreStorage.setCookie('_pbjs_id_optout', '', EXPIRED_COOKIE_DATE);
});

Expand All @@ -343,15 +342,19 @@ describe('User ID', function() {
describe('Handle variations of config values', function() {
beforeEach(function() {
sinon.stub(utils, 'logInfo');
});
})

afterEach(function() {
$$PREBID_GLOBAL$$.requestBids.removeAll();
utils.logInfo.restore();
utils.logInfo.resetHistory();
config.resetConfig();
});

it('handles config with no usersync object', function() {
after(function () {
utils.logInfo.restore();
})

it('handles config with no usersync object', function () {
setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule]);
init(config);
config.setConfig({});
Expand Down Expand Up @@ -492,19 +495,21 @@ describe('User ID', function() {
let mockIdCallback;
let auctionSpy;

beforeEach(function() {
before(function () {
sandbox = sinon.createSandbox();
sandbox.stub(global, 'setTimeout').returns(2);
sandbox.stub(events, 'on');
sandbox.stub(coreStorage, 'getCookie');
auctionSpy = sandbox.spy();
mockIdCallback = sandbox.stub();
})

beforeEach(function() {
// remove cookie
coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE);

adUnits = [getAdUnitMock()];

auctionSpy = sandbox.spy();
mockIdCallback = sandbox.stub();
const mockIdSystem = {
name: 'mockId',
decode: function(value) {
Expand All @@ -529,9 +534,13 @@ describe('User ID', function() {
afterEach(function() {
$$PREBID_GLOBAL$$.requestBids.removeAll();
config.resetConfig();
sandbox.restore();
sandbox.resetHistory();
});

after(function () {
sandbox.restore();
})

it('delays auction if auctionDelay is set, timing out at auction delay', function() {
config.setConfig({
userSync: {
Expand Down Expand Up @@ -1385,15 +1394,22 @@ describe('User ID', function() {
});

describe('callbacks at the end of auction', function() {
beforeEach(function() {
before(function () {
sinon.stub(events, 'getEvents').returns([]);
sinon.stub(utils, 'triggerPixel');
})
beforeEach(function() {
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('_parrable_eid', '', EXPIRED_COOKIE_DATE);
});

afterEach(function() {
events.getEvents.resetHistory();
utils.triggerPixel.resetHistory();
});

after(function() {
events.getEvents.restore();
utils.triggerPixel.restore();
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
Expand Down