chore: update readme and allow env file for local variables (#432)

* chore: update readme and allow env file for local variables
style: lint

* chore: resolved PR comments

* fix: lint and tests failures
This commit is contained in:
Joe Tsang 2022-05-23 10:05:53 +01:00 committed by GitHub
parent 38352c511f
commit aa28f2cac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 29 deletions

1
.gitignore vendored
View File

@ -40,3 +40,4 @@ Thumbs.db
.local.env .local.env
.env.local .env.local
cypress.env.json

View File

@ -73,6 +73,14 @@ Run `yarn nx run <my-app>-e2e:e2e` to execute the e2e tests with [cypress](https
Run `nx test my-app` to execute the unit tests with [Jest](https://jestjs.io), or `nx affected:test` to execute just unit tests affected by a change. You can also use `--watch` with these test to run jest in watch mode, see [Jest executor](https://nx.dev/packages/jest/executors/jest) for all CLI flags. Run `nx test my-app` to execute the unit tests with [Jest](https://jestjs.io), or `nx affected:test` to execute just unit tests affected by a change. You can also use `--watch` with these test to run jest in watch mode, see [Jest executor](https://nx.dev/packages/jest/executors/jest) for all CLI flags.
#### Trading app E2E tests
To run tests locally using your own wallets you can add the following environment variables to `cypress.json`
1. Change `TRADING_TEST_VEGA_WALLET_NAME` to your Vega wallet name
2. Add `TRADING_TEST_VEGA_WALLET_PASSPHRASE` as your wallet passphrase
3. Add `ETH_WALLET_MNEMONIC` as your Ethereum wallet mnemonic
### Formatting ### Formatting
In CI linting, formatting and also run. These checks can be seen in the [CI workflow file](.github/workflows//test.yml). In CI linting, formatting and also run. These checks can be seen in the [CI workflow file](.github/workflows//test.yml).

View File

@ -16,16 +16,15 @@
"defaultCommandTimeout": 10000, "defaultCommandTimeout": 10000,
"env": { "env": {
"ethereumProviderUrl": "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8", "TRADING_TEST_VEGA_WALLET_NAME": "UI_Trading_Test",
"ethereumChainId": 3, "ETHEREUM_PROVIDER_URL": "https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8",
"invalidDepositToAddress": "zzz85edfa7ffdb6ed996ca912e9258998e47bf3515c885cf3c63fb56b15de36f", "ETHEREUM_CHAIN_ID": 3,
"vegaPublicKey": "47836c253520d2661bf5bed6339c0de08fd02cf5d4db0efee3b4373f20c7d278", "VEGA_PUBLIC_KEY": "47836c253520d2661bf5bed6339c0de08fd02cf5d4db0efee3b4373f20c7d278",
"vegaPublicKey2": "1a18cdcaaa4f44a57b35a4e9b77e0701c17a476f2b407620f8c17371740cf2e4", "VEGA_PUBLIC_KEY2": "1a18cdcaaa4f44a57b35a4e9b77e0701c17a476f2b407620f8c17371740cf2e4",
"truncatedVegaPubKey": "47836c…c7d278", "TRUNCATED_VEGA_PUBLIC_KEY": "47836c…c7d278",
"truncatedVegaPubKey2": "1a18cd…0cf2e4", "TRUNCATED_VEGA_PUBLIC_KEY2": "1a18cd…0cf2e4",
"depositAsset": "5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c", "INVALID_DEPOSIT_TO_ADDRESS": "zzz85edfa7ffdb6ed996ca912e9258998e47bf3515c885cf3c63fb56b15de36f",
"tsConfig": "tsconfig.json", "tsConfig": "tsconfig.json",
"TAGS": "not @todo and not @ignore and not @manual", "TAGS": "not @todo and not @ignore and not @manual"
"tBtcContract": "5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c"
} }
} }

View File

@ -65,7 +65,7 @@ Feature: Deposits to vega wallet
Scenario: Invalid deposit public key validation error Scenario: Invalid deposit public key validation error
When I enter the following deposit details in deposit form When I enter the following deposit details in deposit form
| asset | tBTC TEST | | asset | tBTC TEST |
| to | invalidDepositToAddress | | to | INVALID_DEPOSIT_TO_ADDRESS |
| amount | 1 | | amount | 1 |
And I submit the form And I submit the form
Then Invalid Vega key is shown Then Invalid Vega key is shown
@ -73,7 +73,7 @@ Feature: Deposits to vega wallet
Scenario: Deposit amount too small validation Scenario: Deposit amount too small validation
When I enter the following deposit details in deposit form When I enter the following deposit details in deposit form
| asset | tBTC TEST | | asset | tBTC TEST |
| to | invalidDepositToAddress | | to | INVALID_DEPOSIT_TO_ADDRESS |
| amount | 0.00000000000000000000000000000000001 | | amount | 0.00000000000000000000000000000000001 |
And I submit the form And I submit the form
Then Amount too small message shown Then Amount too small message shown
@ -81,7 +81,7 @@ Feature: Deposits to vega wallet
Scenario: Deposit amount greater than approved amount validation Scenario: Deposit amount greater than approved amount validation
When I enter the following deposit details in deposit form When I enter the following deposit details in deposit form
| asset | tBTC TEST | | asset | tBTC TEST |
| to | invalidDepositToAddress | | to | INVALID_DEPOSIT_TO_ADDRESS |
| amount | 788888888888888 | | amount | 788888888888888 |
And I submit the form And I submit the form
And Insufficient amount message shown And Insufficient amount message shown
@ -94,7 +94,7 @@ Feature: Deposits to vega wallet
Scenario: Successful deposit Scenario: Successful deposit
When I enter the following deposit details in deposit form When I enter the following deposit details in deposit form
| asset | tBTC TEST | | asset | tBTC TEST |
| to | vegaPublicKey | | to | VEGA_PUBLIC_KEY |
| amount | 1 | | amount | 1 |
And I submit the form And I submit the form
And I can see the 'deposit pending' modal is shown And I can see the 'deposit pending' modal is shown

View File

@ -9,7 +9,7 @@ export const generateAccounts = (
const defaultAccounts: Accounts = { const defaultAccounts: Accounts = {
party: { party: {
__typename: 'Party', __typename: 'Party',
id: Cypress.env('vegaPublicKey'), id: Cypress.env('VEGA_PUBLIC_KEY'),
accounts: [ accounts: [
{ {
__typename: 'Account', __typename: 'Account',

View File

@ -70,7 +70,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
const defaultResult = { const defaultResult = {
party: { party: {
id: Cypress.env('vegaPublicKey'), id: Cypress.env('VEGA_PUBLIC_KEY'),
orders, orders,
__typename: 'Party', __typename: 'Party',
}, },

View File

@ -118,7 +118,7 @@ export const generatePositions = (
const defaultResult = { const defaultResult = {
party: { party: {
id: Cypress.env('vegaPublicKey'), id: Cypress.env('VEGA_PUBLIC_KEY'),
positions, positions,
__typename: 'Party', __typename: 'Party',
}, },

View File

@ -23,14 +23,16 @@ beforeEach(() => {
When('I connect to Vega Wallet', () => { When('I connect to Vega Wallet', () => {
vegaWallet.openVegaWalletConnectDialog(); vegaWallet.openVegaWalletConnectDialog();
vegaWallet.fillInWalletForm( vegaWallet.fillInWalletForm(
'UI_Trading_Test', Cypress.env('TRADING_TEST_VEGA_WALLET_NAME'),
Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE') Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE')
); );
vegaWallet.clickConnectVegaWallet(); vegaWallet.clickConnectVegaWallet();
}); });
When('I open wallet dialog', () => { When('I open wallet dialog', () => {
vegaWallet.validatePublicKeyDisplayed(Cypress.env('truncatedVegaPubKey')); // Default Test wallet pub key vegaWallet.validatePublicKeyDisplayed(
Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY')
); // Default Test wallet pub key
vegaWallet.clickOnWalletConnectDialog(); vegaWallet.clickOnWalletConnectDialog();
}); });
@ -39,5 +41,7 @@ When('select a different public key', () => {
}); });
Then('public key is switched', () => { Then('public key is switched', () => {
vegaWallet.validatePublicKeyDisplayed(Cypress.env('truncatedVegaPubKey2')); // Second public key for test wallet vegaWallet.validatePublicKeyDisplayed(
Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY2')
); // Second public key for test wallet
}); });

View File

@ -5,7 +5,7 @@ import { ethers } from 'ethers';
// Address of the above key // Address of the above key
export class CustomizedBridge extends Eip1193Bridge { export class CustomizedBridge extends Eip1193Bridge {
chainId = Cypress.env('ethereumChainId'); chainId = Cypress.env('ETHEREUM_CHAIN_ID');
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
async sendAsync(...args: any) { async sendAsync(...args: any) {
@ -109,8 +109,8 @@ const getAccount = (number = 0) => `m/44'/60'/0'/0/${number}`;
const getProvider = () => const getProvider = () =>
new JsonRpcProvider( new JsonRpcProvider(
Cypress.env('ethereumProviderUrl'), Cypress.env('ETHEREUM_PROVIDER_URL'),
Cypress.env('ethereumChainId') Cypress.env('ETHEREUM_CHAIN_ID')
); );
export const createBridge = () => { export const createBridge = () => {