From 0367d14044b019439df836dd7561ab25c1bf0e69 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 22 Oct 2018 15:33:40 +0300 Subject: [PATCH] test(docs-infra): run basic smoke tests against PR previews (#26649) This makes the tests run agaisnt the deployed production versions (as part of the `aio_monitoring` job) more reliable. PR Close #26649 --- aio/package.json | 2 ++ aio/scripts/test-preview.js | 23 +++++++++++---------- aio/tests/deployment/e2e/protractor.conf.js | 8 ++++--- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/aio/package.json b/aio/package.json index 2f869424c7..9726460eb0 100644 --- a/aio/package.json +++ b/aio/package.json @@ -30,6 +30,8 @@ "setup-local": "yarn aio-use-local && yarn example-use-local", "postsetup-local": "yarn postsetup", "set-opensearch-url": "node --eval \"const sh = require('shelljs'); sh.set('-e'); sh.sed('-i', /PLACEHOLDER_URL/g, process.argv[1], 'dist/assets/opensearch.xml');\"", + "presmoke-tests": "yarn update-webdriver", + "smoke-tests": "protractor tests/deployment/e2e/protractor.conf.js --suite smoke --baseUrl", "test-pwa-score": "node scripts/test-pwa-score", "test-pwa-score-localhost": "run-p --race \"~~http-server dist -p 4200 --silent\" \"test-pwa-score http://localhost:4200 {1} {2}\" --", "example-e2e": "yarn example-check-local && node ./tools/examples/run-example-e2e", diff --git a/aio/scripts/test-preview.js b/aio/scripts/test-preview.js index 3130187021..d68e42d75d 100644 --- a/aio/scripts/test-preview.js +++ b/aio/scripts/test-preview.js @@ -45,8 +45,9 @@ get(previewabilityCheckUrl). const totalSecs = Math.round((previewCheckInterval * previewCheckAttempts) / 1000); throw new Error(`Preview still not available after ${totalSecs}s.`); }). - // The preview is now available. Run the PWA tests. - then(() => runPwaTests()); + // The preview is now available. Run the tests. + then(() => yarnRun('smoke-tests', previewUrl)). + then(() => yarnRun('test-pwa-score', previewUrl, minPwaScore)); }). catch(onError); @@ -93,15 +94,6 @@ function reportNoPreview(reason) { console.log(`No (public) preview available. (Reason: ${reason})`); } -function runPwaTests() { - return new Promise((resolve, reject) => { - const spawnOptions = {cwd: __dirname, stdio: 'inherit'}; - spawn('yarn', ['test-pwa-score', previewUrl, minPwaScore], spawnOptions). - on('error', reject). - on('exit', code => (code === 0 ? resolve : reject)()); - }); -} - function validateArgs(args) { if (args.length !== 3) { const relativeScriptPath = relative('.', __filename.replace(/\.js$/, '')); @@ -119,3 +111,12 @@ function wait(delay) { console.log(`Waiting ${delay}ms...`); return new Promise(resolve => setTimeout(resolve, delay)); } + +function yarnRun(script, ...args) { + return new Promise((resolve, reject) => { + const spawnOptions = {cwd: __dirname, stdio: 'inherit'}; + spawn('yarn', [script, ...args], spawnOptions). + on('error', reject). + on('exit', code => (code === 0 ? resolve : reject)()); + }); +} diff --git a/aio/tests/deployment/e2e/protractor.conf.js b/aio/tests/deployment/e2e/protractor.conf.js index 72a1894efb..6c9f1eba18 100644 --- a/aio/tests/deployment/e2e/protractor.conf.js +++ b/aio/tests/deployment/e2e/protractor.conf.js @@ -3,9 +3,11 @@ exports.config = { allScriptsTimeout: 11000, - specs: [ - './*.e2e-spec.ts' - ], + suites: { + full: './*.e2e-spec.ts', + smoke: './smoke-tests.e2e-spec.ts', + }, + suite: 'full', capabilities: { browserName: 'chrome', // For Travis