From a761aa73b6821baf0fb0e4f3098c3087f7fb8535 Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Tue, 19 Mar 2019 09:48:50 -0400 Subject: [PATCH 1/4] Add android test step to package.json. --- package.json | 1 + test/testServer.js | 28 +++++++++++++++++++++++++++- test/wdio.local.conf.js | 6 ++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 359b8935d..b8112bb70 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "test:frontend": "cross-env NODE_ENV=development node test/frontend/runner.js", "test:report": "nyc report --reporter=html", "test-integration": "cross-env NODE_ENV=development wdio test/wdio.docker.conf.js", + "test-integration:android": "cross-env NODE_ENV=development ANDROID=1 wdio test/wdio.local.conf.js", "circleci-test-integration": "cross-env NODE_ENV=development wdio test/wdio.circleci.conf.js", "start": "npm run clean && cross-env NODE_ENV=development FXA_CLIENT_ID=fced6b5e3f4c66b9 BASE_URL=http://localhost:8080 webpack-dev-server --mode=development", "android": "cross-env ANDROID=1 npm start", diff --git a/test/testServer.js b/test/testServer.js index 12fe05be8..0cd4f1dea 100644 --- a/test/testServer.js +++ b/test/testServer.js @@ -15,14 +15,40 @@ module.exports = { const wpm = middleware(webpack(config(null, { mode: 'development' })), { logLevel: 'silent' }); + const ID_REGEX = '([0-9a-fA-F]{10})'; + app.use(wpm); + + function android(req, res) { + const index = wpm.fileSystem + .readFileSync(wpm.getFilenameFromUrl('/android.html')) + .toString() + .replace( + '', + '' + ); + res.set('Content-Type', 'text/html'); + res.send(index); + } + if (process.env.ANDROID) { + // map all html routes to the android index.html + app.get('/', android); + app.get('/legal', android); + app.get(`/share/:id${ID_REGEX}`, android); + app.get('/completed', android); + app.get('/preferences', android); + app.get('/options', android); + app.get('/oauth', android); + } + assets.setMiddleware(wpm); expressWs(app, null, { perMessageDeflate: false }); app.ws('/api/ws', require('../server/routes/ws')); routes(app); tests(app); + wpm.waitUntilValid(() => { - server = app.listen(8000, resolve); + server = app.listen(8080, resolve); }); }); }, diff --git a/test/wdio.local.conf.js b/test/wdio.local.conf.js index 7b39c7cba..b8db96974 100644 --- a/test/wdio.local.conf.js +++ b/test/wdio.local.conf.js @@ -3,14 +3,12 @@ const ip = require('ip'); const common = require('./wdio.common.conf'); /*/ - Config for running selenium against localhost - /*/ exports.config = Object.assign({}, common.config, { - baseUrl: `http://${ip.address()}:8000`, + baseUrl: `http://${ip.address()}:8080`, maxInstances: 1, bail: 1, - services: [require('./testServer')] + services: [require('./testServer'), 'selenium-standalone'] }); From 0eb1c1e5d682050889d75f4dade833eab17317ca Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Tue, 19 Mar 2019 12:48:31 -0400 Subject: [PATCH 2/4] Add circleci config for running android integration tests. --- circle.yml | 20 ++++++++++++++++++++ package.json | 1 + scripts/bin/run-integration-test-circleci.sh | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index b7e6234f9..af686a778 100644 --- a/circle.yml +++ b/circle.yml @@ -47,6 +47,25 @@ jobs: - node_modules - run: name: Run integration test + environment: + INTEGRATION_TEST_JOB: "circleci-test-integration" + command: ./scripts/bin/run-integration-test-circleci.sh + android_integration_tests: + docker: + - image: circleci/node:10-browsers + steps: + - checkout + - restore_cache: + key: send-int-{{ checksum "package-lock.json" }} + - run: npm install + - save_cache: + key: send-int-{{ checksum "package-lock.json" }} + paths: + - node_modules + - run: + name: Run integration test + environment: + INTEGRATION_TEST_JOB: "circleci-test-integration:android" command: ./scripts/bin/run-integration-test-circleci.sh deploy_dev: machine: true @@ -146,6 +165,7 @@ workflows: - build - test - integration_tests + - android-integration-tests filters: branches: ignore: /.*/ diff --git a/package.json b/package.json index b8112bb70..15025ef4d 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "test-integration": "cross-env NODE_ENV=development wdio test/wdio.docker.conf.js", "test-integration:android": "cross-env NODE_ENV=development ANDROID=1 wdio test/wdio.local.conf.js", "circleci-test-integration": "cross-env NODE_ENV=development wdio test/wdio.circleci.conf.js", + "circleci-test-integration:android": "cross-env NODE_ENV=development ANDROID=1 wdio test/wdio.circleci.conf.js", "start": "npm run clean && cross-env NODE_ENV=development FXA_CLIENT_ID=fced6b5e3f4c66b9 BASE_URL=http://localhost:8080 webpack-dev-server --mode=development", "android": "cross-env ANDROID=1 npm start", "prod": "node server/bin/prod.js" diff --git a/scripts/bin/run-integration-test-circleci.sh b/scripts/bin/run-integration-test-circleci.sh index 183e478c2..30bec44e8 100755 --- a/scripts/bin/run-integration-test-circleci.sh +++ b/scripts/bin/run-integration-test-circleci.sh @@ -25,4 +25,4 @@ mozdownload --version latest --type daily --destination ~/project/firefox-downlo export PATH=~/project/firefox:$PATH mozinstall $(ls -t firefox-downloads/firefox_nightly/*.tar.bz2 | head -1) firefox --version - npm run circleci-test-integration \ No newline at end of file +npm run ${INTEGRATION_TEST_JOB} From 384d3a0f6840ea29fa99c16ae15b073b838c0615 Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Tue, 19 Mar 2019 12:52:16 -0400 Subject: [PATCH 3/4] Updates. --- circle.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/circle.yml b/circle.yml index af686a778..72dd6b532 100644 --- a/circle.yml +++ b/circle.yml @@ -160,6 +160,12 @@ workflows: ignore: /.*/ tags: only: /^v.*/ + - android-integration_tests: + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ - deploy_stage: requires: - build From e2b407899c5b311861e8d5e5b6520b5614e94691 Mon Sep 17 00:00:00 2001 From: Benjamin Forehand Jr Date: Tue, 19 Mar 2019 13:13:28 -0400 Subject: [PATCH 4/4] Change server IP. --- circle.yml | 4 ++-- test/testServer.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index 72dd6b532..3fcfbaed9 100644 --- a/circle.yml +++ b/circle.yml @@ -160,7 +160,7 @@ workflows: ignore: /.*/ tags: only: /^v.*/ - - android-integration_tests: + - android_integration_tests: filters: branches: ignore: /.*/ @@ -171,7 +171,7 @@ workflows: - build - test - integration_tests - - android-integration-tests + - android_integration_tests filters: branches: ignore: /.*/ diff --git a/test/testServer.js b/test/testServer.js index 0cd4f1dea..93a94033f 100644 --- a/test/testServer.js +++ b/test/testServer.js @@ -25,7 +25,7 @@ module.exports = { .toString() .replace( '', - '' + '' ); res.set('Content-Type', 'text/html'); res.send(index); @@ -48,7 +48,7 @@ module.exports = { tests(app); wpm.waitUntilValid(() => { - server = app.listen(8080, resolve); + server = app.listen(8000, resolve); }); }); },