2022-07-14 14:21:51 +00:00
const ethWalletContainer = '[data-testid="ethereum-wallet"]' ;
const ethWalletAssociatedBalances =
'[data-testid="eth-wallet-associated-balances"]' ;
const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]' ;
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]' ;
const vegaWalletUnstakedBalance =
'[data-testid="vega-wallet-balance-unstaked"]' ;
2022-09-01 11:25:11 +00:00
const txTimeout = Cypress . env ( 'txTimeout' ) ;
2022-07-08 10:48:51 +00:00
const vegaWalletPublicKeyShort = Cypress . env ( 'vegaWalletPublicKeyShort' ) ;
2022-08-23 08:34:13 +00:00
const ethWalletAssociateButton = '[href="/staking/associate"]' ;
const associateWalletRadioButton = '[data-testid="associate-radio-wallet"]' ;
const tokenAmountInputBox = '[data-testid="token-amount-input"]' ;
const tokenSubmitButton = '[data-testid="token-input-submit-button"]' ;
const ethWalletDissociateButton = '[href="/staking/disassociate"]' ;
const vestingContractSection = '[data-testid="vega-in-vesting-contract"]' ;
const vegaInWalletSection = '[data-testid="vega-in-wallet"]' ;
const associatedKey = '[data-test-id="associated-key"]' ;
const associatedAmount = '[data-test-id="associated-amount"]' ;
2022-08-30 09:09:47 +00:00
const disassocitiationWarning = '[data-testid="disassociation-warning"]' ;
2022-09-01 11:25:11 +00:00
const vegaWallet = '[data-testid="vega-wallet"]' ;
2022-07-08 10:48:51 +00:00
2022-07-11 13:32:32 +00:00
context (
'Token association flow - with eth and vega wallets connected' ,
function ( ) {
before ( 'visit staking tab and connect vega wallet' , function ( ) {
cy . vega _wallet _import ( ) ;
cy . visit ( '/' ) ;
2022-07-14 14:21:51 +00:00
cy . verify _page _header ( 'The $VEGA token' ) ;
2022-07-11 13:32:32 +00:00
cy . vega _wallet _connect ( ) ;
cy . vega _wallet _set _specified _approval _amount ( '1000' ) ;
cy . reload ( ) ;
2022-07-14 14:21:51 +00:00
cy . verify _page _header ( 'The $VEGA token' ) ;
2022-07-11 13:32:32 +00:00
cy . ethereum _wallet _connect ( ) ;
2022-07-13 15:23:51 +00:00
cy . navigate _to ( 'staking' ) ;
2022-07-14 14:21:51 +00:00
cy . wait _for _spinner ( ) ;
2022-09-01 11:25:11 +00:00
cy . wait _for _begining _of _epoch ( ) ;
2022-07-08 10:48:51 +00:00
} ) ;
2022-07-11 13:32:32 +00:00
describe ( 'Eth wallet - contains VEGA tokens' , function ( ) {
beforeEach (
'teardown wallet & drill into a specific validator' ,
function ( ) {
cy . vega _wallet _teardown ( ) ;
2022-07-13 15:23:51 +00:00
cy . navigate _to ( 'staking' ) ;
2022-07-14 14:21:51 +00:00
cy . wait _for _spinner ( ) ;
2022-07-11 13:32:32 +00:00
}
2022-07-08 10:48:51 +00:00
) ;
2022-09-01 11:25:11 +00:00
it ( 'Able to associate tokens - from wallet' , function ( ) {
2022-08-23 08:34:13 +00:00
//1000-ASSO-0008
//1000-ASSO-0009
//1000-ASSO-0030
//1000-ASSO-0012
2022-08-23 17:27:43 +00:00
//1000-ASSO-0013
2022-08-23 08:34:13 +00:00
//1000-ASSO-0014
//1000-ASSO-0015
//1000-ASSO-0030
2022-07-11 13:32:32 +00:00
cy . staking _page _associate _tokens ( '2' ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletAssociatedBalances , txTimeout )
. contains ( vegaWalletPublicKeyShort )
2022-08-18 10:10:30 +00:00
. parent ( txTimeout )
. should ( 'contain' , 2.0 ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletTotalAssociatedBalance , txTimeout )
. contains ( '2.0' , txTimeout )
. should ( 'be.visible' ) ;
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 2.0 ) ;
} ) ;
2022-07-14 14:21:51 +00:00
2022-08-18 10:10:30 +00:00
cy . get ( vegaWalletUnstakedBalance , txTimeout ) . should ( 'contain' , 2.0 ) ;
2022-07-11 13:32:32 +00:00
} ) ;
2022-07-08 10:48:51 +00:00
2022-09-01 11:25:11 +00:00
it ( 'Able to disassociate all associated tokens - manually' , function ( ) {
2022-08-23 08:34:13 +00:00
// 1000-ASSO-0025
// 1000-ASSO-0027
// 1000-ASSO-0028
// 1000-ASSO-0029
2022-07-11 13:32:32 +00:00
cy . staking _page _associate _tokens ( '2' ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletAssociatedBalances , txTimeout )
. contains ( vegaWalletPublicKeyShort )
2022-08-18 10:10:30 +00:00
. parent ( txTimeout )
. should ( 'contain' , 2.0 ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletTotalAssociatedBalance , txTimeout )
. contains ( '2.0' , txTimeout )
. should ( 'be.visible' ) ;
2022-07-11 13:32:32 +00:00
cy . get ( 'button' ) . contains ( 'Select a validator to nominate' ) . click ( ) ;
2022-07-14 14:21:51 +00:00
2022-09-01 11:25:11 +00:00
cy . staking _page _disassociate _tokens ( '2' ) ;
2022-07-14 14:21:51 +00:00
2022-09-01 11:25:11 +00:00
cy . get ( ethWalletAssociatedBalances , txTimeout ) . should ( 'not.exist' ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletTotalAssociatedBalance , txTimeout )
2022-09-01 11:25:11 +00:00
. contains ( '0.00' , txTimeout )
2022-07-14 14:21:51 +00:00
. should ( 'be.visible' ) ;
2022-07-11 13:32:32 +00:00
} ) ;
2022-07-08 10:48:51 +00:00
2022-07-11 13:32:32 +00:00
it ( 'Able to associate more tokens than the approved amount of 1000 - requires re-approval' , function ( ) {
2022-08-23 08:34:13 +00:00
//1000-ASSO-0011
cy . staking _page _associate _tokens ( '1001' , { approve : true } ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletAssociatedBalances , txTimeout )
. contains ( vegaWalletPublicKeyShort )
. parent ( )
. should ( 'contain' , '1,001.000000000000000000' , txTimeout ) ;
cy . get ( ethWalletTotalAssociatedBalance , txTimeout )
. contains ( '1,001.00' , txTimeout )
. should ( 'be.visible' ) ;
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
'1,001.000000000000000000'
) ;
} ) ;
2022-07-11 13:32:32 +00:00
} ) ;
it ( 'Able to disassociate a partial amount of tokens currently associated' , function ( ) {
cy . staking _page _associate _tokens ( '2' ) ;
2022-07-14 14:21:51 +00:00
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 2.0 ) ;
} ) ;
2022-07-14 14:21:51 +00:00
2022-07-11 13:32:32 +00:00
cy . get ( 'button' ) . contains ( 'Select a validator to nominate' ) . click ( ) ;
2022-07-14 14:21:51 +00:00
2022-07-11 13:32:32 +00:00
cy . staking _page _disassociate _tokens ( '1' ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletAssociatedBalances , txTimeout )
. contains ( vegaWalletPublicKeyShort )
2022-08-18 10:10:30 +00:00
. parent ( txTimeout )
. should ( 'contain' , 1.0 ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletAssociatedBalances , txTimeout )
. contains ( vegaWalletPublicKeyShort )
2022-08-18 10:10:30 +00:00
. parent ( txTimeout )
. should ( 'contain' , 1.0 ) ;
2022-07-14 14:21:51 +00:00
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 1.0 ) ;
} ) ;
2022-07-11 13:32:32 +00:00
} ) ;
2022-09-01 11:25:11 +00:00
it ( 'Able to disassociate all tokens - using max' , function ( ) {
2022-08-23 08:34:13 +00:00
// 1000-ASSO-0026
2022-08-30 09:09:47 +00:00
const warningText =
'Warning: Any tokens that have been nominated to a node will sacrifice rewards they are due for the current epoch. If you do not wish to sacrifice these, you should remove stake from a node at the end of an epoch before disassociation.' ;
2022-07-11 13:32:32 +00:00
cy . staking _page _associate _tokens ( '2' ) ;
2022-07-14 14:21:51 +00:00
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 2.0 ) ;
} ) ;
2022-07-14 14:21:51 +00:00
2022-07-11 13:32:32 +00:00
cy . get ( 'button' ) . contains ( 'Select a validator to nominate' ) . click ( ) ;
2022-07-14 14:21:51 +00:00
2022-08-23 08:34:13 +00:00
cy . get ( ethWalletDissociateButton ) . click ( ) ;
2022-08-30 09:09:47 +00:00
cy . get ( disassocitiationWarning ) . should ( 'contain' , warningText ) ;
2022-08-23 08:34:13 +00:00
2022-07-11 13:32:32 +00:00
cy . staking _page _disassociate _all _tokens ( ) ;
2022-07-14 14:21:51 +00:00
cy . get ( ethWalletContainer ) . within ( ( ) => {
cy . contains ( vegaWalletPublicKeyShort , { timeout : 20000 } ) . should (
'not.exist'
) ;
} ) ;
cy . get ( ethWalletContainer ) . within ( ( ) => {
cy . contains ( vegaWalletPublicKeyShort , { timeout : 20000 } ) . should (
'not.exist'
) ;
} ) ;
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 0.0 ) ;
} ) ;
2022-07-11 13:32:32 +00:00
} ) ;
2022-08-23 08:34:13 +00:00
it ( 'Able to associate and disassociate vesting contract tokens' , function ( ) {
// 1000-ASSO-0006
// 1000-ASSO-0024
// 1000-ASSO-0023
cy . staking _page _associate _tokens ( '2' , { type : 'contract' } ) ;
cy . get ( ethWalletAssociatedBalances , txTimeout )
. contains ( vegaWalletPublicKeyShort )
. parent ( txTimeout )
. should ( 'contain' , 2.0 ) ;
cy . get ( ethWalletTotalAssociatedBalance , txTimeout )
. contains ( '2.0' , txTimeout )
. should ( 'be.visible' ) ;
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 2.0 ) ;
} ) ;
2022-08-23 08:34:13 +00:00
cy . get ( vegaWalletUnstakedBalance , txTimeout ) . should ( 'contain' , 2.0 ) ;
cy . staking _page _disassociate _tokens ( '1' , { type : 'contract' } ) ;
cy . get ( ethWalletAssociatedBalances , txTimeout )
. contains ( vegaWalletPublicKeyShort )
. parent ( txTimeout )
. should ( 'contain' , 1.0 ) ;
cy . get ( ethWalletTotalAssociatedBalance , txTimeout )
. contains ( '1.0' , txTimeout )
. should ( 'be.visible' ) ;
} ) ;
2022-08-30 09:09:47 +00:00
it ( 'Able to associate & disassociate both wallet and vesting contract tokens' , function ( ) {
2022-08-23 08:34:13 +00:00
// 1000-ASSO-0019
// 1000-ASSO-0020
// 1000-ASSO-0021
// 1000-ASSO-0022
cy . staking _page _associate _tokens ( '21' , { type : 'wallet' } ) ;
cy . get ( 'button' ) . contains ( 'Select a validator to nominate' ) . click ( ) ;
cy . staking _page _associate _tokens ( '37' , { type : 'contract' } ) ;
cy . get ( vestingContractSection ) . within ( ( ) => {
cy . get ( associatedKey ) . should (
'contain' ,
Cypress . env ( 'vegaWalletPublicKeyShort' )
) ;
2022-08-30 09:09:47 +00:00
cy . get ( associatedAmount , txTimeout ) . should ( 'contain' , 37 ) ;
2022-08-23 08:34:13 +00:00
} ) ;
cy . get ( vegaInWalletSection ) . within ( ( ) => {
cy . get ( associatedKey ) . should (
'contain' ,
Cypress . env ( 'vegaWalletPublicKeyShort' )
) ;
2022-08-30 09:09:47 +00:00
cy . get ( associatedAmount , txTimeout ) . should ( 'contain' , 21 ) ;
} ) ;
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 58 ) ;
} ) ;
2022-08-30 09:09:47 +00:00
cy . staking _page _disassociate _tokens ( '6' , { type : 'contract' } ) ;
cy . get ( vestingContractSection ) . within ( ( ) => {
cy . get ( associatedAmount , txTimeout ) . should ( 'contain' , 31 ) ;
} ) ;
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 52 ) ;
} ) ;
cy . navigate _to ( 'staking' ) ;
2022-08-30 09:09:47 +00:00
cy . staking _page _disassociate _tokens ( '9' , { type : 'wallet' } ) ;
cy . get ( vegaInWalletSection ) . within ( ( ) => {
cy . get ( associatedAmount , txTimeout ) . should ( 'contain' , 12 ) ;
2022-08-23 08:34:13 +00:00
} ) ;
2022-09-01 11:25:11 +00:00
cy . get ( vegaWallet ) . within ( ( ) => {
cy . get ( vegaWalletAssociatedBalance , txTimeout ) . should ( 'contain' , 43 ) ;
} ) ;
2022-08-23 08:34:13 +00:00
} ) ;
it ( 'Not able to associate more tokens than owned' , function ( ) {
// 1000-ASSO-0010
// No warning visible as described in AC, but the button is disabled
cy . get ( ethWalletAssociateButton ) . first ( ) . click ( ) ;
cy . get ( associateWalletRadioButton , { timeout : 30000 } ) . click ( ) ;
cy . get ( tokenAmountInputBox , { timeout : 10000 } ) . type ( 6500000 ) ;
cy . get ( tokenSubmitButton , txTimeout ) . should ( 'be.disabled' ) ;
} ) ;
2022-07-08 10:48:51 +00:00
} ) ;
2022-07-11 13:32:32 +00:00
}
) ;