diff --git a/.circleci/config.yml b/.circleci/config.yml index edcaae9e532..db0d3df10cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,92 +6,45 @@ orbs: horizon: artsy/release@0.0.1 node: artsy/node@1.0.0 yarn: artsy/yarn@5.1.3 + artsy-remote-docker: artsy/remote-docker@dev:612b35f7058aed43d189438a46cdeee8 jobs: - run_deepcrawl_automator: - docker: - - image: cimg/base:2020.09 - environment: - AUTOMATOR_START_ONLY: true - steps: - - run: - name: Download automator script - command: curl https://raw.githubusercontent.com/deepcrawl/automator-sdk/master/ci.sh --output automator.sh - - run: - name: Start automator crawl - command: chmod +x automator.sh && ./automator.sh - acceptance_cypress: - docker: - - image: circleci/node:12-stretch-browsers + mocha: + executor: hokusai/deploy steps: - - yarn/setup - - run: - name: Cypress Tests - command: yarn test:smoke + - hokusai/setup-docker + - run: hokusai registry pull --tag "$CIRCLE_SHA1" + - run: docker run --rm -e NODE_ENV=test --entrypoint /bin/bash "hokusai_force" /usr/local/bin/yarn test:mocha - validate_production_schema: - executor: node/build + jest: + executor: hokusai/deploy steps: - - yarn/setup - - run: - name: Validate Production Schema - command: node scripts/validateSchemas.js production + - hokusai/setup-docker + - run: hokusai registry pull --tag "$CIRCLE_SHA1" + - run: docker run --rm -e NODE_ENV=test --entrypoint /bin/bash "hokusai_force" /usr/local/bin/yarn test:jest - build: - executor: node/build + type-check: + executor: hokusai/deploy steps: - - yarn/setup - - run: - name: Build force assets - command: yarn assets - - store_artifacts: - path: ~/project/.artifacts - - run: - name: Duplicates Report - command: curl "https://artsy-dupe-report.now.sh/packages/dupe-report/now.js?owner=artsy&repo=force&buildNum=$CIRCLE_BUILD_NUM" - - # FIXME: Reenable after https://github.com/artsy/force/pull/5673 is addressed - # danger: - # executor: node/build - # steps: - # - yarn/setup - # - run: - # name: Danger - # # Formatted this way to prevent GitHub's token detection. This is intended to be committed and public. - # command: DANGER_GITHUB_API_TOKEN="3f715685d9d032e17""48c3368dc8f22c672849136" yarn danger ci + - hokusai/setup-docker + - run: hokusai registry pull --tag "$CIRCLE_SHA1" + - run: docker run --rm -e NODE_ENV=test --entrypoint /bin/bash "hokusai_force" /usr/local/bin/yarn type-check - create_or_update_review_app: + acceptance: executor: hokusai/deploy steps: - hokusai/setup-docker - - hokusai/install-aws-iam-authenticator - - hokusai/configure-hokusai - - run: - name: Install jq - command: curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 > /usr/local/bin/jq - - run: - name: Make jq executable - command: chmod u+x /usr/local/bin/jq - - run: - name: "Create or update review app" - command: | - review_app_name=$(echo $CIRCLE_BRANCH | sed 's/review-app-//') - - kubectl config use-context staging - - if $(kubectl get namespace | grep -qi $review_app_name); then - ./scripts/update_review_app.sh $review_app_name - else - ./scripts/build_review_app.sh $review_app_name - fi + - run: hokusai registry pull --tag "$CIRCLE_SHA1" + - run: docker build -t electron-runner -f electron.Dockerfile . + - run: docker run --rm --entrypoint /app/scripts/xvfb-run.sh electron-runner /usr/local/bin/yarn test:acceptance -not_master_or_staging_or_release: ¬_master_or_staging_or_release - filters: - branches: - ignore: - - master - - staging - - release + acceptance-cypress: + executor: hokusai/deploy + steps: + - hokusai/setup-docker + - run: hokusai registry pull --tag "$CIRCLE_SHA1" + - run: docker build -t electron-runner -f electron.Dockerfile . + - run: docker run --rm --entrypoint /app/scripts/xvfb-run.sh electron-runner /usr/local/bin/yarn test:smoke not_staging_or_release: ¬_staging_or_release filters: @@ -100,108 +53,56 @@ not_staging_or_release: ¬_staging_or_release - staging - release -only_master: &only_master - context: hokusai - filters: - branches: - only: master - -only_release: &only_release - context: hokusai - filters: - branches: - only: release - workflows: - default: + build-deploy: jobs: - - horizon/block: - <<: *only_release - context: horizon - project_id: 11 - - # Pre-staging - - yarn/jest: + - artsy-remote-docker/build: <<: *not_staging_or_release - args: --runInBand + context: hokusai + name: build + pre-steps: + - run: + command: echo 'export BUILD_TARGET="builder"; export DOCKER_BUILDKIT=1; export BUILDKIT_PROGRESS=plain; export COMPOSE_DOCKER_CLI_BUILD=1;' >> $BASH_ENV - - yarn/run: + - mocha: <<: *not_staging_or_release - name: test:mocha - script: "test:mocha" - - # TODO: Disabled due to memory issues. Can we use our workflows above and - # upload coverage that way (similar to reaction). We save a lot of time - # by running outside of an unnecessary docker context. - - # - hokusai/test: - # name: test - # <<: *not_staging_or_release - # post-steps: - # - run: mkdir -p ./coverage ./.nyc_output ./reports - # - run: - # name: Copy jest coverage artifacts - # command: docker cp hokusai_force_1:/app/coverage ./ - # when: always - # - codecov/upload: - # file: ./coverage/lcov.info - # - run: - # name: Copy mocha coverage artifacts - # command: docker cp hokusai_force_1:/app/.nyc_output ./ - # when: always - # - codecov/upload: - # file: ./.nyc_output/lcov.info - # - run: - # name: Copy coverage reports - # command: docker cp hokusai_force_1:/app/reports ./ - # when: always - # - store_test_results: - # path: ./reports + context: hokusai + requires: + - build - - yarn/update-cache: - <<: *not_staging_or_release - - yarn/type-check: - <<: *not_staging_or_release - - acceptance_cypress: - <<: *not_master_or_staging_or_release - - build: + - jest: <<: *not_staging_or_release - # - danger: - # <<: *not_staging_or_release - - # Staging - - hokusai/push: - name: push-staging-image - <<: *only_master + context: hokusai requires: - - yarn/jest - - test:mocha - build - - hokusai/deploy-staging: - <<: *only_master - name: deploy-staging - project-name: force + - type-check: + <<: *not_staging_or_release + context: hokusai requires: - - push-staging-image + - build - # Release - - validate_production_schema: - <<: *only_release - - hokusai/deploy-production: - <<: *only_release - name: deploy-production + - acceptance: + <<: *not_staging_or_release + context: hokusai requires: - - horizon/block - - validate_production_schema + - build - - run_deepcrawl_automator: - context: deepcrawl-automator + - acceptance-cypress: + <<: *not_staging_or_release + context: hokusai requires: - - deploy-production + - build - - create_or_update_review_app: - context: hokusai - filters: - branches: - only: /^review-app-.*/ + - hokusai/push: + name: push-staging-image + <<: *not_staging_or_release + requires: + - mocha + - jest + - type-check + - acceptance + - acceptance-cypress + pre-steps: + - run: + command: echo 'export BUILD_TARGET="production"' >> $BASH_ENV diff --git a/.dockerignore b/.dockerignore index 51b9d788584..287f7203773 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,23 +1,36 @@ -.git -.gitignore -.dockerignore -Dockerfile -hokusai +# Prefer excluding all assets by default. It prevents large artifacts from +# accidentally becomming part of the Docker context. +* -README.md -LICENSE -VERSION -docs +# CI +!scripts/ -.DS_Store -.AppleDouble -.LSOverride +# Source +!data/ +!patches/ +!src/ +!webpack/ -.env -.env.* +# Testing +!__mocks__/ +!cypress/ !.env.oss -log -tmp -node_modules -.vscode -redis.conf +!.env.test + +# Build Configuration +!.eslintrc.js +!.nvmrc +!.prettierignore +!apollo.config.js +!babel.config.js +!coffeelint.json +!cypress.json +!dangerfile.ts +!jest.config.js +!package.json +!relay.config.js +!renovate.json +!test.config.js +!test.mocha.js +!tsconfig.json +!yarn.lock diff --git a/Dockerfile b/Dockerfile index c474ad6a91d..355ae2fd063 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,39 +1,149 @@ -FROM node:12.14-alpine +# --------------------------------------------------------- +# Base build dependencies +# --------------------------------------------------------- +FROM node:12.14-alpine as builder-base + +WORKDIR /app # Install system dependencies -# Add deploy user RUN apk --no-cache --quiet add \ bash \ build-base \ curl \ - dumb-init \ git \ - python && \ - adduser -D -g '' deploy + python -WORKDIR /app +# --------------------------------------------------------- +# Yarn base +# --------------------------------------------------------- +FROM builder-base as yarn-base -# Set the correct owner on the /app -RUN chown deploy:deploy $(pwd) +# Copy files required for installation of application dependencies +COPY package.json yarn.lock ./ +COPY patches ./patches -# Switch to less-privileged user, do this early to ensure files are created -# with proper ownership. -USER deploy +# --------------------------------------------------------- +# Yarn development dependencies +# --------------------------------------------------------- +FROM yarn-base as yarn-development-deps -# Copy files required for installation of application dependencies -COPY --chown=deploy:deploy package.json yarn.lock ./ -COPY --chown=deploy:deploy patches ./patches +RUN yarn install --frozen-lockfile --quiet \ + && yarn cache clean --force + +# --------------------------------------------------------- +# Yarn production dependencies +# --------------------------------------------------------- +FROM yarn-base as yarn-production-deps -# Install application dependencies -RUN yarn install --frozen-lockfile --quiet && \ - yarn cache clean --force +RUN yarn install --production --frozen-lockfile --quiet \ + && yarn cache clean --force + +# --------------------------------------------------------- +# Builder with source code +# --------------------------------------------------------- +FROM yarn-development-deps as builder-src # Copy application code -COPY --chown=deploy:deploy . ./ +COPY __mocks__ ./__mocks__ +COPY cypress ./cypress +COPY data ./data +COPY patches ./patches +COPY src ./src +COPY webpack ./webpack +COPY .env.oss \ + .env.test \ + .eslintrc.js \ + .nvmrc \ + .prettierignore \ + apollo.config.js \ + babel.config.js \ + coffeelint.json \ + cypress.json \ + dangerfile.ts \ + jest.config.js \ + package.json \ + relay.config.js \ + renovate.json \ + test.config.js \ + test.mocha.js \ + tsconfig.json \ + yarn.lock \ + ./ + +# --------------------------------------------------------- +# Compile assets +# --------------------------------------------------------- +FROM builder-src as builder-assets # Build application -RUN yarn assets && \ - yarn build:server +RUN yarn assets + +# --------------------------------------------------------- +# Compile server +# --------------------------------------------------------- +FROM builder-src as builder-server + +# Build application +RUN yarn build:server + +# --------------------------------------------------------- +# All development assets +# --------------------------------------------------------- +FROM builder-src as builder + +# Scripts +COPY ./scripts ./scripts + +# Client assets +COPY --from=builder-assets /app/manifest.json . +COPY --from=builder-assets /app/public ./public +COPY --from=builder-assets /app/src ./src + +# Server assets +COPY --from=builder-server /app/server.dist.js . +COPY --from=builder-server /app/server.dist.js.map . + +# --------------------------------------------------------- +# Release image +# --------------------------------------------------------- +# +# Release stage. This stage creates the final docker iamge that will be +# released. It contains only production dependencies and artifacts. +# +# TODO: Make the COPY steps more explicit, the iamge still copies in the all raw +# sources and configuration. +# +FROM node:12.14-alpine as release + +RUN apk --no-cache --quiet add \ + bash \ + dumb-init \ + && adduser -D -g '' deploy + +WORKDIR /app +RUN chown deploy:deploy $(pwd) + +USER deploy + +# Base code +COPY --chown=deploy:deploy --from=builder /app/data ./data +COPY --chown=deploy:deploy --from=builder /app/package.json . +COPY --chown=deploy:deploy --from=builder /app/scripts ./scripts +COPY --chown=deploy:deploy --from=builder /app/webpack ./webpack +COPY --chown=deploy:deploy --from=builder /app/yarn.lock . + +# Client assets +COPY --chown=deploy:deploy --from=builder /app/manifest.json . +COPY --chown=deploy:deploy --from=builder /app/public ./public +COPY --chown=deploy:deploy --from=builder /app/src ./src + +# Server assets +COPY --chown=deploy:deploy --from=builder /app/server.dist.js . +COPY --chown=deploy:deploy --from=builder /app/server.dist.js.map . + + +# Production node modules. +COPY --chown=deploy:deploy --from=yarn-production-deps /app/node_modules ./node_modules ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["yarn", "start"] diff --git a/buildkit.Dockerfile b/buildkit.Dockerfile new file mode 100644 index 00000000000..feec5fe5895 --- /dev/null +++ b/buildkit.Dockerfile @@ -0,0 +1,146 @@ +# --------------------------------------------------------- +# Base build dependencies +# --------------------------------------------------------- +FROM node:12.14-alpine as builder-base + +WORKDIR /app + +# Install system dependencies +RUN apk --no-cache --quiet add \ + bash \ + build-base \ + curl \ + git \ + python + +# --------------------------------------------------------- +# Yarn base +# --------------------------------------------------------- +FROM builder-base as yarn-base + +# Copy files required for installation of application dependencies +COPY package.json yarn.lock ./ +COPY patches ./patches + +# --------------------------------------------------------- +# Yarn development dependencies +# --------------------------------------------------------- +FROM yarn-base as yarn-development-deps + +RUN yarn install --frozen-lockfile --quiet \ + && yarn cache clean --force + +# --------------------------------------------------------- +# Yarn production dependencies +# --------------------------------------------------------- +FROM yarn-base as yarn-production-deps + +RUN yarn install --production --frozen-lockfile --quiet \ + && yarn cache clean --force + +# --------------------------------------------------------- +# Builder with source code +# --------------------------------------------------------- +FROM yarn-development-deps as builder-src + +# Copy application code +COPY __mocks__ ./__mocks__ +COPY cypress ./cypress +COPY data ./data +COPY patches ./patches +COPY src ./src +COPY webpack ./webpack +COPY .env.oss \ + .env.test \ + .eslintrc.js \ + .nvmrc \ + .prettierignore \ + apollo.config.js \ + babel.config.js \ + coffeelint.json \ + cypress.json \ + dangerfile.ts \ + jest.config.js \ + package.json \ + relay.config.js \ + renovate.json \ + test.config.js \ + test.mocha.js \ + tsconfig.json \ + yarn.lock \ + ./ + +# --------------------------------------------------------- +# Compile assets +# --------------------------------------------------------- +FROM builder-src as builder-assets + +# Build application +RUN yarn assets + +# --------------------------------------------------------- +# Compile server +# --------------------------------------------------------- +FROM builder-src as builder-server + +# Build application +RUN yarn build:server + +# --------------------------------------------------------- +# All development assets +# --------------------------------------------------------- +FROM builder-src as builder + +# Client assets +COPY --from=builder-assets /app/manifest.json . +COPY --from=builder-assets /app/public ./public +COPY --from=builder-assets /app/src ./src + +# Server assets +COPY --from=builder-server /app/server.dist.js . +COPY --from=builder-server /app/server.dist.js.map . + +# --------------------------------------------------------- +# Release image +# --------------------------------------------------------- +# +# Release stage. This stage creates the final docker iamge that will be +# released. It contains only production dependencies and artifacts. +# +# TODO: Make the COPY steps more explicit, the iamge still copies in the all raw +# sources and configuration. +# +FROM node:12.14-alpine as release + +RUN apk --no-cache --quiet add \ + bash \ + dumb-init \ + && adduser -D -g '' deploy + +WORKDIR /app +RUN chown deploy:deploy $(pwd) + +USER deploy + +# Base code +COPY --chown=deploy:deploy --from=builder /app/data ./data +COPY --chown=deploy:deploy --from=builder /app/package.json . +COPY --chown=deploy:deploy --from=builder /app/scripts ./scripts +COPY --chown=deploy:deploy --from=builder /app/webpack ./webpack +COPY --chown=deploy:deploy --from=builder /app/yarn.lock . + +# Client assets +COPY --chown=deploy:deploy --from=builder /app/manifest.json . +COPY --chown=deploy:deploy --from=builder /app/public ./public +COPY --chown=deploy:deploy --from=builder /app/src ./src + +# Server assets +COPY --chown=deploy:deploy --from=builder /app/server.dist.js . +COPY --chown=deploy:deploy --from=builder /app/server.dist.js.map . + + +# Production node modules. +COPY --chown=deploy:deploy --from=yarn-production-deps /app/node_modules ./node_modules + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +CMD ["yarn", "start"] diff --git a/electron.Dockerfile b/electron.Dockerfile new file mode 100644 index 00000000000..72ddc4d4390 --- /dev/null +++ b/electron.Dockerfile @@ -0,0 +1,21 @@ +FROM hokusai_force as data + +FROM node:12.18.4-stretch as electron + +WORKDIR /app + +# Install electron deps +RUN apt-get update && apt-get install -y \ + libgtk2.0-0 \ + libgtk-3-0 \ + libgbm-dev \ + libnotify-dev \ + libgconf-2-4 \ + libnss3 \ + libxss1 \ + libasound2 \ + libxtst6 \ + xauth \ + xvfb + +COPY --from=data /app /app diff --git a/hokusai/build.yml b/hokusai/build.yml index 534b57b09d8..f15e02846ed 100644 --- a/hokusai/build.yml +++ b/hokusai/build.yml @@ -1,5 +1,8 @@ -version: "2" +--- +version: "3.8" services: force: + image: "hokusai_force:${BUILD_TAG:-latest}" build: context: ../ + target: "${BUILD_TARGET}" diff --git a/hokusai/development.yml b/hokusai/development.yml index 542a29ad2e2..e446d12c9bb 100644 --- a/hokusai/development.yml +++ b/hokusai/development.yml @@ -1,4 +1,5 @@ -version: "2" +--- +version: "3.8" services: force: extends: diff --git a/hokusai/test.yml b/hokusai/test.yml index 4355ad46cd7..b03d2a4f658 100644 --- a/hokusai/test.yml +++ b/hokusai/test.yml @@ -1,4 +1,5 @@ -version: "2" +--- +version: "3.8" services: force: command: yarn test diff --git a/package.json b/package.json index 8d72a64ab73..4f16e722879 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "cypress": "./node_modules/.bin/cypress open", "delete-review-app": "kubectl --context staging delete namespace", "jest": "JEST_JUNIT_OUTPUT=reports/junit/js-test-results.xml node --expose-gc --max_old_space_size=4096 ./node_modules/.bin/jest --no-cache --runInBand --logHeapUsage", - "lint": "eslint --rulesdir ./eslint --cache --cache-location '.cache/eslint/' --ext ts,tsx --ignore-pattern 'src/v2/__generated__'", + "lint": "eslint --cache --cache-location '.cache/eslint/' --ext ts,tsx --ignore-pattern 'src/v2/__generated__'", "mocha": "scripts/mocha.sh", "prepare": "patch-package", "prettier-project": "yarn run prettier-write 'src/**/*.{ts,tsx,js,jsx}'", @@ -36,6 +36,7 @@ "start:prod": "yarn assets && yarn build:server && NODE_ENV=production yarn start", "start": "scripts/start.sh", "storybook": "concurrently --raw --kill-others 'yarn relay --watch' 'start-storybook --quiet -s ./public -p 9001'", + "test:acceptance": "yarn acceptance src/test/acceptance/*.js", "test:smoke": "scripts/smoke_test.sh", "test": "scripts/test.sh", "test:jest": "node node_modules/.bin/jest", @@ -97,6 +98,7 @@ "cookie-session": "2.0.0-beta.3", "cookies-js": "1.2.3", "cors": "2.8.3", + "core-js": "2.6.5", "dd-trace": "0.7.3", "diacritics": "1.3.0", "dompurify": "0.8.9", @@ -152,7 +154,6 @@ "nock": "9.0.13", "node-uuid": "1.4.8", "nouislider": "9.2.0", - "nyc": "13.3.0", "openseadragon": "2.4.0", "particle": "artsy/particle", "path-to-regexp": "6.1.0", @@ -193,6 +194,7 @@ "scroll-frame": "1.0.0", "serve-favicon": "2.4.3", "sharify": "0.1.6", + "source-map-support": "0.5.10", "standard": "9.0.2", "stickyfill": "1.1.1", "styled-components": "4.3.2", @@ -282,7 +284,6 @@ "cache-loader": "1.2.2", "coffee-loader": "0.8.0", "coffeescript": "1.11.1", - "core-js": "2.6.5", "cypress": "5.1.0", "danger": "7.0.16", "electron": "3.0.16", @@ -318,6 +319,7 @@ "mocha-junit-reporter": "1.22.0", "mocha-multi-reporters": "1.1.7", "nightmare": "2.10.0", + "nyc": "13.3.0", "patch-package": "6.2.0", "postinstall-prepare": "1.0.1", "prettier": "2.0.5", @@ -335,7 +337,6 @@ "should": "11.2.1", "simple-progress-webpack-plugin": "1.1.2", "sinon": "1.17.7", - "source-map-support": "0.5.10", "speed-measure-webpack-plugin": "1.3.3", "static-extend": "0.1.2", "strip-ansi": "5.0.0", diff --git a/scripts/acceptance.sh b/scripts/acceptance.sh index 9a539eb0c59..027c0379872 100755 --- a/scripts/acceptance.sh +++ b/scripts/acceptance.sh @@ -2,16 +2,18 @@ set -ex -# Build the client assets for testing -export BUILD_CLIENT=true +if [ ! -f server.dist.js ]; then + # Build the client assets for testing + export BUILD_CLIENT=true -# CSS is only compiled during a development build? -export NODE_ENV=production + # CSS is only compiled during a development build? + export NODE_ENV=production -yarn webpack + yarn webpack +fi mocha \ --retries 5 \ --require test.config.js \ - -t 60000 \ + -t 360000 \ $@ diff --git a/scripts/smoke_test.sh b/scripts/smoke_test.sh index 1bd8219ba6b..8a61a86a8aa 100755 --- a/scripts/smoke_test.sh +++ b/scripts/smoke_test.sh @@ -1,6 +1,6 @@ #! /bin/bash -set -euxo pipefail +set -ex # provide a default environment if none exists if [ ! -f ".env" ]; then @@ -8,19 +8,22 @@ if [ ! -f ".env" ]; then cp .env.oss .env fi -# prepare a production build -yarn assets -yarn build:server +# # prepare a production build +# yarn assets +# yarn build:server # start server in the background in production mode -NODE_ENV=production yarn start & +NODE_ENV=production nohup yarn start & # wait for it to accept connections ./node_modules/.bin/wait-on http://localhost:5000 +sleep 10 + +export ELECTRON_EXTRA_LAUNCH_ARGS=disable-dev-shm-usage # run ./cypress/integration/* tests in headless mode ./node_modules/.bin/cypress install ./node_modules/.bin/cypress run -# kill server -kill $! +# Kill the server +kill -9 $! || true diff --git a/scripts/xvfb-run.sh b/scripts/xvfb-run.sh new file mode 100755 index 00000000000..efb52ee30c3 --- /dev/null +++ b/scripts/xvfb-run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +DISPLAY_MACBOOK_AIR=1440x900x24 + +xvfb-run --server-args="-screen 0 $DISPLAY_MACBOOK_AIR" $@ diff --git a/src/test/acceptance/artist.js b/src/test/acceptance/artist.js index d435826161c..9e34b86fef5 100644 --- a/src/test/acceptance/artist.js +++ b/src/test/acceptance/artist.js @@ -1,10 +1,5 @@ /* eslint-env mocha */ import { setup, teardown } from "./helpers" -import { JSDOM } from "jsdom" - -const jsdom = new JSDOM("") -global.Node = jsdom.window.Node -global.DOMParser = jsdom.window.DOMParser describe("Artist page", () => { let metaphysics, browser diff --git a/src/test/acceptance/helpers/index.js b/src/test/acceptance/helpers/index.js index 62e7be4d4b5..6bb5ca5bd32 100644 --- a/src/test/acceptance/helpers/index.js +++ b/src/test/acceptance/helpers/index.js @@ -35,15 +35,15 @@ export const setup = async () => { positron = await startApp(POSITRON_PORT) metaphysics = await startApp(METAPHYSICS_PORT) force = await startForce(FORCE_PORT) - browser = mixinBrowserHelpers( - Nightmare({ - waitTimeout: TIMEOUT, - gotoTimeout: TIMEOUT, - loadTimeout: TIMEOUT, - executionTimeout: TIMEOUT, - typeInterval: 10, - }) - ) + browser = Nightmare({ + waitTimeout: TIMEOUT, + gotoTimeout: TIMEOUT, + loadTimeout: TIMEOUT, + executionTimeout: TIMEOUT, + typeInterval: 10, + }) + + initializeBrowser(browser) // Make sure cancelling the process cleans up the servers/Electron process.on("exit", teardown) @@ -77,7 +77,7 @@ export const sleep = ms => setTimeout(resolve, ms) }) -const mixinBrowserHelpers = browser => { +function initializeBrowser(browser) { // Steps to log in through the auth modal browser.login = async () => { await browser.el(".mlh-login") @@ -104,10 +104,10 @@ const mixinBrowserHelpers = browser => { }, selector) return html } - return browser } -const warn = e => console.log(chalk.red(e)) +// eslint-disable-next-line +const warn = e => console.log("warning", chalk.yellow(e)) const startForce = port => new Promise((resolve, reject) => { @@ -142,10 +142,7 @@ const startGravity = port => app.get("/api/v1/xapp_token", (req, res) => { res.send({ xapp_token: "xapp-token", - expires_in: moment() - .add(100, "days") - .utc() - .format(), + expires_in: moment().add(100, "days").utc().format(), }) }) app.get("/api/v1/profile/pace-gallery", (req, res) => {