diff --git a/apps/token-e2e/cypress.config.js b/apps/token-e2e/cypress.config.js
index 8d67c0742..b46af7681 100644
--- a/apps/token-e2e/cypress.config.js
+++ b/apps/token-e2e/cypress.config.js
@@ -14,4 +14,17 @@ module.exports = defineConfig({
screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots',
chromeWebSecurity: false,
},
+ env: {
+ ethProviderUrl: 'http://localhost:8545/',
+ ethWalletPublicKey: '0xEe7D375bcB50C26d52E1A4a472D8822A2A22d94F',
+ ethStakingBridgeContractAddress: '0x9135f5afd6F055e731bca2348429482eE614CFfA',
+ vegaWalletName: 'capsule_wallet',
+ vegaWalletLocation: '~/.vegacapsule/testnet/wallet',
+ vegaWalletPassphrase: '123',
+ vegaWalletMnemonic: 'ozone access unlock valid olympic save include omit supply green clown session',
+ vegaWalletPublicKey: '02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65',
+ vegaWalletPublicKeyShort: '02ecea…2f65',
+ vegaTokenContractAddress: '0xF41bD86d462D36b997C0bbb4D97a0a3382f205B7',
+ vegaTokenAddress: '0x67175Da1D5e966e40D11c4B2519392B2058373de'
+ }
});
diff --git a/apps/token-e2e/src/fixtures/envVars.json b/apps/token-e2e/src/fixtures/envVars.json
deleted file mode 100644
index e837d6012..000000000
--- a/apps/token-e2e/src/fixtures/envVars.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "ethProviderUrl": "http://localhost:8545/",
- "ethWalletPublicKey": "0xEe7D375bcB50C26d52E1A4a472D8822A2A22d94F",
- "ethStakingBridgeContractAddress": "0x9135f5afd6F055e731bca2348429482eE614CFfA",
- "vegaWalletName": "capsule_wallet",
- "vegaWalletLocation": "~/.vegacapsule/testnet/wallet",
- "vegaWalletPassphrase": "123",
- "vegaWalletMnemonic": "ozone access unlock valid olympic save include omit supply green clown session",
- "vegaWalletPublicKey": "02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65",
- "vegaWalletPublicKeyShort": "02ecea…2f65",
- "vegaTokenContractAddress": "0xF41bD86d462D36b997C0bbb4D97a0a3382f205B7",
- "vegaTokenAddress": "0x67175Da1D5e966e40D11c4B2519392B2058373de"
-}
diff --git a/apps/token-e2e/src/integration/flow/staking-flow.cy.js b/apps/token-e2e/src/integration/flow/staking-flow.cy.js
index fa37deff2..cd7d99ec4 100644
--- a/apps/token-e2e/src/integration/flow/staking-flow.cy.js
+++ b/apps/token-e2e/src/integration/flow/staking-flow.cy.js
@@ -1,9 +1,13 @@
///
import navigation from '../../locators/navigation.locators';
import staking from '../../locators/staking.locators';
+import wallet from '../../locators/wallet.locators';
import '../../support/staking.functions';
-import '../../support/wallet.functions';
-import envVars from '../../fixtures/envVars.json';
+import '../../support/vega-wallet.functions';
+import '../../support/eth-wallet.functions';
+import '../../support/wallet-teardown.functions';
+
+const vegaWalletPublicKeyShort = Cypress.env("vegaWalletPublicKeyShort");
context('Staking Tab - with eth and vega wallets connected', function () {
before('visit staking tab and connect vega wallet', function () {
@@ -11,12 +15,14 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.visit('/');
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
cy.vega_wallet_connect();
- cy.vega_wallet_set_specified_approval_amount_and_reload('1000');
+ cy.vega_wallet_set_specified_approval_amount('1000');
+ cy.reload();
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
cy.ethereum_wallet_connect();
cy.get(navigation.staking).first().click();
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
cy.get(staking.validatorNames).first().invoke('text').as('validatorName');
+ cy.get(staking.validatorNames).last().invoke('text').as('otherValidatorName');
});
describe('Eth wallet - contains VEGA tokens', function () {
@@ -25,84 +31,14 @@ context('Staking Tab - with eth and vega wallets connected', function () {
function () {
cy.vega_wallet_teardown();
cy.get(navigation.staking).first().click();
- cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
- cy.get(staking.validatorNames).contains(this.validatorName).click();
- cy.contains('Your Stake On Node (This Epoch)').should('be.visible');
}
);
- it('Able to associate tokens - from eth wallet', function () {
- cy.ethereum_wallet_associate_tokens('2');
- cy.ethereum_wallet_check_associated_vega_key_value_is(
- envVars.vegaWalletPublicKeyShort,
- '2.000000000000000000'
- );
- cy.vega_wallet_check_associated_value_is('2.000000000000000000');
- });
-
- it('Able to associate tokens - from staking page', function () {
- cy.get(navigation.staking).first().click();
- cy.staking_page_associate_tokens('2');
- cy.ethereum_wallet_check_associated_vega_key_value_is(
- envVars.vegaWalletPublicKeyShort,
- '2.000000000000000000'
- );
- cy.vega_wallet_check_associated_value_is('2.000000000000000000');
- });
-
- it('Able to disassociate tokens - from staking page', function () {
- cy.get(navigation.staking).first().click();
- cy.staking_page_associate_tokens('2');
- cy.ethereum_wallet_check_associated_vega_key_value_is(
- envVars.vegaWalletPublicKeyShort,
- '2.000000000000000000'
- );
- cy.vega_wallet_check_associated_value_is('2.000000000000000000');
-
- cy.get(navigation.staking).first().click();
- cy.staking_page_disassociate_tokens('1');
- cy.ethereum_wallet_check_associated_vega_key_value_is(
- envVars.vegaWalletPublicKeyShort,
- '1.000000000000000000'
- );
- cy.vega_wallet_check_associated_value_is('1.000000000000000000');
- });
-
- it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () {
- cy.ethereum_wallet_associate_tokens('1001', 'Approve');
- cy.ethereum_wallet_check_associated_vega_key_value_is(
- envVars.vegaWalletPublicKeyShort,
- '1,001.000000000000000000'
- );
- cy.vega_wallet_check_associated_value_is('1,001.000000000000000000');
- });
-
- it('Able to disassociate a partial amount of tokens currently associated', function () {
- cy.ethereum_wallet_associate_tokens('2');
- cy.vega_wallet_check_associated_value_is('2.000000000000000000');
-
- cy.ethereum_wallet_disassociate_tokens('1');
- cy.ethereum_wallet_check_associated_vega_key_value_is(
- envVars.vegaWalletPublicKeyShort,
- '1.000000000000000000'
- );
- cy.vega_wallet_check_associated_value_is('1.000000000000000000');
- });
-
- it('Able to disassociate all tokens', function () {
- cy.ethereum_wallet_associate_tokens('2');
- cy.vega_wallet_check_associated_value_is('2.000000000000000000');
-
- cy.ethereum_wallet_disassociate_all_tokens();
- cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(
- envVars.vegaWalletPublicKeyShort
- );
- cy.vega_wallet_check_associated_value_is('0.000000000000000000');
- });
-
it('Able to stake against a validator', function () {
- cy.ethereum_wallet_associate_tokens('3');
+ cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
+ cy.ethereum_wallet_check_associated_value_is('3.0')
+ cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'3.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
cy.get(staking.validatorNames).contains(this.validatorName).click();
@@ -121,8 +57,27 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.staking_validator_page_check_stake_this_epoch_value('2.0');
});
+ it('Able to stake against mulitple validators', function () {
+ cy.staking_page_associate_tokens('5');
+ cy.vega_wallet_check_unstaked_value_is('5.000000000000000000');
+ cy.get('button').contains('Select a validator to nominate').click();
+ cy.get(staking.validatorNames).contains(this.validatorName).click();
+
+ cy.staking_validator_page_add_stake('2');
+ cy.vega_wallet_check_validator_staked_value_is(this.validatorName,
+ '2.000000000000000000'
+ );
+ cy.get(navigation.staking).first().click();
+ cy.get(staking.validatorNames).contains(this.otherValidatorName).click();
+ cy.staking_validator_page_add_stake('1');
+ cy.vega_wallet_check_validator_staked_value_is(this.otherValidatorName,
+ '1.000000000000000000'
+ );
+ cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
+ });
+
it('Able to remove part of a stake against a validator', function () {
- cy.ethereum_wallet_associate_tokens('4');
+ cy.staking_page_associate_tokens('4');
cy.vega_wallet_check_unstaked_value_is('4.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
@@ -160,7 +115,7 @@ context('Staking Tab - with eth and vega wallets connected', function () {
});
it('Able to remove a full stake against a validator', function () {
- cy.ethereum_wallet_associate_tokens('3');
+ cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
@@ -191,10 +146,11 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.staking_validator_page_check_stake_next_epoch_value('0.0');
cy.staking_validator_page_check_stake_this_epoch_value('0.0');
+ cy.vega_wallet_check_validator_no_longer_showing(this.validatorName);
});
it('Unable to remove a stake with a negative value for a validator', function () {
- cy.ethereum_wallet_associate_tokens('3');
+ cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
@@ -220,7 +176,7 @@ context('Staking Tab - with eth and vega wallets connected', function () {
});
it('Unable to remove a stake greater than staked amount next epoch for a validator', function () {
- cy.ethereum_wallet_associate_tokens('3');
+ cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
@@ -244,5 +200,94 @@ context('Staking Tab - with eth and vega wallets connected', function () {
.and('contain', `Remove 4 $VEGA tokens at the end of epoch`)
.and('be.visible');
});
+
+ it('Disassociating all tokens - removes all staked tokens', function () {
+ cy.staking_page_associate_tokens('3')
+ cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
+
+ cy.get('button').contains('Select a validator to nominate').click();
+ cy.get(staking.validatorNames).contains(this.validatorName).click();
+
+ cy.staking_validator_page_add_stake('2');
+ cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
+ cy.vega_wallet_check_validator_staked_value_is(this.validatorName, '2.000000000000000000');
+ cy.get(navigation.staking).first().click();
+ cy.staking_page_disassociate_all_tokens();
+ cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(vegaWalletPublicKeyShort);
+ cy.ethereum_wallet_check_associated_value_is('0.0');
+ cy.vega_wallet_check_associated_value_is('0.000000000000000000');
+ cy.vega_wallet_check_validator_no_longer_showing(this.validatorName);
+ });
+
+ it('Disassociating some tokens - prioritizes unstaked tokens', function () {
+ cy.staking_page_associate_tokens('3')
+ cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
+
+ cy.get('button').contains('Select a validator to nominate').click();
+ cy.get(staking.validatorNames).contains(this.validatorName).click();
+
+ cy.staking_validator_page_add_stake('2');
+ cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
+ cy.vega_wallet_check_validator_staked_value_is(this.validatorName, '2.000000000000000000');
+ cy.get(navigation.staking).first().click();
+ cy.staking_page_disassociate_tokens('1');
+ cy.ethereum_wallet_check_associated_value_is('2.0');
+ cy.vega_wallet_check_associated_value_is('2.000000000000000000');
+ cy.vega_wallet_check_validator_staked_value_is(this.validatorName,
+ '2.000000000000000000'
+ );
+ });
});
+
+ cy.staking_validator_page_check_stake_next_epoch_value = (expectedVal) => {
+ cy.highlight(`Checking Staking Page - Validator Stake Next Epoch Value is ${expectedVal}`);
+ cy.get(staking.stakeNextEpochValue, { timeout: 10000 })
+ .contains(expectedVal, { timeout: 10000 })
+ .should('be.visible');
+ };
+
+ cy.staking_validator_page_check_stake_this_epoch_value = (expectedVal) => {
+ cy.highlight(`Checking Staking Page - Validator Stake This Epoch Value is ${expectedVal}`);
+ cy.get(staking.stakeThisEpochValue, { timeout: 10000 })
+ .contains(expectedVal, { timeout: 10000 })
+ .should('be.visible');
+ };
+
+ cy.vega_wallet_check_validator_stake_next_epoch_value_is = (validatorName, expectedVal) => {
+ cy.highlight(`Checking vega wallet - Stake Next Epoch Value for ${validatorName} is ${expectedVal}`);
+ cy.get(wallet.vegawallet).within(() => {
+ cy.contains(`${validatorName} (Next epoch)`, { timeout: 40000 })
+ .siblings()
+ .contains(expectedVal, { timeout: 40000 })
+ .should('be.visible');
+ });
+ };
+
+ cy.vega_wallet_check_validator_stake_this_epoch_value_is = (validatorName, expectedVal) => {
+ cy.highlight(`Checking vega wallet - Stake This Epoch Value for ${validatorName} is ${expectedVal}`);
+ cy.get(wallet.vegawallet).within(() => {
+ cy.contains(`${validatorName} (This Epoch)`, { timeout: 40000 })
+ .siblings()
+ .contains(expectedVal, { timeout: 40000 })
+ .should('be.visible');
+ });
+ };
+
+ cy.vega_wallet_check_validator_no_longer_showing = (validatorName) => {
+ cy.highlight(`Checking Validator and therefore stake removed for ${validatorName}`);
+ cy.get(wallet.vegawallet).within(() => {
+ cy.contains(`${validatorName}`, { timeout: 40000 })
+ .should('not.exist', { timeout: 40000 });
+ });
+ };
+
+ cy.vega_wallet_check_validator_staked_value_is = (validatorName, expectedVal) => {
+ cy.highlight(`Checking Validator Stake Value for ${validatorName} is ${expectedVal}`);
+ cy.get(wallet.vegawallet).within(() => {
+ cy.contains(`${validatorName}`, { timeout: 40000 })
+ .siblings()
+ .contains(expectedVal, { timeout: 40000 })
+ .should('be.visible');
+ });
+ };
});
diff --git a/apps/token-e2e/src/integration/flow/token-association-flow.cy.js b/apps/token-e2e/src/integration/flow/token-association-flow.cy.js
new file mode 100644
index 000000000..d74b2cf8c
--- /dev/null
+++ b/apps/token-e2e/src/integration/flow/token-association-flow.cy.js
@@ -0,0 +1,93 @@
+///
+import navigation from '../../locators/navigation.locators';
+import staking from '../../locators/staking.locators';
+import wallet from '../../locators/wallet.locators';
+import '../../support/staking.functions';
+import '../../support/vega-wallet.functions';
+import '../../support/eth-wallet.functions';
+import '../../support/wallet-teardown.functions';
+
+const vegaWalletPublicKeyShort = Cypress.env("vegaWalletPublicKeyShort");
+
+context('Staking Tab - with eth and vega wallets connected', function () {
+ before('visit staking tab and connect vega wallet', function () {
+ cy.vega_wallet_import();
+ cy.visit('/');
+ cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
+ cy.vega_wallet_connect();
+ cy.vega_wallet_set_specified_approval_amount('1000');
+ cy.reload();
+ cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
+ cy.ethereum_wallet_connect();
+ cy.get(navigation.staking).first().click();
+ cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
+ cy.get(staking.validatorNames).first().invoke('text').as('validatorName');
+ });
+
+ describe('Eth wallet - contains VEGA tokens', function () {
+ beforeEach(
+ 'teardown wallet & drill into a specific validator',
+ function () {
+ cy.vega_wallet_teardown();
+ cy.get(navigation.staking).first().click();
+ cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
+ }
+ );
+
+ it('Able to associate tokens - from staking page', function () {
+ cy.staking_page_associate_tokens('2');
+ cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'2.000000000000000000');
+ cy.ethereum_wallet_check_associated_value_is('2.0');
+ cy.vega_wallet_check_associated_value_is('2.000000000000000000');
+ cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
+ });
+
+ it('Able to disassociate tokens - from staking page', function () {
+ cy.staking_page_associate_tokens('2');
+ cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'2.000000000000000000');
+ cy.vega_wallet_check_associated_value_is('2.000000000000000000');
+ cy.get('button').contains('Select a validator to nominate').click();
+ cy.staking_page_disassociate_tokens('1');
+ cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'1.000000000000000000');
+ cy.ethereum_wallet_check_associated_value_is('1.0');
+ cy.vega_wallet_check_associated_value_is('1.000000000000000000');
+ });
+
+ it('Able to access associate token form - from eth wallet', function () {
+ cy.get(wallet.ethWallet).within(() => cy.get(wallet.ethWalletAssociate).click());
+ cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should('be.enabled')
+ });
+
+ it('Able to access disassociate token form - from eth wallet', function () {
+ cy.get(wallet.ethWallet).within(() => cy.get(wallet.ethWalletDisassociate).click());
+ cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should('be.enabled')
+ });
+
+ it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () {
+ cy.staking_page_associate_tokens('1001', true);
+ cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'1,001.000000000000000000');
+ cy.ethereum_wallet_check_associated_value_is('1,001.00');
+ cy.vega_wallet_check_associated_value_is('1,001.000000000000000000');
+ });
+
+ it('Able to disassociate a partial amount of tokens currently associated', function () {
+ cy.staking_page_associate_tokens('2');
+ cy.vega_wallet_check_associated_value_is('2.000000000000000000');
+ cy.get('button').contains('Select a validator to nominate').click();
+ cy.staking_page_disassociate_tokens('1');
+ cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'1.000000000000000000');
+ cy.ethereum_wallet_check_associated_value_is('1.0');
+ cy.vega_wallet_check_associated_value_is('1.000000000000000000');
+ });
+
+ it('Able to disassociate all tokens', function () {
+ cy.staking_page_associate_tokens('2');
+ cy.vega_wallet_check_associated_value_is('2.000000000000000000');
+ cy.get('button').contains('Select a validator to nominate').click();
+ cy.staking_page_disassociate_all_tokens();
+ cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(vegaWalletPublicKeyShort);
+ cy.ethereum_wallet_check_associated_value_is('0.0');
+ cy.vega_wallet_check_associated_value_is('0.000000000000000000');
+ });
+ });
+});
diff --git a/apps/token-e2e/src/integration/home.cy.js b/apps/token-e2e/src/integration/home.cy.js
index 438557a1d..5d1a95533 100644
--- a/apps/token-e2e/src/integration/home.cy.js
+++ b/apps/token-e2e/src/integration/home.cy.js
@@ -1,6 +1,8 @@
import navigation from '../locators/navigation.locators';
import home from '../locators/home.locators';
-import envVars from '../fixtures/envVars.json';
+
+const vegaTokenAddress = Cypress.env("vegaTokenAddress");;
+const vegaTokenContractAddress = Cypress.env("vegaTokenContractAddress");
context('Home Page - verify elements on page', function () {
before('visit token home page', function () {
@@ -51,7 +53,7 @@ context('Home Page - verify elements on page', function () {
cy.get(home.address)
.should('be.visible')
.invoke('text')
- .should('be.equal', envVars.vegaTokenAddress);
+ .should('be.equal', vegaTokenAddress);
});
});
it('should have VESTING CONTRACT', function () {
@@ -59,7 +61,7 @@ context('Home Page - verify elements on page', function () {
cy.get(home.contract)
.should('be.visible')
.invoke('text')
- .should('be.equal', envVars.vegaTokenContractAddress);
+ .should('be.equal', vegaTokenContractAddress);
});
});
it('should have TOTAL SUPPLY', function () {
diff --git a/apps/token-e2e/src/locators/navigation.locators.js b/apps/token-e2e/src/locators/navigation.locators.js
index cdcbb25fd..24d414dc5 100644
--- a/apps/token-e2e/src/locators/navigation.locators.js
+++ b/apps/token-e2e/src/locators/navigation.locators.js
@@ -1,4 +1,7 @@
+import common from './common.locators';
+
export default {
+ ...common,
section: 'nav',
home: '[href="/"]',
vesting: '[href="/vesting"]',
diff --git a/apps/token-e2e/src/locators/staking.locators.js b/apps/token-e2e/src/locators/staking.locators.js
index cfbbb3424..3a293b542 100644
--- a/apps/token-e2e/src/locators/staking.locators.js
+++ b/apps/token-e2e/src/locators/staking.locators.js
@@ -22,5 +22,5 @@ export default {
stakeAssociateWalletRadio: '[data-testid="associate-radio-wallet"]',
disassociateButton: '[data-testid="disassociate-tokens-btn"]',
associateMoreTokensButton: '[data-testid="associate-more-tokens-btn"]',
- associateButton: '[data-testid="associate-tokens-btn"]',
+ associateButton: '[data-testid="associate-tokens-btn"]'
};
diff --git a/apps/token-e2e/src/locators/wallet.locators.js b/apps/token-e2e/src/locators/wallet.locators.js
index ab99b8ccc..2a7a2eb54 100644
--- a/apps/token-e2e/src/locators/wallet.locators.js
+++ b/apps/token-e2e/src/locators/wallet.locators.js
@@ -1,4 +1,7 @@
+import common from './common.locators';
+
export default {
+ ...common,
connectRestForm: '[data-testid="rest-connector-form"]',
name: '#wallet',
passphrase: '#passphrase',
@@ -8,4 +11,4 @@ export default {
ethWalletConnect: '[data-testid="web3-connector-Unknown"]',
ethWalletAssociate: '[href="/staking/associate"]',
ethWalletDisassociate: '[href="/staking/disassociate"]',
-};
+};
\ No newline at end of file
diff --git a/apps/token-e2e/src/support/eth-wallet.functions.js b/apps/token-e2e/src/support/eth-wallet.functions.js
new file mode 100644
index 000000000..8707b329f
--- /dev/null
+++ b/apps/token-e2e/src/support/eth-wallet.functions.js
@@ -0,0 +1,43 @@
+import wallet from '../locators/wallet.locators';
+
+cy.ethereum_wallet_connect = () => {
+ cy.highlight('Connecting Eth Wallet');
+ cy.get(wallet.ethWalletConnectToEth).within(() => {
+ cy.contains('Connect Ethereum wallet to associate $VEGA')
+ .should('be.visible')
+ .click();
+ });
+ cy.get(wallet.ethWalletConnect).click();
+ cy.get(wallet.ethWalletConnect, { timeout: 60000 }).should('not.exist');
+ cy.get(wallet.ethWallet).within(() => {
+ // this check is required since it ensures the wallet is fully (not partially) loaded
+ cy.contains('Locked', { timeout: 15000 }).should('be.visible');
+ });
+};
+
+cy.ethereum_wallet_check_associated_value_is = (expectedVal) => {
+ cy.highlight(`Checking Eth Wallet - Associated Value is ${expectedVal}`);
+ cy.get(wallet.ethWallet).within(() => {
+ cy.contains('Associated', { timeout: 20000 })
+ .parent().siblings()
+ .contains(expectedVal, { timeout: 40000 })
+ .should('be.visible');
+ });
+};
+
+cy.ethereum_wallet_check_associated_vega_key_value_is = (vegaShortPublicKey, expectedVal) => {
+ cy.highlight(`Checking Eth Wallet - Vega Key Associated Value is ${expectedVal} for key ${vegaShortPublicKey}`);
+ cy.get(wallet.ethWallet).within(() => {
+ cy.contains(vegaShortPublicKey, { timeout: 20000 })
+ .parent()
+ .contains(expectedVal, { timeout: 40000 })
+ .should('be.visible');
+ });
+};
+
+cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing = (vegaShortPublicKey) => {
+ cy.highlight('Checking Eth Wallet - Vega Key Associated is not showing');
+ cy.get(wallet.ethWallet).within(() => {
+ cy.contains(vegaShortPublicKey, { timeout: 20000 }).should('not.exist');
+ });
+};
\ No newline at end of file
diff --git a/apps/token-e2e/src/support/staking.functions.js b/apps/token-e2e/src/support/staking.functions.js
index aa9eb7a47..4d27697b4 100644
--- a/apps/token-e2e/src/support/staking.functions.js
+++ b/apps/token-e2e/src/support/staking.functions.js
@@ -1,37 +1,7 @@
import staking from '../locators/staking.locators';
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'staking_validator_page_check_stake_next_epoch_value',
- function (expectedVal) {
- cy.log(
- `👉 **_Checking Staking Page - Validator Stake Next Epoch Value is ${expectedVal}_**`
- );
- cy.get(staking.stakeNextEpochValue, { timeout: 10000 })
- .contains(expectedVal, { timeout: 10000 })
- .should('be.visible');
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'staking_validator_page_check_stake_this_epoch_value',
- function (expectedVal) {
- cy.log(
- `👉 **_Checking Staking Page - Validator Stake This Epoch Value is ${expectedVal}_**`
- );
- cy.get(staking.stakeThisEpochValue, { timeout: 10000 })
- .contains(expectedVal, { timeout: 10000 })
- .should('be.visible');
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('staking_validator_page_add_stake', function (stake) {
- cy.log(`👉 **_Adding a stake of ${stake}_**`);
+cy.staking_validator_page_add_stake = (stake) => {
+ cy.highlight(`Adding a stake of ${stake}`);
cy.get(staking.addStakeRadioButton).click({ force: true });
cy.get(staking.tokenAmountInput).type(stake);
cy.contains('Waiting for next epoch to start', { timeout: 10000 });
@@ -44,12 +14,10 @@ Cypress.Commands.add('staking_validator_page_add_stake', function (stake) {
'At the beginning of the next epoch your $VEGA will be nominated to the validator',
{ timeout: 20000 }
).should('be.visible');
-});
+};
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('staking_validator_page_removeStake', function (stake) {
- cy.log(`👉 **_Removing a stake of ${stake}_**`);
+cy.staking_validator_page_removeStake = (stake) => {
+ cy.highlight(`Removing a stake of ${stake}`);
cy.get(staking.removeStakeRadioButton).click({ force: true });
cy.get(staking.tokenAmountInput).type(stake);
cy.contains('Waiting for next epoch to start', { timeout: 10000 });
@@ -61,43 +29,33 @@ Cypress.Commands.add('staking_validator_page_removeStake', function (stake) {
cy.contains(`${stake} $VEGA has been removed from validator`).should(
'be.visible'
);
-});
+};
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'staking_page_associate_tokens',
- function (amount, approve) {
- cy.log(`👉 **_Associating ${amount} tokens via Staking Page_**`);
- cy.get(staking.associateButton).click();
- cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).click();
- cy.get(staking.tokenAmountInput, { timeout: 10000 }).type(amount);
-
- if (approve !== undefined && approve.toLowerCase() == 'approve') {
- cy.get(staking.tokenInputApprove, { timeout: 40000 })
- .should('be.enabled')
- .click();
- cy.contains('Approve $VEGA Tokens for staking on Vega').should(
- 'be.visible'
- );
- cy.contains('Approve $VEGA Tokens for staking on Vega', {
- timeout: 40000,
- }).should('not.exist');
- }
-
- cy.get(staking.tokenInputSubmit, { timeout: 40000 })
+cy.staking_page_associate_tokens = (amount, approve=false) => {
+ cy.highlight(`Associating ${amount} tokens`);
+ cy.get(staking.associateButton).click();
+ cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).click();
+ cy.get(staking.tokenAmountInput, { timeout: 10000 }).type(amount);
+ if (approve) {
+ cy.get(staking.tokenInputApprove, { timeout: 40000 })
.should('be.enabled')
.click();
- cy.contains('can now participate in governance and nominate a validator', {
- timeout: 60000,
- }).should('be.visible');
- }
-);
+ cy.contains('Approve $VEGA Tokens for staking on Vega').should(
+ 'be.visible'
+ );
+ cy.contains('Approve $VEGA Tokens for staking on Vega', {
+ timeout: 40000,
+ }).should('not.exist');
+ }
+ cy.get(staking.tokenInputSubmit, { timeout: 40000 })
+ .should('be.enabled').click();
+ cy.contains('can now participate in governance and nominate a validator', {
+ timeout: 60000,
+ }).should('be.visible');
+}
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('staking_page_disassociate_tokens', function (amount) {
- cy.log(`👉 **_Disassociating ${amount} tokens via Staking Page_**`);
+cy.staking_page_disassociate_tokens = (amount) => {
+ cy.highlight(`Disassociating ${amount} tokens via Staking Page`);
cy.get(staking.disassociateButton).click();
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).click();
cy.get(staking.tokenAmountInput, { timeout: 10000 }).type(amount);
@@ -108,6 +66,15 @@ Cypress.Commands.add('staking_page_disassociate_tokens', function (amount) {
cy.contains(`${amount} $VEGA tokens have been returned to Ethereum wallet`, {
timeout: 60000,
}).should('be.visible');
-});
+};
-// ----------------------------------------------------------------------
+cy.staking_page_disassociate_all_tokens = () => {
+ cy.highlight(`Disassociating all tokens via Staking Page`);
+ cy.get(staking.disassociateButton).click();
+ cy.get(staking.stakeAssociateWalletRadio, { timeout: 20000 }).click();
+ cy.get(staking.stakeMaximumTokens, { timeout: 60000 }).click();
+ cy.get(staking.tokenInputSubmit, { timeout: 10000 }).click();
+ cy.contains('$VEGA tokens have been returned to Ethereum wallet', {
+ timeout: 60000,
+ }).should('be.visible');
+};
\ No newline at end of file
diff --git a/apps/token-e2e/src/support/vega-wallet.functions.js b/apps/token-e2e/src/support/vega-wallet.functions.js
new file mode 100644
index 000000000..c51c89c19
--- /dev/null
+++ b/apps/token-e2e/src/support/vega-wallet.functions.js
@@ -0,0 +1,56 @@
+import wallet from '../locators/wallet.locators';
+
+const vegaWalletName = Cypress.env("vegaWalletName");
+const vegaWalletLocation = Cypress.env("vegaWalletLocation");
+const vegaWalletPassphrase = Cypress.env("vegaWalletPassphrase");
+
+cy.vega_wallet_import = () => {
+ cy.highlight(`Importing Vega Wallet ${vegaWalletName}`);
+ cy.exec(`vegawallet init -f --home ${vegaWalletLocation}`);
+ cy.exec(
+ `vegawallet import -w ${vegaWalletName} --recovery-phrase-file ./src/fixtures/wallet/recovery -p ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet`,
+ { failOnNonZeroExit: false }
+ );
+ cy.exec(
+ `vegawallet service run --network DV --automatic-consent --home ${vegaWalletLocation}`
+ );
+};
+
+cy.vega_wallet_connect = () => {
+ cy.highlight('Connecting Vega Wallet');
+ cy.get(wallet.vegawallet).within(() => {
+ cy.get('button')
+ .contains('Connect Vega wallet to use associated $VEGA')
+ .should('be.enabled')
+ .and('be.visible')
+ .click({ force: true });
+ });
+ cy.get('button').contains('rest provider').click();
+ cy.get(wallet.connectRestForm).within(() => {
+ cy.get(wallet.name).click().type(vegaWalletName);
+ cy.get(wallet.passphrase).click().type(vegaWalletPassphrase);
+ cy.get('button').contains('Connect').click();
+ });
+ cy.contains(`${vegaWalletName} key`, { timeout: 20000 }).should('be.visible');
+};
+
+cy.vega_wallet_check_unstaked_value_is = (expectedVal) => {
+ cy.highlight(`Checking vega wallet - Unstaked Value is ${expectedVal}`);
+ cy.get(wallet.vegawallet).within(() => {
+ cy.contains('Unstaked', { timeout: 40000 })
+ .siblings()
+ .contains(expectedVal, { timeout: 40000 })
+ .should('be.visible');
+ });
+};
+
+cy.vega_wallet_check_associated_value_is = (expectedVal) => {
+ cy.highlight(`Checking vega wallet - Associated Value is ${expectedVal}`);
+ cy.get(wallet.vegawallet).within(() => {
+ cy.contains('Associated', { timeout: 40000 })
+ .parent()
+ .siblings()
+ .contains(expectedVal, { timeout: 40000 })
+ .should('be.visible');
+ });
+};
\ No newline at end of file
diff --git a/apps/token-e2e/src/support/wallet-teardown.functions.js b/apps/token-e2e/src/support/wallet-teardown.functions.js
new file mode 100644
index 000000000..81b35a2be
--- /dev/null
+++ b/apps/token-e2e/src/support/wallet-teardown.functions.js
@@ -0,0 +1,79 @@
+import { StakingBridge, Token, TokenVesting } from '@vegaprotocol/smart-contracts';
+import { ethers, Wallet } from 'ethers';
+
+const vegaWalletMnemonic = Cypress.env("vegaWalletMnemonic");
+const vegaWalletPubKey = Cypress.env("vegaWalletPublicKey");
+const vegaTokenContractAddress = Cypress.env("vegaTokenContractAddress");
+const vegaTokenAddress = Cypress.env("vegaTokenAddress");
+const ethWalletPubKey = Cypress.env("ethWalletPublicKey");
+const ethStakingBridgeContractAddress = Cypress.env("ethStakingBridgeContractAddress");
+const ethProviderUrl = Cypress.env("ethProviderUrl");
+const getAccount = (number = 0) => `m/44'/60'/0'/0/${number}`;
+const transactionTimeout = '50000';
+
+before('Vega wallet teardown prep', function () {
+ cy.wrap(new ethers.providers.JsonRpcProvider({ url: ethProviderUrl }), {
+ log: false}).as('provider');
+
+ cy.wrap(Wallet.fromMnemonic(vegaWalletMnemonic, getAccount(0)).privateKey, {
+ log: false}).then((privateKey) => {
+ cy.wrap(new Wallet(privateKey, this.provider), { log: false }).as('signer');
+ })
+
+ cy.get("@signer", {log: false}).then((signer => {
+ cy.wrap(new StakingBridge(ethStakingBridgeContractAddress, signer), {
+ log: false}).as('stakingBridgeContract')
+ cy.wrap(new TokenVesting(vegaTokenContractAddress, signer), {
+ log: false}).as('vestingContract')
+ }))
+
+})
+
+Cypress.Commands.add('vega_wallet_teardown', function () {
+ cy.vega_wallet_teardown_staking(this.stakingBridgeContract);
+ cy.vega_wallet_teardown_vesting(this.vestingContract);
+ cy.vega_wallet_check_associated_value_is('0.000000000000000000');
+});
+
+Cypress.Commands.add('vega_wallet_set_specified_approval_amount', function (resetAmount) {
+ cy.highlight(`Setting token approval amount to ${resetAmount}`);
+ cy.wrap(new Token(vegaTokenAddress, this.signer), { log: false })
+ .then((token) => {
+ cy.wrap(token.approve(ethStakingBridgeContractAddress,
+ resetAmount.concat('000000000000000000')
+ ),
+ { timeout: transactionTimeout, log: false })
+ .then((tx) => { cy.wait_for_transaction(tx) });
+ });
+ // ensure to cy.reload() after running this in order to take affect
+});
+
+cy.vega_wallet_teardown_staking = (stakingBridgeContract) => {
+ cy.highlight('Tearing down staking tokens from vega wallet if present');
+ cy.wrap(stakingBridgeContract.stakeBalance(ethWalletPubKey, vegaWalletPubKey), {
+ timeout: transactionTimeout, log: false})
+ .then((stake_amount) => {
+ if (String(stake_amount) != '0') {
+ cy.wrap(stakingBridgeContract.removeStake(stake_amount, vegaWalletPubKey),
+ { timeout: transactionTimeout, log: false })
+ .then((tx) => { cy.wait_for_transaction(tx) });
+ }
+ })
+};
+
+cy.vega_wallet_teardown_vesting = (vestingContract) => {
+ cy.highlight('Tearing down vesting tokens from vega wallet if present');
+ cy.wrap(vestingContract.stakeBalance(ethWalletPubKey, vegaWalletPubKey), {
+ timeout: transactionTimeout, log: false})
+ .then((vesting_amount) => {
+ if (String(vesting_amount) != '0') {
+ cy.wrap(vestingContract.removeStake(vesting_amount, vegaWalletPubKey),
+ { timeout: transactionTimeout, log: false })
+ .then((tx) => { cy.wait_for_transaction(tx) });
+ }
+ });
+};
+
+cy.wait_for_transaction = (tx) => {
+ cy.wrap(tx.wait(1).catch(cy.log), {timeout: transactionTimeout})
+};
\ No newline at end of file
diff --git a/apps/token-e2e/src/support/wallet.functions.js b/apps/token-e2e/src/support/wallet.functions.js
deleted file mode 100644
index 6d29a9784..000000000
--- a/apps/token-e2e/src/support/wallet.functions.js
+++ /dev/null
@@ -1,369 +0,0 @@
-import wallet from '../locators/wallet.locators';
-import staking from '../locators/staking.locators';
-import {
- StakingBridge,
- Token,
- TokenVesting,
-} from '@vegaprotocol/smart-contracts';
-import { ethers, Wallet } from 'ethers';
-import envVars from '../fixtures/envVars.json';
-
-// ----------------------------------------------------------------------
-
-const vegaWalletName = envVars.vegaWalletName;
-const vegaWalletLocation = envVars.vegaWalletLocation;
-const vegaWalletPassphrase = envVars.vegaWalletPassphrase;
-const vegaWalletMnemonic = envVars.vegaWalletMnemonic;
-const vegaWalletPubKey = envVars.vegaWalletPublicKey;
-const vegaTokenContractAddress = envVars.vegaTokenContractAddress;
-const vegaTokenAddress = envVars.vegaTokenAddress;
-const ethWalletPubKey = envVars.ethWalletPublicKey;
-const ethStakingBridgeContractAddress = envVars.ethStakingBridgeContractAddress;
-const ethProviderUrl = envVars.ethProviderUrl;
-const getAccount = (number = 0) => `m/44'/60'/0'/0/${number}`;
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('vega_wallet_teardown', function () {
- cy.wrap(Wallet.fromMnemonic(vegaWalletMnemonic, getAccount(0)).privateKey, {
- log: false,
- }).then((privateKey) => {
- cy.vega_wallet_teardown_staking(privateKey);
- cy.vega_wallet_teardown_vesting(privateKey);
- cy.vega_wallet_check_associated_value_is('0.000000000000000000');
- });
-});
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('vega_wallet_teardown_staking', function (privateKey) {
- cy.log('👉 **_Tearing down staking tokens from vega wallet if present_**');
- cy.wrap(new ethers.providers.JsonRpcProvider({ url: ethProviderUrl }), {
- log: false,
- }).as('provider');
- cy.get('@provider', { log: false }).then((provider) => {
- cy.wrap(new Wallet(privateKey, provider), { log: false }).as('signer');
- cy.get('@signer', { log: false }).then((signer) => {
- cy.wrap(new StakingBridge(ethStakingBridgeContractAddress, signer), {
- log: false,
- }).as('stakingBridge');
- cy.get('@stakingBridge', { log: false }).then((stakingBridge) => {
- cy.wrap(stakingBridge.stakeBalance(ethWalletPubKey, vegaWalletPubKey), {
- timeout: 40000,
- log: false,
- }).then((stake_amount) => {
- if (String(stake_amount) != '0') {
- cy.wrap(stakingBridge.removeStake(stake_amount, vegaWalletPubKey), {
- timeout: 40000,
- log: false,
- }).then((tx) => {
- cy.wrap(tx.wait(1), { timeout: 40000, log: false });
- });
- }
- });
- });
- });
- });
-});
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('vega_wallet_teardown_vesting', function (privateKey) {
- cy.log('👉 **_Tearing down vesting tokens from vega wallet if present_**');
- cy.wrap(new ethers.providers.JsonRpcProvider({ url: ethProviderUrl }), {
- log: false,
- }).as('provider');
- cy.get('@provider', { log: false }).then((provider) => {
- cy.wrap(new Wallet(privateKey, provider), { log: false }).as('signer');
- cy.get('@signer', { log: false }).then((signer) => {
- cy.wrap(new TokenVesting(vegaTokenContractAddress, signer), {
- log: false,
- }).as('vesting');
- cy.get('@vesting', { log: false }).then((vesting) => {
- cy.wrap(vesting.stakeBalance(ethWalletPubKey, vegaWalletPubKey), {
- timeout: 40000,
- log: false,
- }).then((vesting_amount) => {
- if (String(vesting_amount) != '0') {
- cy.wrap(vesting.removeStake(vesting_amount, vegaWalletPubKey), {
- timeout: 40000,
- log: false,
- }).then((tx) => {
- cy.wrap(tx.wait(1), { timeout: 40000, log: false });
- });
- }
- });
- });
- });
- });
-});
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'vega_wallet_set_specified_approval_amount_and_reload',
- function (resetAmount) {
- cy.log(`👉 **_Setting token approval amount to ${resetAmount}_**`);
- cy.wrap(Wallet.fromMnemonic(vegaWalletMnemonic, getAccount(0)).privateKey, {
- log: false,
- }).then((privateKey) => {
- cy.wrap(new ethers.providers.JsonRpcProvider({ url: ethProviderUrl }), {
- log: false,
- }).as('provider');
- cy.get('@provider', { log: false }).then((provider) => {
- cy.wrap(new Wallet(privateKey, provider), { log: false }).as('signer');
- cy.get('@signer', { log: false }).then((signer) => {
- cy.wrap(new Token(vegaTokenAddress, signer), { log: false }).as(
- 'token'
- );
- cy.get('@token', { log: false }).then((token) => {
- cy.wrap(
- token.approve(
- ethStakingBridgeContractAddress,
- resetAmount.concat('000000000000000000')
- ),
- { timeout: 60000, log: false }
- ).then((tx) => {
- cy.wrap(tx.wait(1), { timeout: 40000, log: false });
- });
- });
- });
- });
- });
- cy.log('👉 **_Reloading app for token approval setting to take affect_**');
- cy.reload();
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('vega_wallet_import', function () {
- cy.log(`👉 **_Importing Vega Wallet ${vegaWalletName}_**`);
- cy.exec(`vegawallet init -f --home ${vegaWalletLocation}`);
- cy.exec(
- `vegawallet import -w ${vegaWalletName} --recovery-phrase-file ./src/fixtures/wallet/recovery -p ./src/fixtures/wallet/passphrase --home ~/.vegacapsule/testnet/wallet`,
- { failOnNonZeroExit: false }
- );
- cy.exec(
- `vegawallet service run --network DV --automatic-consent --home ${vegaWalletLocation}`
- );
-});
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('vega_wallet_connect', function () {
- cy.log('👉 **_Connecting Vega Wallet_**');
- cy.get(wallet.vegawallet).within(() => {
- cy.get('button')
- .contains('Connect Vega wallet to use associated $VEGA')
- .should('be.enabled')
- .and('be.visible')
- .click({ force: true });
- });
-
- cy.get('button').contains('rest provider').click();
-
- cy.get(wallet.connectRestForm).within(() => {
- cy.get(wallet.name).click().type(vegaWalletName);
- cy.get(wallet.passphrase).click().type(vegaWalletPassphrase);
- cy.get('button').contains('Connect').click();
- });
-
- cy.contains(`${vegaWalletName} key`, { timeout: 20000 }).should('be.visible');
-});
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'vega_wallet_check_validator_stake_next_epoch_value_is',
- function (validatorName, expectedVal) {
- cy.log(
- `**_Checking vega wallet - Stake Next Epoch Value for ${validatorName} is ${expectedVal}_**`
- );
- cy.get(wallet.vegawallet).within(() => {
- cy.contains(`${validatorName} (Next epoch)`, { timeout: 40000 })
- .siblings()
- .contains(expectedVal, { timeout: 40000 })
- .should('be.visible');
- });
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'vega_wallet_check_validator_stake_this_epoch_value_is',
- function (validatorName, expectedVal) {
- cy.log(
- `**_Checking vega wallet - Stake This Epoch Value for ${validatorName} is ${expectedVal}_**`
- );
- cy.get(wallet.vegawallet).within(() => {
- cy.contains(`${validatorName} (This Epoch)`, { timeout: 40000 })
- .siblings()
- .contains(expectedVal, { timeout: 40000 })
- .should('be.visible');
- });
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'vega_wallet_check_validator_staked_value_is',
- function (validatorName, expectedVal) {
- cy.log(
- `**_Checking Validator Stake Value for ${validatorName} is ${expectedVal}_**`
- );
- cy.get(wallet.vegawallet).within(() => {
- cy.contains(`${validatorName}`, { timeout: 40000 })
- .siblings()
- .contains(expectedVal, { timeout: 40000 })
- .should('be.visible');
- });
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'vega_wallet_check_unstaked_value_is',
- function (expectedVal) {
- cy.log(`👉 **_Checking vega wallet - Unstaked Value is ${expectedVal}_**`);
- cy.get(wallet.vegawallet).within(() => {
- cy.contains('Unstaked', { timeout: 40000 })
- .siblings()
- .contains(expectedVal, { timeout: 40000 })
- .should('be.visible');
- });
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'vega_wallet_check_associated_value_is',
- function (expectedVal) {
- cy.log(
- `👉 **_Checking vega wallet - Associated Value is ${expectedVal}_**`
- );
- cy.get(wallet.vegawallet).within(() => {
- cy.contains('Associated', { timeout: 40000 })
- .parent()
- .siblings()
- .contains(expectedVal, { timeout: 40000 })
- .should('be.visible');
- });
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('ethereum_wallet_connect', function () {
- cy.log('👉 **_Connecting Eth Wallet_**');
- cy.get(wallet.ethWalletConnectToEth).within(() => {
- cy.contains('Connect Ethereum wallet to associate $VEGA')
- .should('be.visible')
- .click();
- });
- cy.get(wallet.ethWalletConnect).click();
- cy.get(wallet.ethWalletConnect, { timeout: 60000 }).should('not.exist');
- cy.get(wallet.ethWallet).within(() => {
- // this check is required since it ensures the wallet is fully (not partially) loaded
- cy.contains('Locked', { timeout: 10000 }).should('be.visible');
- });
-});
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'ethereum_wallet_associate_tokens',
- function (amount, approve) {
- cy.log(`👉 **_Associating ${amount} tokens via Eth Wallet_**`);
- cy.get(wallet.ethWallet).within(() =>
- cy.get(wallet.ethWalletAssociate).click()
- );
- cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).click();
- cy.get(staking.tokenAmountInput, { timeout: 10000 }).type(amount);
-
- if (approve !== undefined && approve.toLowerCase() == 'approve') {
- cy.get(staking.tokenInputApprove, { timeout: 40000 })
- .should('be.enabled')
- .click();
- cy.contains('Approve $VEGA Tokens for staking on Vega').should(
- 'be.visible'
- );
- cy.contains('Approve $VEGA Tokens for staking on Vega', {
- timeout: 40000,
- }).should('not.exist');
- }
-
- cy.get(staking.tokenInputSubmit, { timeout: 40000 })
- .should('be.enabled')
- .click();
- cy.contains('can now participate in governance and nominate a validator', {
- timeout: 60000,
- }).should('be.visible');
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('ethereum_wallet_disassociate_tokens', function (amount) {
- cy.log(`👉 **_Disassociating ${amount} tokens via Eth Wallet_**`);
- cy.get(wallet.ethWallet).within(() =>
- cy.get(wallet.ethWalletDisassociate).click()
- );
- cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).click();
- cy.get(staking.tokenAmountInput, { timeout: 10000 }).type(amount);
-
- cy.get(staking.tokenInputSubmit, { timeout: 40000 })
- .should('be.enabled')
- .click();
- cy.contains(`${amount} $VEGA tokens have been returned to Ethereum wallet`, {
- timeout: 60000,
- }).should('be.visible');
-});
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add('ethereum_wallet_disassociate_all_tokens', function () {
- cy.log('👉 **_Disassociating all tokens via Eth Wallet_**');
- cy.get(wallet.ethWallet).within(() =>
- cy.get(wallet.ethWalletDisassociate).click()
- );
- cy.get(staking.stakeAssociateWalletRadio, { timeout: 20000 }).click();
- cy.get(staking.stakeMaximumTokens, { timeout: 60000 }).click();
- cy.get(staking.tokenInputSubmit, { timeout: 10000 }).click();
- cy.contains('$VEGA tokens have been returned to Ethereum wallet', {
- timeout: 60000,
- }).should('be.visible');
-});
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'ethereum_wallet_check_associated_vega_key_value_is',
- function (vegaShortPublicKey, expectedVal) {
- cy.log(
- `**_Checking Eth Wallet - Vega Key Associated Value is ${expectedVal} for key ${vegaShortPublicKey}_**`
- );
- cy.get(wallet.ethWallet).within(() => {
- cy.contains(vegaShortPublicKey, { timeout: 20000 })
- .parent()
- .contains(expectedVal, { timeout: 40000 })
- .should('be.visible');
- });
- }
-);
-
-// ----------------------------------------------------------------------
-
-Cypress.Commands.add(
- 'ethereum_wallet_check_associated_vega_key_is_no_longer_showing',
- function (vegaShortPublicKey) {
- cy.log(`👉 **_Checking Eth Wallet - Vega Key Associated is not showing_**`);
- cy.get(wallet.ethWallet).within(() => {
- cy.contains(vegaShortPublicKey, { timeout: 20000 }).should('not.exist');
- });
- }
-);
diff --git a/libs/cypress/src/index.ts b/libs/cypress/src/index.ts
index 99d034722..b3a239957 100644
--- a/libs/cypress/src/index.ts
+++ b/libs/cypress/src/index.ts
@@ -3,11 +3,13 @@ import { addMockGQLCommand } from './lib/commands/mock-gql';
import { addMockVegaWalletCommands } from './lib/commands/mock-vega-wallet';
import { addMockWeb3ProviderCommand } from './lib/commands/mock-web3-provider';
import { addSlackCommand } from './lib/commands/slack';
+import { addHighlightLog } from './lib/commands/highlight-log';
addGetTestIdcommand();
addSlackCommand();
addMockGQLCommand();
addMockVegaWalletCommands();
addMockWeb3ProviderCommand();
+addHighlightLog();
-export * from './lib/graphql-test-utils';
+export * from './lib/graphql-test-utils';
\ No newline at end of file
diff --git a/libs/cypress/src/lib/commands/highlight-log.ts b/libs/cypress/src/lib/commands/highlight-log.ts
new file mode 100644
index 000000000..ae7f0acb1
--- /dev/null
+++ b/libs/cypress/src/lib/commands/highlight-log.ts
@@ -0,0 +1,16 @@
+declare global {
+ // eslint-disable-next-line @typescript-eslint/no-namespace
+ namespace Cypress {
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ interface Chainable {
+ highlight(message: string): void;
+ }
+ }
+ }
+
+ export function addHighlightLog() {
+ // @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
+ Cypress.Commands.add('highlight', (message) => {
+ cy.log(`👉 **_${message}_**`);
+ });
+ }
\ No newline at end of file