From 68e962e4d8b80349373848b4cabd22c9a94a37ba Mon Sep 17 00:00:00 2001 From: Conrad Chan Date: Wed, 30 Jan 2019 17:42:24 -0800 Subject: [PATCH] Chore: Add support for integration testing with Cypress (#909) --- .babelrc | 5 + .gitignore | 16 +- .travis.yml | 2 + build/webpack.config.js | 3 +- cypress.json | 13 + package.json | 10 + src/index.html | 10 +- src/lib/shell.html | 2 +- test/.eslintrc.json | 7 + test/fixtures/index.json | 1 + test/integration/sanity/Sanity.e2e.test.js | 20 + test/plugins/index.js | 19 + test/support/commands.js | 8 + test/support/constants.js | 7 + test/support/index.js | 17 + yarn.lock | 585 ++++++++++++++++++++- 16 files changed, 687 insertions(+), 38 deletions(-) create mode 100644 cypress.json create mode 100644 test/.eslintrc.json create mode 100644 test/fixtures/index.json create mode 100644 test/integration/sanity/Sanity.e2e.test.js create mode 100644 test/plugins/index.js create mode 100644 test/support/commands.js create mode 100644 test/support/constants.js create mode 100644 test/support/index.js diff --git a/.babelrc b/.babelrc index 38c229729..1dcaa5676 100644 --- a/.babelrc +++ b/.babelrc @@ -27,6 +27,11 @@ }], ["babel-plugin-transform-require-ignore", { "extensions": [".scss"] }] ] + }, + "production": { + "plugins": [ + ["react-remove-properties", {"properties": ["data-testid"]}] + ] } } } diff --git a/.gitignore b/.gitignore index 49d4629f5..90bf41e74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,15 @@ -node_modules -*.swp -*.iml +.DS_Store .idea +*.iml +*.swp build/rsync.json -.DS_Store +dist +functional-tests/output +jsconfig.json +node_modules npm-debug.log reports -dist src/i18n/json -jsconfig.json -functional-tests/output +test/screenshots +test/videos yarn-error.log diff --git a/.travis.yml b/.travis.yml index ee0d8aff6..c51d7da54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,3 +19,5 @@ jobs: addons: chrome: beta script: travis_retry yarn run functional-tests-ci + - name: "E2E Tests" + script: yarn test:e2e diff --git a/build/webpack.config.js b/build/webpack.config.js index 6b2f2a37f..8dd621369 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -45,7 +45,8 @@ function updateConfig(conf, language, index) { contentBase: './src', disableHostCheck: true, host: '0.0.0.0', - inline: true + inline: true, + port: 8000 } }); diff --git a/cypress.json b/cypress.json new file mode 100644 index 000000000..071241ed8 --- /dev/null +++ b/cypress.json @@ -0,0 +1,13 @@ +{ + "baseUrl": "http://localhost:8000/#", + "fileServerFolder": "test", + "fixturesFolder": "test/fixtures", + "integrationFolder": "test/integration", + "pluginsFile": "test/plugins/index.js", + "screenshotsFolder": "test/screenshots", + "supportFile": "test/support/index.js", + "video": false, + "videosFolder": "test/videos", + "viewportHeight": 1260, + "viewportWidth": 1600 +} diff --git a/package.json b/package.json index 87b468d05..c53dcd826 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "babel-eslint": "^8.0.3", "babel-loader": "^7.1.2", "babel-plugin-istanbul": "^4.1.4", + "babel-plugin-react-remove-properties": "^0.2.5", "babel-plugin-transform-builtin-extend": "^1.1.2", "babel-plugin-transform-class-properties": "^6.23.0", "babel-plugin-transform-decorators-legacy": "^1.3.4", @@ -35,11 +36,13 @@ "create-react-class": "^15.6.2", "css-loader": "^0.28.7", "cssnano-cli": "^1.0.5", + "cypress": "^3.1.4", "eslint": "^4.12.1", "eslint-config-airbnb": "^16.1.0", "eslint-config-prettier": "^2.9.0", "eslint-import-resolver-webpack": "^0.8.3", "eslint-plugin-babel": "^4.1.1", + "eslint-plugin-cypress": "^2.2.0", "eslint-plugin-import": "^2.8.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.5.1", @@ -73,6 +76,7 @@ "mojito-rb-gen": "^0.0.1", "node-noop": "^1.0.0", "node-sass": "4.9.3", + "npm-run-all": "^4.1.5", "optimize-css-assets-webpack-plugin": "^3.2.0", "phantomjs-prebuilt": "^2.1.16", "postcss-loader": "^2.0.9", @@ -95,6 +99,7 @@ "stylelint-config-standard": "^18.0.0", "stylelint-order": "^0.7.0", "stylelint-scss": "^2.2.0", + "wait-on": "^3.2.0", "webdriverio": "^4.12.0", "webpack": "^3.10.0", "webpack-bundle-analyzer": "^2.9.1", @@ -112,6 +117,9 @@ "ci": "yarn install && yarn run clean && yarn run build-rb && yarn run lint && yarn run test && yarn run build-ci", "clean": "rm -rf dist && rm -rf reports/coverage && rm -rf src/i18n/json", "commitmsg": "commitlint -e", + "cy:open": "yarn cy:wait; yarn cypress open", + "cy:run": "yarn cy:wait; yarn cypress run --spec test/integration/**/*.test.js", + "cy:wait": "wait-on http-get://localhost:8000", "debug": "yarn install && NODE_ENV=test ./node_modules/.bin/karma start build/karma.conf.js --no-single-run --auto-watch", "dev": "yarn install && BABEL_ENV=dev NODE_ENV=dev ./node_modules/.bin/webpack --progress --colors --config build/webpack.config.js", "functional-tests": "python -m SimpleHTTPServer 8000 & node ./node_modules/codeceptjs/bin/codecept.js run-multiple parallel --verbose ; pkill -i python -m SimpleHTTPServer 8000", @@ -125,6 +133,8 @@ "start": "yarn install && BABEL_ENV=dev NODE_ENV=dev ./node_modules/.bin/webpack --watch --progress --colors --config build/webpack.config.js", "start:dev": "yarn run build-rb && LANGUAGE=en-US BABEL_ENV=dev NODE_ENV=dev ./node_modules/.bin/webpack-dev-server --config build/webpack.config.js", "test": "yarn install && NODE_ENV=test node --max_old_space_size=4096 ./node_modules/.bin/karma start build/karma.conf.js", + "test:e2e": "npm-run-all -p -r start:dev cy:run", + "test:e2e:open": "npm-run-all -p -r start:dev cy:open", "upgrade-pdfjs": "./build/upgrade_pdfjs.sh && ./build/minify_pdfjs.sh", "upgrade-annotations": "./build/upgrade_annotations.sh", "major": "./build/release.sh -m", diff --git a/src/index.html b/src/index.html index 9bfd39cbb..c27ef19a8 100644 --- a/src/index.html +++ b/src/index.html @@ -48,18 +48,18 @@
Token:
- - + +
File ID:
- - + +
-
+