diff --git a/.circleci/config.yml b/.circleci/config.yml index de43422d1b..a33a302a6e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,6 +54,26 @@ jobs: - run: npm install - run: npm run bundle - run: npm test + frontend-e2e-tests: + environment: + COMPOSE_FILE: .circleci/docker-compose.cypress.yml + COMPOSE_PROJECT_NAME: cypress + docker: + - image: circleci/node:8 + steps: + - setup_remote_docker + - checkout + - run: + name: Install npm dependencies + command: npm install + - run: + name: Setup Redash server + command: | + npm run cypress:server start-ci + docker-compose run cypress node ./cypress/cypress-server.js setup + - run: + name: Execute Cypress tests + command: docker-compose run cypress ./node_modules/.bin/cypress run build-tarball: docker: - image: circleci/node:8 @@ -77,64 +97,15 @@ jobs: - run: docker login -u $DOCKER_USER -p $DOCKER_PASS - run: docker build -t redash/redash:$(.circleci/docker_tag) . - run: docker push redash/redash:$(.circleci/docker_tag) - integration-tests: - working_directory: ~/redash - machine: true - environment: - REDASH_SERVER_URL : "http://127.0.0.1:5000/" - DOCKER_IMAGE: mozilla/redash-ui-tests - steps: - - checkout - - run: - name: Install Docker Compose - command: | - set -x - pip install --upgrade pip - pip install docker-compose>=1.18 - docker-compose --version - - run: - name: Pull redash images - command: | - set -x - docker-compose -f docker-compose.yml up --no-start - sleep 10 - - run: - name: Pull redash-ui-tests - command: docker pull "${DOCKER_IMAGE}":latest - - run: - name: Setup redash instance - command: | - set -x - docker-compose run --rm --user root server create_db - docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests" - docker-compose run --rm --user root server /app/manage.py users create_root root@example.com "rootuser" --password "IAMROOT" --org default - docker-compose run --rm --user root server /app/manage.py ds new "ui-tests" --type "url" --options '{"title": "uitests"}' - docker-compose run -d -p 5000:5000 --user root server - docker-compose start postgres - docker-compose run --rm --user root server npm install - docker-compose run --rm --user root server npm run bundle - docker-compose run --rm --user root server npm run build - - run: - name: Run tests - command: | - set -x - docker run --net="host" --env REDASH_SERVER_URL="${REDASH_SERVER_URL}" "${DOCKER_IMAGE}" - - store_artifacts: - path: report.html workflows: version: 2 - # integration_tests: - # jobs: - # - integration-tests: - # filters: - # branches: - # only: master build: jobs: - python-flake8-tests - legacy-python-flake8-tests - backend-unit-tests - frontend-unit-tests + - frontend-e2e-tests - build-tarball: requires: - backend-unit-tests diff --git a/.circleci/docker-compose.cypress.yml b/.circleci/docker-compose.cypress.yml new file mode 100644 index 0000000000..ae06edb482 --- /dev/null +++ b/.circleci/docker-compose.cypress.yml @@ -0,0 +1,43 @@ +version: '2' +services: + server: + build: ../ + command: dev_server + depends_on: + - postgres + - redis + ports: + - "5000:5000" + environment: + PYTHONUNBUFFERED: 0 + REDASH_LOG_LEVEL: "INFO" + REDASH_REDIS_URL: "redis://redis:6379/0" + REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres" + worker: + build: ../ + command: scheduler + depends_on: + - server + environment: + PYTHONUNBUFFERED: 0 + REDASH_LOG_LEVEL: "INFO" + REDASH_REDIS_URL: "redis://redis:6379/0" + REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres" + QUEUES: "queries,scheduled_queries,celery" + WORKERS_COUNT: 2 + cypress: + build: + context: ../ + dockerfile: Dockerfile.cypress + depends_on: + - server + - worker + environment: + CYPRESS_baseUrl: "http://server:5000" + redis: + image: redis:3.0-alpine + restart: unless-stopped + postgres: + image: postgres:9.5.6-alpine + command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF" + restart: unless-stopped diff --git a/.gitignore b/.gitignore index e405ce2850..7307021b73 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ node_modules .sass-cache npm-debug.log +cypress/screenshots +cypress/videos diff --git a/Dockerfile.cypress b/Dockerfile.cypress new file mode 100644 index 0000000000..31f619ba56 --- /dev/null +++ b/Dockerfile.cypress @@ -0,0 +1,10 @@ +FROM cypress/browsers:chrome67 + +WORKDIR /usr/src/app + +RUN npm install cypress > /dev/null + +COPY cypress /usr/src/app/cypress +COPY cypress.json /usr/src/app/cypress.json + +RUN ./node_modules/.bin/cypress verify diff --git a/client/.eslintrc.js b/client/.eslintrc.js index 759c24f53e..10fae2b4c6 100644 --- a/client/.eslintrc.js +++ b/client/.eslintrc.js @@ -1,13 +1,14 @@ module.exports = { root: true, extends: ["airbnb", "plugin:jest/recommended"], - plugins: ["jest"], + plugins: ["jest", "cypress"], settings: { "import/resolver": "webpack" }, parser: "babel-eslint", env: { "jest/globals": true, + "cypress/globals": true, "browser": true, "node": true }, diff --git a/client/app/components/app-header/app-header.html b/client/app/components/app-header/app-header.html index 184c84bac5..18ee1ea8fc 100644 --- a/client/app/components/app-header/app-header.html +++ b/client/app/components/app-header/app-header.html @@ -86,7 +86,7 @@