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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,14 +23,16 @@ beforeEach(() => {
When('I connect to Vega Wallet', () => {
vegaWallet.openVegaWalletConnectDialog();
vegaWallet.fillInWalletForm(
'UI_Trading_Test',
Cypress.env('TRADING_TEST_VEGA_WALLET_NAME'),
Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE')
);
vegaWallet.clickConnectVegaWallet();
});
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();
});
@ -39,5 +41,7 @@ When('select a different public key', () => {
});
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
export class CustomizedBridge extends Eip1193Bridge {
chainId = Cypress.env('ethereumChainId');
chainId = Cypress.env('ETHEREUM_CHAIN_ID');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async sendAsync(...args: any) {
@ -109,8 +109,8 @@ const getAccount = (number = 0) => `m/44'/60'/0'/0/${number}`;
const getProvider = () =>
new JsonRpcProvider(
Cypress.env('ethereumProviderUrl'),
Cypress.env('ethereumChainId')
Cypress.env('ETHEREUM_PROVIDER_URL'),
Cypress.env('ETHEREUM_CHAIN_ID')
);
export const createBridge = () => {