diff --git a/circle.yml b/circle.yml index b7e6234f9..3fcfbaed9 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 @@ -141,11 +160,18 @@ workflows: ignore: /.*/ tags: only: /^v.*/ + - android_integration_tests: + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ - deploy_stage: requires: - build - test - integration_tests + - android_integration_tests filters: branches: ignore: /.*/ diff --git a/package.json b/package.json index 359b8935d..15025ef4d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,9 @@ "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", + "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} diff --git a/test/testServer.js b/test/testServer.js index 12fe05be8..93a94033f 100644 --- a/test/testServer.js +++ b/test/testServer.js @@ -15,12 +15,38 @@ 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); }); 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'] });