Skip to content

Commit

Permalink
Add cypress e2e testing
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselly authored and sjmcnamara committed Nov 23, 2023
1 parent e9a955a commit 05da462
Show file tree
Hide file tree
Showing 30 changed files with 2,932 additions and 2,124 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ coverage/

# Build
public

# Cypress
test/cypress/screenshots
test/cypress/videos
62 changes: 62 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-disable no-process-env */
const { DefinePlugin, ProvidePlugin } = require('webpack');
const webpackPreprocessor = require('@cypress/webpack-preprocessor');
const { defineConfig } = require('cypress');

const environment = process.env.NODE_ENV || 'development';
const isDevelopment = environment === 'development' || process.env.LOCAL_DEVELOPMENT === 'true';

module.exports = defineConfig({
defaultCommandTimeout: 40000,
e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
require('@cypress/grep/src/plugin')(config);
const options = webpackPreprocessor.defaultOptions;

options.webpackOptions.plugins = [
new DefinePlugin({
__DEV__: isDevelopment,
}),
new ProvidePlugin({
process: 'process/browser',
}),
new ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
];

options.webpackOptions.resolve = {
fallback: {
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
stream: require.resolve('stream-browserify'),
url: require.resolve('url'),
},
};
on('file:preprocessor', webpackPreprocessor(options));

on('task', {
log(message) {
console.log(message);

return null;
},
});

return config;
},
specPattern: 'test/cypress/integration/**/*.js',
supportFile: 'test/cypress/support/e2e.js',
},
fixturesFolder: 'test/cypress/fixtures',
responseTimeout: 20000,
screenshotsFolder: 'test/cypress/screenshots',
videoCompression: false,
videosFolder: 'test/cypress/videos',
viewportHeight: 1080,
viewportWidth: 1920,
watchForFileChanges: false,
});
26 changes: 0 additions & 26 deletions jest.json

This file was deleted.

24 changes: 15 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
"build": "NODE_CONFIG_DIR=./config bash -c 'webpack --config webpack.app.babel.js --node-env ${NODE_ENV:=development} --progress'",
"cleanup": "echo 'not implemented'",
"dev": "NODE_CONFIG_DIR=./config webpack serve --config webpack.app.babel.js",
"cy:open": "cypress open",
"cy:run": "cypress run --config excludeSpecPattern=test/cypress/integration/optional.spec.js",
"cy:run-optional": "cypress run --config specPattern=test/cypress/integration/optional.spec.js",
"e2e": "start-server-and-test start http://localhost:3000 cy:run",
"e2e:optional": "start-server-and-test start http://localhost:3000 cy:run-optional",
"lint": "eslint .",
"patch-package": "patch-package",
"pre-commit": "lint-staged --relative",
"start": "NODE_CONFIG_DIR=./config webpack serve --config webpack.app.babel.js",
"test": "jest -c jest.json"
"start": "NODE_CONFIG_DIR=./config webpack serve --config webpack.app.babel.js --mode development"
},
"lint-staged": {
"*.js": [
Expand All @@ -31,6 +35,7 @@
"config": "3.1.0",
"copy-webpack-plugin": "11.0.0",
"create-file-plugin-webpack": "1.0.1",
"cypress-real-events": "1.10.3",
"dayjs": "1.10.7",
"dayjs-business-days": "1.0.4",
"html-webpack-plugin": "5.5.0",
Expand All @@ -53,13 +58,16 @@
"@babel/preset-env": "7.19.4",
"@babel/preset-react": "7.18.6",
"@babel/register": "7.18.9",
"@cypress/browserify-preprocessor": "3.0.2",
"@cypress/grep": "4.0.0",
"@cypress/webpack-preprocessor": "6.0.0",
"@hookform/resolvers": "2.8.8",
"@mdx-js/react": "1.6.22",
"@svgr/webpack": "6.4.0",
"@testing-library/cypress": "10.0.1",
"@testing-library/react-hooks": "7.0.2",
"app-module-path": "2.2.0",
"babel-eslint": "10.1.0",
"babel-jest": "29.2.1",
"babel-loader": "9.1.0",
"babel-plugin-istanbul": "6.1.1",
"babel-plugin-styled-components": "2.0.7",
Expand All @@ -72,11 +80,14 @@
"crypto-browserify": "3.12.0",
"css-loader": "6.7.1",
"css-modules-require-hook": "4.2.3",
"cypress": "12.17.1",
"cypress-pipe": "2.0.0",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"duplicate-package-checker-webpack-plugin": "3.0.0",
"eslint": "8.30.0",
"eslint-config-uphold-react": "1.0.0",
"eslint-plugin-cypress": "2.14.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-react-hooks": "4.6.0",
Expand All @@ -90,12 +101,6 @@
"i18next": "23.2.11",
"i18next-browser-languagedetector": "7.1.0",
"identity-obj-proxy": "3.0.0",
"jest": "29.7.0",
"jest-cli": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-environment-jsdom-fourteen": "0.1.0",
"jest-resolve": "29.7.0",
"jest-watch-typeahead": "0.4.2",
"js-cookie": "2.2.1",
"lodash-es": "4.17.21",
"lottie-web": "5.6.5",
Expand All @@ -116,6 +121,7 @@
"resolve": "1.12.0",
"semver": "6.3.1",
"smoothscroll-polyfill": "0.4.4",
"start-server-and-test": "2.0.3",
"storybook": "7.2.0",
"stream-browserify": "3.0.0",
"stream-http": "3.2.0",
Expand Down
4 changes: 3 additions & 1 deletion src/lib/vault/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const getTransactionLink = (blockchain, hash) => {
}
};

export const isKeySigner = (blockchain, key, signers) => signers.includes(new Wallet(blockchain, key).address);
export const getAddress = (blockchain, key) => new Wallet(blockchain, key).address;

export const isKeySigner = (blockchain, key, signers) => signers.includes(getAddress(blockchain, key));

export const sendTransaction = async (blockchain, transaction) => {
switch (blockchain) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Withdraw/XRP/Confirm/Confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const Confirm = ({ onConfirmWithdraw, accountData }) => {
onClick: () => setIsBackupKeySheetVisible(true),
}}
control={control}
data-test="vaultKey"
data-test="backupKey"
label={t('withdraw.xrp.confirm.fields.backup.key.label')}
name="backupKey"
placeholder={t('withdraw.xrp.confirm.fields.vault.key.placeholder')}
Expand Down
15 changes: 15 additions & 0 deletions test/cypress/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
env:
browser: true
cypress/globals: true
node: true

extends:
- plugin:cypress/recommended
- uphold-react

rules:
id-match: ['error', '^_$|^[_a-zA-Z][_a-zA-Z0-9]*$|^[A-Z][_A-Z0-9]+[_A-Z0-9]$||^[$a-zA-Z][$a-zA-Z0-9]*$|^[A-Z][$A-Z0-9]+[$A-Z0-9]$']
spaced-comment: ["error", "never"]

plugins:
- cypress
11 changes: 11 additions & 0 deletions test/cypress/fixtures/routes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"access": "/access",
"accessDetails": "/access/details",
"landing": "/",
"transaction": "/transaction",
"transactionFailure": "/transaction/failure",
"transactionSuccess": "/transaction/success",
"withdrawXrp": "/withdraw/xrp",
"withdrawXrpConfirm": "/withdraw/xrp/confirm",
"withdrawXrpDestination": "/withdraw/xrp/destination"
}
Loading

0 comments on commit 05da462

Please sign in to comment.