2023-03-22 17:35:00 +00:00
import {
verifyEthWalletTotalAssociatedBalance ,
verifyEthWalletAssociatedBalance ,
waitForSpinner ,
navigateTo ,
navigation ,
2023-05-09 12:32:16 +00:00
turnTelemetryOff ,
2023-03-22 17:35:00 +00:00
} from '../../support/common.functions' ;
import {
stakingPageAssociateTokens ,
stakingPageDisassociateAllTokens ,
stakingPageDisassociateTokens ,
validateWalletCurrency ,
} from '../../support/staking.functions' ;
import { ethereumWalletConnect } from '../../support/wallet-eth.functions' ;
import {
2023-06-21 08:42:36 +00:00
switchVegaWalletPubKey ,
2023-03-22 17:35:00 +00:00
vegaWalletAssociate ,
vegaWalletDisassociate ,
vegaWalletSetSpecifiedApprovalAmount ,
vegaWalletTeardown ,
2023-06-21 08:42:36 +00:00
} from '../../support/wallet-functions' ;
2023-03-22 17:35:00 +00:00
2023-06-28 16:15:06 +00:00
const ethWalletContainer = 'ethereum-wallet' ;
const vegaWalletAssociatedBalance = 'currency-value' ;
const vegaWalletUnstakedBalance = 'vega-wallet-balance-unstaked' ;
2023-04-13 09:46:01 +00:00
const ethWalletAssociateButton = '[data-testid="associate-btn"]:visible' ;
2023-06-28 16:15:06 +00:00
const associateWalletRadioButton = 'associate-radio-wallet' ;
const tokenAmountInputBox = 'token-amount-input' ;
const tokenSubmitButton = 'token-input-submit-button' ;
2023-04-13 09:46:01 +00:00
const ethWalletDissociateButton = '[href="/token/disassociate"]:visible' ;
2023-06-28 16:15:06 +00:00
const vestingContractSection = 'vega-in-vesting-contract' ;
const vegaInWalletSection = 'vega-in-wallet' ;
const connectedVegaKey = 'connected-vega-key' ;
const associatedKey = 'associated-key' ;
const associatedAmount = 'associated-amount' ;
const associateCompleteText = 'transaction-complete-body' ;
const disassociationWarning = 'disassociation-warning' ;
2023-06-06 11:12:59 +00:00
const vegaWallet = 'aside [data-testid="vega-wallet"]' ;
2023-06-28 16:15:06 +00:00
const vegaWalletPublicKeyShort = Cypress . env ( 'vegaWalletPublicKeyShort' ) ;
const txTimeout = Cypress . env ( 'txTimeout' ) ;
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' ,
2022-09-22 17:40:11 +00:00
{ tags : '@slow' } ,
2022-07-11 13:32:32 +00:00
function ( ) {
before ( 'visit staking tab and connect vega wallet' , function ( ) {
cy . visit ( '/' ) ;
2022-12-08 08:53:42 +00:00
// 0005-ETXN-001
2023-03-22 17:35:00 +00:00
vegaWalletSetSpecifiedApprovalAmount ( '1000' ) ;
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 ( ) {
2023-05-03 10:23:17 +00:00
cy . clearLocalStorage ( ) ;
2023-05-09 12:32:16 +00:00
turnTelemetryOff ( ) ;
2022-11-17 18:22:51 +00:00
cy . reload ( ) ;
2023-03-22 17:35:00 +00:00
waitForSpinner ( ) ;
2023-02-03 19:26:17 +00:00
cy . connectVegaWallet ( ) ;
2023-03-22 17:35:00 +00:00
ethereumWalletConnect ( ) ;
vegaWalletTeardown ( ) ;
2022-07-11 13:32:32 +00:00
}
2022-07-08 10:48:51 +00:00
) ;
2023-06-16 13:42:38 +00:00
it (
'Able to associate tokens - from wallet' ,
{ tags : '@smoke' } ,
function ( ) {
//1004-ASSO-003
//1004-ASSO-005
//1004-ASSO-009
//1004-ASSO-030
//1004-ASSO-012
//1004-ASSO-013
//1004-ASSO-014
//1004-ASSO-015
//1004-ASSO-030
//0005-ETXN-006
//0005-ETXN-003
//0005-ETXN-005
stakingPageAssociateTokens ( '2' , { skipConfirmation : true } ) ;
validateWalletCurrency ( 'Associated' , '0.00' ) ;
validateWalletCurrency ( 'Pending association' , '2.00' ) ;
validateWalletCurrency ( 'Total associated after pending' , '2.00' ) ;
// 0005-ETXN-002
verifyEthWalletAssociatedBalance ( '2.0' ) ;
verifyEthWalletTotalAssociatedBalance ( '2.0' ) ;
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
2023-06-16 13:42:38 +00:00
'contain' ,
2.0
) ;
} ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletUnstakedBalance , txTimeout ) . should (
'contain' ,
2.0
) ;
2023-06-16 13:42:38 +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-10-03 08:29:28 +00:00
// 1004-ASSO-025
// 1004-ASSO-027
// 1004-ASSO-028
// 1004-ASSO-029
2022-12-08 08:53:42 +00:00
// 1004-ASSO-031
2023-05-19 13:29:20 +00:00
vegaWalletTeardown ( ) ;
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '2' ) ;
verifyEthWalletAssociatedBalance ( '2.0' ) ;
2023-05-19 13:29:20 +00:00
verifyEthWalletTotalAssociatedBalance ( '6,002.00' ) ;
2022-07-11 13:32:32 +00:00
cy . get ( 'button' ) . contains ( 'Select a validator to nominate' ) . click ( ) ;
2023-06-06 11:12:59 +00:00
cy . getByTestId ( 'epoch-countdown' ) . should ( 'be.visible' ) ;
2023-03-22 17:35:00 +00:00
stakingPageDisassociateTokens ( '2' ) ;
validateWalletCurrency ( 'Associated' , '2.00' ) ;
validateWalletCurrency ( 'Pending association' , '2.00' ) ;
validateWalletCurrency ( 'Total associated after pending' , '0.00' ) ;
2023-05-19 13:29:20 +00:00
cy . get (
'[data-testid="eth-wallet-associated-balances"]:visible' ,
txTimeout
) . should ( 'have.length' , 2 ) ;
verifyEthWalletTotalAssociatedBalance ( '6,000.00' ) ;
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-10-03 08:29:28 +00:00
//1004-ASSO-011
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '1001' , { approve : true } ) ;
verifyEthWalletAssociatedBalance ( '1,001.00' ) ;
2023-05-19 13:29:20 +00:00
verifyEthWalletTotalAssociatedBalance ( '7,001.00' ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
2023-06-06 11:12:59 +00:00
'contain' ,
'1,001.00'
) ;
} ) ;
2022-07-11 13:32:32 +00:00
} ) ;
it ( 'Able to disassociate a partial amount of tokens currently associated' , function ( ) {
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '2' ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
2.0
) ;
2023-06-06 11:12:59 +00:00
} ) ;
2022-07-11 13:32:32 +00:00
cy . get ( 'button' ) . contains ( 'Select a validator to nominate' ) . click ( ) ;
2023-06-06 11:12:59 +00:00
cy . getByTestId ( 'epoch-countdown' ) . should ( 'be.visible' ) ;
2023-03-22 17:35:00 +00:00
stakingPageDisassociateTokens ( '1' ) ;
verifyEthWalletAssociatedBalance ( '1.0' ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
1.0
) ;
2023-06-06 11:12:59 +00:00
} ) ;
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-10-03 08:29:28 +00:00
// 1004-ASSO-026
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.' ;
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '2' ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
2.0
) ;
2023-06-06 11:12:59 +00:00
} ) ;
2022-07-11 13:32:32 +00:00
cy . get ( 'button' ) . contains ( 'Select a validator to nominate' ) . click ( ) ;
2023-06-06 11:12:59 +00:00
cy . getByTestId ( 'epoch-countdown' ) . should ( 'be.visible' ) ;
2022-08-23 08:34:13 +00:00
cy . get ( ethWalletDissociateButton ) . click ( ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( disassociationWarning ) . should ( 'contain' , warningText ) ;
2023-03-22 17:35:00 +00:00
stakingPageDisassociateAllTokens ( ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( ethWalletContainer )
2023-05-03 10:23:17 +00:00
. first ( )
. within ( ( ) = > {
cy . contains ( vegaWalletPublicKeyShort , { timeout : 20000 } ) . should (
'not.exist'
) ;
} ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( ethWalletContainer )
2023-05-03 10:23:17 +00:00
. first ( )
. within ( ( ) = > {
cy . contains ( vegaWalletPublicKeyShort , { timeout : 20000 } ) . should (
'not.exist'
) ;
} ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
0.0
) ;
2023-06-06 11:12:59 +00:00
} ) ;
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 ( ) {
2022-10-03 08:29:28 +00:00
// 1004-ASSO-006
2022-10-10 08:22:41 +00:00
// 1004-ASSO-007
// 1004-ASSO-018
2022-10-03 08:29:28 +00:00
// 1004-ASSO-024
// 1004-ASSO-023
2023-03-30 16:18:41 +00:00
// 1004-ASSO-032
2022-08-23 08:34:13 +00:00
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '2' , {
2023-02-03 19:26:17 +00:00
type : 'contract' ,
skipConfirmation : true ,
} ) ;
2023-03-22 17:35:00 +00:00
validateWalletCurrency ( 'Associated' , '0.00' ) ;
validateWalletCurrency ( 'Pending association' , '2.00' ) ;
validateWalletCurrency ( 'Total associated after pending' , '2.00' ) ;
verifyEthWalletAssociatedBalance ( '2.0' ) ;
verifyEthWalletTotalAssociatedBalance ( '2.0' ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
2.0
) ;
2023-06-06 11:12:59 +00:00
} ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletUnstakedBalance , txTimeout ) . should (
'contain' ,
2.0
) ;
2023-03-22 17:35:00 +00:00
stakingPageDisassociateTokens ( '1' , {
2023-02-03 19:26:17 +00:00
type : 'contract' ,
skipConfirmation : true ,
} ) ;
2023-03-22 17:35:00 +00:00
validateWalletCurrency ( 'Associated' , '2.00' ) ;
validateWalletCurrency ( 'Pending association' , '1.00' ) ;
validateWalletCurrency ( 'Total associated after pending' , '1.00' ) ;
verifyEthWalletAssociatedBalance ( '1.0' ) ;
verifyEthWalletTotalAssociatedBalance ( '1.0' ) ;
2022-08-23 08:34:13 +00:00
} ) ;
2022-08-30 09:09:47 +00:00
it ( 'Able to associate & disassociate both wallet and vesting contract tokens' , function ( ) {
2022-10-03 08:29:28 +00:00
// 1004-ASSO-019
// 1004-ASSO-020
// 1004-ASSO-021
// 1004-ASSO-022
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '21' , { type : 'wallet' } ) ;
2022-08-23 08:34:13 +00:00
cy . get ( 'button' ) . contains ( 'Select a validator to nominate' ) . click ( ) ;
2023-06-06 11:12:59 +00:00
cy . getByTestId ( 'epoch-countdown' ) . should ( 'be.visible' ) ;
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '37' , { type : 'contract' } ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vestingContractSection )
2023-05-03 10:23:17 +00:00
. first ( )
. within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associatedKey ) . should (
2023-05-03 10:23:17 +00:00
'contain' ,
Cypress . env ( 'vegaWalletPublicKeyShort' )
) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associatedAmount , txTimeout ) . should ( 'contain' , 37 ) ;
2023-05-03 10:23:17 +00:00
} ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaInWalletSection )
2023-05-03 10:23:17 +00:00
. first ( )
. within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associatedKey ) . should (
2023-05-03 10:23:17 +00:00
'contain' ,
Cypress . env ( 'vegaWalletPublicKeyShort' )
) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associatedAmount , txTimeout ) . should ( 'contain' , 21 ) ;
2023-05-03 10:23:17 +00:00
} ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
58
) ;
2023-06-06 11:12:59 +00:00
} ) ;
2023-03-22 17:35:00 +00:00
stakingPageDisassociateTokens ( '6' , { type : 'contract' } ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vestingContractSection )
2023-05-03 10:23:17 +00:00
. first ( )
. within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associatedAmount , txTimeout ) . should ( 'contain' , 31 ) ;
2023-05-03 10:23:17 +00:00
} ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
52
) ;
2023-06-06 11:12:59 +00:00
} ) ;
2023-03-22 17:35:00 +00:00
navigateTo ( navigation . validators ) ;
stakingPageDisassociateTokens ( '9' , { type : 'wallet' } ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaInWalletSection )
2023-05-03 10:23:17 +00:00
. first ( )
. within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associatedAmount , txTimeout ) . should ( 'contain' , 12 ) ;
2023-05-03 10:23:17 +00:00
} ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
43
) ;
2023-06-06 11:12:59 +00:00
} ) ;
2022-08-23 08:34:13 +00:00
} ) ;
it ( 'Not able to associate more tokens than owned' , function ( ) {
2022-10-10 08:22:41 +00:00
// 1004-ASSO-008
2022-10-03 08:29:28 +00:00
// 1004-ASSO-010
2022-08-23 08:34:13 +00:00
// No warning visible as described in AC, but the button is disabled
2023-04-13 09:46:01 +00:00
cy . get ( ethWalletAssociateButton ) . click ( ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associateWalletRadioButton , { timeout : 30000 } ) . click ( ) ;
cy . getByTestId ( tokenSubmitButton , txTimeout ) . should ( 'be.disabled' ) ; // button disabled with no input
cy . getByTestId ( tokenAmountInputBox , { timeout : 10000 } ) . type ( '6500000' ) ;
cy . getByTestId ( tokenSubmitButton , txTimeout ) . should ( 'be.disabled' ) ;
2022-08-23 08:34:13 +00:00
} ) ;
2022-09-16 17:12:08 +00:00
2022-10-10 08:22:41 +00:00
// 1004-ASSO-004
2023-02-03 19:26:17 +00:00
it ( 'Pending association outside of app is shown' , function ( ) {
2023-03-22 17:35:00 +00:00
vegaWalletAssociate ( '2' ) ;
validateWalletCurrency ( 'Associated' , '0.00' ) ;
validateWalletCurrency ( 'Pending association' , '2.00' ) ;
validateWalletCurrency ( 'Total associated after pending' , '2.00' ) ;
validateWalletCurrency ( 'Associated' , '2.00' ) ;
2023-02-03 19:26:17 +00:00
} ) ;
it ( 'Disassociation outside of app is shown' , function ( ) {
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '2' ) ;
cy . wrap ( validateWalletCurrency ( 'Associated' , '2.00' ) ) . then ( ( ) = > {
vegaWalletDisassociate ( '2' ) ;
} ) ;
validateWalletCurrency ( 'Associated' , '2.00' ) ;
validateWalletCurrency ( 'Pending association' , '2.00' ) ;
validateWalletCurrency ( 'Total associated after pending' , '0.00' ) ;
validateWalletCurrency ( 'Associated' , '0.00' ) ;
2023-02-03 19:26:17 +00:00
} ) ;
2022-10-10 08:22:41 +00:00
it ( 'Able to associate tokens to different public key of connected vega wallet' , function ( ) {
2023-04-13 09:46:01 +00:00
cy . get ( ethWalletAssociateButton ) . click ( ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associateWalletRadioButton ) . click ( ) ;
cy . getByTestId ( connectedVegaKey ) . should (
2022-10-10 08:22:41 +00:00
'have.text' ,
Cypress . env ( 'vegaWalletPublicKey' )
) ;
2023-06-21 08:42:36 +00:00
switchVegaWalletPubKey ( ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( connectedVegaKey ) . should (
2022-10-10 08:22:41 +00:00
'have.text' ,
Cypress . env ( 'vegaWalletPublicKey2' )
) ;
2023-03-22 17:35:00 +00:00
stakingPageAssociateTokens ( '2' ) ;
2023-06-06 11:12:59 +00:00
cy . get ( vegaWallet ) . within ( ( ) = > {
2023-06-28 16:15:06 +00:00
cy . getByTestId ( vegaWalletAssociatedBalance , txTimeout ) . should (
'contain' ,
2.0
) ;
2023-06-06 11:12:59 +00:00
} ) ;
2023-06-28 16:15:06 +00:00
cy . getByTestId ( associateCompleteText ) . should (
2022-10-10 08:22:41 +00:00
'have.text' ,
` Vega key ${ Cypress . env (
'vegaWalletPublicKey2Short'
) } can now participate in governance and nominate a validator with your associated $VEGA . `
) ;
2023-03-22 17:35:00 +00:00
stakingPageDisassociateAllTokens ( ) ;
2022-10-10 08:22:41 +00:00
} ) ;
2023-07-31 08:58:52 +00:00
it ( 'Able to associate over 1 million tokens' , function ( ) {
cy . get ( ethWalletAssociateButton ) . click ( ) ;
stakingPageAssociateTokens ( '2000000' , { approve : true } ) ;
stakingPageDisassociateAllTokens ( ) ;
} ) ;
2022-07-08 10:48:51 +00:00
} ) ;
2022-07-11 13:32:32 +00:00
}
) ;