Skip to content

Commit

Permalink
Circle CI runs e2e tests on every push (prebid#4200)
Browse files Browse the repository at this point in the history
* run functional tests on circle ci on push to any remote branch

* remove extraneous key from config file

* add test.localhost as alias to 127.0.0.1

* check 0: execute circle-ci

* move /etc/config to a separate command

* change bid partner to rubicon

* test appnexus bid adapter in ci

* comment browserstack command

* remove console.log statement

* test1: circle-ci

* change reference dev -> prod while loading prebid

* add console.log statement

* check-2: circle-ci

* comment browserstack testing

* change bid adapter

* change bid adapter

* remove test case for checking targeting keys

* remove the ci flag

* uncomment test for checking correct generation of targeting keys

* swap AN -> Rubicon for testing targeting keys
  • Loading branch information
Fawke authored and jaiminpanchal27 committed Oct 7, 2019
1 parent 214efe8 commit bc855ed
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
key: v1-dependencies-{{ checksum "package.json" }}

- run: sudo npm install -g gulp-cli

# Download and run BrowserStack local
- run:
name : Download BrowserStack Local binary and start it.
Expand All @@ -48,3 +49,7 @@ jobs:
- run:
name: BrowserStack testing
command: gulp test --browserstack --nolintfix
# run e2e tests
- run:
name: Functional testing
command: echo "127.0.0.1 test.localhost" | sudo tee -a /etc/hosts && gulp e2e-test --host=test.localhost --file=./test/spec/e2e/banner/basic_banner_ad.spec.js
29 changes: 24 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,35 @@ function bundle(dev, moduleArr) {
// If --browserstack is given, it will run the full suite of currently supported browsers.
// If --browsers is given, browsers can be chosen explicitly. e.g. --browsers=chrome,firefox,ie9
// If --notest is given, it will immediately skip the test task (useful for developing changes with `gulp serve --notest`)

function test(done) {
if (argv.notest) {
done();
} else if (argv.e2e) {
let wdioCmd = path.join(__dirname, 'node_modules/.bin/wdio');
let wdioConf = path.join(__dirname, 'wdio.conf.js');
let wdioOpts = [
wdioConf
];
return execa(wdioCmd, wdioOpts, { stdio: 'inherit' });
let wdioOpts;

if (argv.file) {
wdioOpts = [
wdioConf,
`--spec`,
`${argv.file}`
]
} else {
wdioOpts = [
wdioConf
];
}
execa(wdioCmd, wdioOpts, { stdio: 'inherit' })
.then(stdout => {
done();
process.exit(0);
})
.catch(err => {
done(new Error(`Tests failed with error: ${err}`));
process.exit(1);
});
} else {
var karmaConf = karmaConfMaker(false, argv.browserstack, argv.watch, argv.file);

Expand Down Expand Up @@ -315,7 +334,7 @@ gulp.task('build-postbid', gulp.series(escapePostbidConfig, buildPostbid));
gulp.task('serve', gulp.series(clean, lint, gulp.parallel('build-bundle-dev', watch, test)));
gulp.task('default', gulp.series(clean, makeWebpackPkg));

gulp.task('e2e-test', gulp.series(clean, setupE2e, gulp.parallel('build-bundle-dev', watch), test))
gulp.task('e2e-test', gulp.series(clean, setupE2e, gulp.parallel('build-bundle-prod', watch), test))
// other tasks
gulp.task(bundleToStdout);
gulp.task('bundle', gulpBundle.bind(null, false)); // used for just concatenating pre-built files with no build step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Prebid Freewheel Integration Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <script async src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js"></script> -->
<script src="/build/dev/prebid.js" async=true></script>
<script src="/build/dist/prebid.js" async=true></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
Expand Down Expand Up @@ -129,4 +129,4 @@ <h2 class="mb-0">

</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Prebid Freewheel Integration Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <script async src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js"></script> -->
<script src="/build/dev/prebid.js" async=true></script>
<script src="/build/dist/prebid.js" async=true></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
Expand Down Expand Up @@ -127,4 +127,4 @@ <h2 class="mb-0">

</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Prebid Freewheel Integration Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <script async src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js"></script> -->
<script src="/build/dev/prebid.js" async=true></script>
<script src="/build/dist/prebid.js" async=true></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
Expand Down Expand Up @@ -127,4 +127,4 @@ <h2 class="mb-0">

</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Prebid Freewheel Integration Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <script async src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js"></script> -->
<script src="/build/dev/prebid.js" async=true></script>
<script src="/build/dist/prebid.js" async=true></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
Expand Down Expand Up @@ -128,4 +128,4 @@ <h2 class="mb-0">

</body>

</html>
</html>
16 changes: 9 additions & 7 deletions test/pages/banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Prebid.js Banner Example</title>

<!-- Prebid.js -->
<script async src="../../build/dev/prebid.js"></script>
<script async src="../../build/dist/prebid.js"></script>

<!-- Google Publisher Tag -->
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
Expand Down Expand Up @@ -38,9 +38,11 @@
}
},
bids: [{
bidder: 'appnexus',
bidder: "rubicon",
params: {
placementId: 13144370
accountId: 14062,
siteId: 70608,
zoneId: 498816
}
}]
}];
Expand Down Expand Up @@ -74,7 +76,7 @@
googletag
.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0')
.addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
Expand All @@ -84,9 +86,9 @@
<body>
<h2>Prebid.js Banner Ad Unit Test</h2>
<div id='div-gpt-ad-1460505748561-0'>
<script>
googletag.cmd.push(() => { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
<script>
googletag.cmd.push(() => { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
<div id="targeting-keys"></div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion test/pages/native.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Prebid.js Native Example</title>

<!-- Prebid.js -->
<script async src="../../build/dev/prebid.js"></script>
<script async src="../../build/dist/prebid.js"></script>

<!-- Google Publisher Tag -->
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/pages/outstream.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Prebid.js Video Outstream Example</title>

<!-- Load Prebid.js -->
<script async src="../../build/dev/prebid.js"></script>
<script async src="../../build/dist/prebid.js"></script>

<!-- Load Google Publisher Tag -->
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/pages/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-vast-vpaid/2.0.2/videojs_5.vast.vpaid.min.js"></script>

<!-- prebid.js -->
<script src="../../build/dev/prebid.js" async=true></script>
<script src="../../build/dist/prebid.js" async=true></script>


<script>
Expand Down
20 changes: 10 additions & 10 deletions test/spec/e2e/banner/basic_banner_ad.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const TEST_PAGE_URL = `${protocol}://${host}:9999/test/pages/banner.html`;
const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="google_ads_iframe_/19968336/header-bid-tag-0_0"]';

const EXPECTED_TARGETING_KEYS = {
hb_format: 'banner',
hb_source: 'client',
hb_pb: '0.50',
hb_bidder: 'appnexus',
hb_format_appnexus: 'banner',
hb_source_appnexus: 'client',
hb_pb_appnexus: '0.50',
hb_bidder_appnexus: 'appnexus'
}
'hb_format': 'banner',
'hb_source': 'client',
'hb_pb': '0.60',
'hb_bidder': 'rubicon',
'hb_format_rubicon': 'banner',
'hb_source_rubicon': 'client',
'hb_pb_rubicon': '0.60',
'hb_bidder_rubicon': 'rubicon'
};

describe('Prebid.js Banner Ad Unit Test', function () {
before(function loadTestPage() {
Expand All @@ -38,7 +38,7 @@ describe('Prebid.js Banner Ad Unit Test', function () {

expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS);
expect(targetingKeys.hb_adid).to.be.a('string');
expect(targetingKeys.hb_adid_appnexus).to.be.a('string');
expect(targetingKeys.hb_adid_rubicon).to.be.a('string');
expect(targetingKeys.hb_size).to.satisfy((size) => size === '300x250' || '300x600');
});

Expand Down
8 changes: 7 additions & 1 deletion wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ function getCapabilities() {
return platformMap[os];
}

// remove the IE11 browser from functional tests
// only Edge 16, Chrome 74 & Firefox 66 run as part of functional tests
// rest of the browsers are discarded.
delete browsers['bs_ie_11_windows_10'];
delete browsers['bs_edge_17_windows_10'];
delete browsers['bs_chrome_75_windows_10'];
delete browsers['bs_firefox_67_windows_10'];
delete browsers['bs_safari_11_mac_high_sierra'];
delete browsers['bs_safari_12_mac_mojave'];

let capabilities = []
Object.keys(browsers).forEach(key => {
Expand Down

0 comments on commit bc855ed

Please sign in to comment.