test(token-e2e): lint

This commit is contained in:
AndyWhiteVega 2022-06-23 14:43:17 +01:00
parent 9500c522de
commit f0d1c1d15d
8 changed files with 350 additions and 251 deletions

View File

@ -4,72 +4,104 @@ import staking from '../../locators/staking.locators';
import '../../support/staking.functions'; import '../../support/staking.functions';
import '../../support/wallet.functions'; import '../../support/wallet.functions';
context('Staking Tab - with vega wallet connected', function() { context('Staking Tab - with vega wallet connected', function () {
before('visit staking tab and connect vega wallet', function () {
cy.visit('/');
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
cy.get(navigation.staking).first().click();
cy.walletVega_connect();
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance');
cy.stakingPage_getValidatorNamesSorted().as('validatorNames');
});
before('visit staking tab and connect vega wallet', function() { describe('vega wallet contains VEGA tokens', function () {
cy.visit('/'); before('ensure environment fit for test', function () {
cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); assert.isAtLeast(
cy.get(navigation.staking).first().click() parseInt(this.initialUnstakedBalance),
cy.walletVega_connect(); 0.1,
cy.get(navigation.spinner, {timeout : 20000}).should('not.exist') 'Checking we have at least 0.1 unstaked vega to play with'
cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); );
cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); assert.isAtLeast(
}) this.validatorNames.length,
2,
'Checking we have at least 2 validators'
);
// Ensure we are not in last minute - as this adds flake
cy.get(staking.epochEndingText)
.contains('Next epoch in 1 minutes', { timeout: 65000 })
.should('not.exist');
});
describe('vega wallet contains VEGA tokens', function() { before('drill into a specific validator - and note values', function () {
cy.get(staking.validatorNames).contains(this.validatorNames[0]).click();
cy.contains('Manage your stake').should('be.visible');
cy.get(staking.stakeNextEpochValue)
.invoke('text')
.as('initialStakeNextEpoch');
cy.get(staking.stakeThisEpochValue)
.invoke('text')
.as('initialStakeThisEpoch');
cy.contains('OWN STAKE (THIS EPOCH)')
.parent()
.siblings()
.invoke('text')
.as('initialValidatorStake');
});
before('ensure environment fit for test', function() { describe('Able to stake against a validator', function () {
assert.isAtLeast(parseInt(this.initialUnstakedBalance), 0.1, 'Checking we have at least 0.1 unstaked vega to play with'); it('Check - ability to fill in fields and request a stake of 0.1 tokens', function () {
assert.isAtLeast(this.validatorNames.length, 2, 'Checking we have at least 2 validators'); cy.get(staking.addStakeRadioButton).click({ force: true });
// Ensure we are not in last minute - as this adds flake cy.get(staking.tokenAmountInput).type('0.1');
cy.get(staking.epochEndingText).contains('Next epoch in 1 minutes', {timeout:65000}).should('not.exist'); cy.get('button').contains('Add 0.1 $VEGA tokens').click();
}) });
before('drill into a specific validator - and note values', function() { it('Check - relevant successfull feedback provided after staking', function () {
cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); // Wallet auto approves at this stage
cy.contains('Manage your stake').should('be.visible'); cy.contains(
cy.get(staking.stakeNextEpochValue).invoke('text').as('initialStakeNextEpoch'); `Adding 0.1 $VEGA to validator ${this.validatorNames[0]}`
cy.get(staking.stakeThisEpochValue).invoke('text').as('initialStakeThisEpoch'); ).should('be.visible');
cy.contains('OWN STAKE (THIS EPOCH)').parent().siblings().invoke('text').as('initialValidatorStake'); cy.contains(
}) 'Waiting for confirmation that your change in nomination has been received'
).should('be.visible');
cy.contains(
'Waiting for confirmation that your change in nomination has been received',
{ timeout: 120000 }
).should('not.exist');
cy.contains(
'At the beginning of the next epoch your $VEGA will be nominated to the validator'
);
});
describe('Able to stake against a validator', function() { it('Check - staking page - stake on node (next epoch) - updates to reflect stake', function () {
let expectedStakeNextEpochValue =
parseFloat(this.initialStakeNextEpoch) + 0.1;
cy.get(staking.stakeNextEpochValue, { timeout: 10000 }).contains(
expectedStakeNextEpochValue.toFixed(2),
{ timeout: 10000 }
);
});
it('Check - ability to fill in fields and request a stake of 0.1 tokens', function() { it('Check - wallet - next epoch amount - updates balance for validator', function () {
cy.get(staking.addStakeRadioButton).click({force:true}); let expectedValStakeNextEpochValue =
cy.get(staking.tokenAmountInput).type('0.1'); parseFloat(this.initialStakeNextEpoch) + 0.1;
cy.get('button').contains('Add 0.1 $VEGA tokens').click(); cy.walletVega_getNextEpochStakeForSpecifiedValidator(
}) this.validatorNames[0]
).then((actualNextEpochStake) => {
it('Check - relevant successfull feedback provided after staking', function() { assert.equal(
// Wallet auto approves at this stage parseFloat(actualNextEpochStake).toPrecision(12),
cy.contains(`Adding 0.1 $VEGA to validator ${this.validatorNames[0]}`).should('be.visible'); parseFloat(expectedValStakeNextEpochValue).toPrecision(12)
cy.contains('Waiting for confirmation that your change in nomination has been received').should('be.visible'); );
cy.contains('Waiting for confirmation that your change in nomination has been received', {timeout: 120000}).should('not.exist'); });
cy.contains('At the beginning of the next epoch your $VEGA will be nominated to the validator'); });
})
it('Check - staking page - stake on node (next epoch) - updates to reflect stake', function() { it.skip('Check - wallet - unstaked amount - updates balance', function () {
let expectedStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) + 0.1; // Skipping until capsule can enable this test
cy.get(staking.stakeNextEpochValue, {timeout:10000}) cy.walletVega_getUnstakedAmount().should(
.contains(expectedStakeNextEpochValue.toFixed(2), {timeout:10000}) 'equal',
}) this.initialUnstakedBalance - 0.1
);
it('Check - wallet - next epoch amount - updates balance for validator', function() { });
let expectedValStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) + 0.1; });
cy.walletVega_getNextEpochStakeForSpecifiedValidator(this.validatorNames[0]) });
.then(actualNextEpochStake => { });
assert.equal(
parseFloat(actualNextEpochStake).toPrecision(12),
parseFloat(expectedValStakeNextEpochValue).toPrecision(12)
)
})
})
it.skip('Check - wallet - unstaked amount - updates balance', function() {
// Skipping until capsule can enable this test
cy.walletVega_getUnstakedAmount().should('equal', this.initialUnstakedBalance - 0.1)
})
})
})
})

View File

@ -4,77 +4,107 @@ import staking from '../../locators/staking.locators';
import '../../support/staking.functions'; import '../../support/staking.functions';
import '../../support/wallet.functions'; import '../../support/wallet.functions';
context('Staking Tab - with vega wallet connected', function() { context('Staking Tab - with vega wallet connected', function () {
before('visit staking tab and connect vega wallet', function () {
cy.visit('/');
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
cy.get(navigation.staking).first().click();
cy.walletVega_connect();
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance');
cy.stakingPage_getValidatorNamesSorted().as('validatorNames');
});
before('visit staking tab and connect vega wallet', function() { describe('vega wallet contains VEGA tokens', function () {
cy.visit('/'); before('ensure environment fit for test', function () {
cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); assert.isAtLeast(
cy.get(navigation.staking).first().click(); this.validatorNames.length,
cy.walletVega_connect(); 2,
cy.get(navigation.spinner, {timeout : 20000}).should('not.exist'); 'Checking we have at least 2 validators'
cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); );
cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); // Ensure we are not in last minute - as this adds flake
}) cy.get(staking.epochEndingText)
.contains('Next epoch in 1 minutes', { timeout: 65000 })
.should('not.exist');
});
describe('vega wallet contains VEGA tokens', function() { before('drill into a specific validator - and note values', function () {
cy.get(staking.validatorNames).contains(this.validatorNames[0]).click();
cy.contains('Manage your stake').should('be.visible');
cy.get(staking.stakeNextEpochValue)
.invoke('text')
.as('initialStakeNextEpoch');
cy.get(staking.stakeThisEpochValue)
.invoke('text')
.as('initialStakeThisEpoch');
cy.contains('OWN STAKE (THIS EPOCH)')
.parent()
.siblings()
.invoke('text')
.as('initialValidatorStake');
});
before('ensure environment fit for test', function() { describe('Able to remove a stake against a validator', function () {
assert.isAtLeast(this.validatorNames.length, 2, 'Checking we have at least 2 validators'); it('Check - validator has tokens to remove', function () {
// Ensure we are not in last minute - as this adds flake let tokensToRemove = parseFloat(this.initialStakeNextEpoch);
cy.get(staking.epochEndingText).contains('Next epoch in 1 minutes', {timeout:65000}).should('not.exist'); assert.isAtLeast(
}) tokensToRemove,
0.1,
'Checking we have tokens to remove'
);
});
before('drill into a specific validator - and note values', function() { it('Check - ability to fill in fields and request a stake of 0.1 tokens', function () {
cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); cy.get(staking.removeStakeRadioButton).click({ force: true });
cy.contains('Manage your stake').should('be.visible'); cy.get(staking.tokenAmountInput).type('0.1');
cy.get(staking.stakeNextEpochValue).invoke('text').as('initialStakeNextEpoch'); cy.get('button').contains('Remove 0.1 $VEGA tokens').click();
cy.get(staking.stakeThisEpochValue).invoke('text').as('initialStakeThisEpoch'); });
cy.contains('OWN STAKE (THIS EPOCH)').parent().siblings().invoke('text').as('initialValidatorStake');
})
describe('Able to remove a stake against a validator', function() { it('Check - relevant successfull feedback provided after staking', function () {
// Wallet auto approves at this stage
cy.contains(
`Removing 0.1 $VEGA from validator ${this.validatorNames[0]}`
).should('be.visible');
cy.contains(
'Waiting for confirmation that your change in nomination has been received'
).should('be.visible');
cy.contains(
'Waiting for confirmation that your change in nomination has been received',
{ timeout: 120000 }
).should('not.exist');
cy.contains(
`0.1 $VEGA has been removed from validator ${this.validatorNames[0]}`
);
});
it('Check - validator has tokens to remove', function() { it('Check - staking page - stake on node (next epoch) - updates to reflect stake', function () {
let tokensToRemove = parseFloat(this.initialStakeNextEpoch); let expectedStakeNextEpochValue =
assert.isAtLeast(tokensToRemove, 0.10, 'Checking we have tokens to remove'); parseFloat(this.initialStakeNextEpoch) - 0.1;
}) cy.get(staking.stakeNextEpochValue, { timeout: 10000 })
.contains(expectedStakeNextEpochValue.toFixed(2), { timeout: 10000 })
.should('be.visible');
});
it('Check - ability to fill in fields and request a stake of 0.1 tokens', function() { it('Check - wallet - next epoch amount - updates balance for validator', function () {
cy.get(staking.removeStakeRadioButton).click({force:true}); let expectedValStakeNextEpochValue =
cy.get(staking.tokenAmountInput).type('0.1'); parseFloat(this.initialStakeNextEpoch) - 0.1;
cy.get('button').contains('Remove 0.1 $VEGA tokens').click(); cy.walletVega_getNextEpochStakeForSpecifiedValidator(
}) this.validatorNames[0]
).then((actualNextEpochStake) => {
it('Check - relevant successfull feedback provided after staking', function() { assert.equal(
// Wallet auto approves at this stage parseFloat(actualNextEpochStake).toPrecision(12),
cy.contains(`Removing 0.1 $VEGA from validator ${this.validatorNames[0]}`).should('be.visible'); parseFloat(expectedValStakeNextEpochValue).toPrecision(12)
cy.contains('Waiting for confirmation that your change in nomination has been received').should('be.visible'); );
cy.contains('Waiting for confirmation that your change in nomination has been received', {timeout: 120000}).should('not.exist'); });
cy.contains(`0.1 $VEGA has been removed from validator ${this.validatorNames[0]}`); });
})
it('Check - staking page - stake on node (next epoch) - updates to reflect stake', function() { it.skip('Check - wallet - unstaked amount - updates balance', function () {
let expectedStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) - 0.1; // Skipping until capsule can enable this test
cy.get(staking.stakeNextEpochValue, {timeout:10000}) cy.walletVega_getUnstakedAmount().should(
.contains(expectedStakeNextEpochValue.toFixed(2), {timeout:10000}) 'equal',
.should('be.visible') this.initialUnstakedBalance - 0.1
}) );
});
it('Check - wallet - next epoch amount - updates balance for validator', function() { });
let expectedValStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) - 0.1; });
cy.walletVega_getNextEpochStakeForSpecifiedValidator(this.validatorNames[0]) });
.then(actualNextEpochStake => {
assert.equal(
parseFloat(actualNextEpochStake).toPrecision(12),
parseFloat(expectedValStakeNextEpochValue).toPrecision(12)
)
})
})
it.skip('Check - wallet - unstaked amount - updates balance', function() {
// Skipping until capsule can enable this test
cy.walletVega_getUnstakedAmount().should('equal', this.initialUnstakedBalance - 0.1)
})
})
})
})

View File

@ -4,67 +4,96 @@ import staking from '../../locators/staking.locators';
import '../../support/staking.functions'; import '../../support/staking.functions';
import '../../support/wallet.functions'; import '../../support/wallet.functions';
context('Staking Tab - with vega wallet connected', function() { context('Staking Tab - with vega wallet connected', function () {
before('visit staking tab and connect vega wallet', function () {
cy.visit('/');
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
cy.get(navigation.staking).first().click();
cy.walletVega_connect();
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance');
cy.stakingPage_getValidatorNamesSorted().as('validatorNames');
});
before('visit staking tab and connect vega wallet', function() { describe('vega wallet contains VEGA tokens', function () {
cy.visit('/'); before('ensure environment fit for test', function () {
cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); assert.isAtLeast(
cy.get(navigation.staking).first().click() parseInt(this.initialUnstakedBalance),
cy.walletVega_connect(); 0.1,
cy.get(navigation.spinner, {timeout : 20000}).should('not.exist') 'Checking we have at least 0.1 unstaked vega to play with'
cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); );
cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); assert.isAtLeast(
}) this.validatorNames.length,
2,
'Checking we have at least 2 validators'
);
// Ensure we are not in last minute - as this adds flake
cy.get(staking.epochEndingText)
.contains('Next epoch in 1 minutes', { timeout: 65000 })
.should('not.exist');
});
describe('vega wallet contains VEGA tokens', function() { before('drill into a specific validator - and note values', function () {
cy.get(staking.validatorNames).contains(this.validatorNames[0]).click();
cy.contains('Manage your stake').should('be.visible');
cy.get(staking.stakeNextEpochValue)
.invoke('text')
.as('initialStakeNextEpoch');
cy.get(staking.stakeThisEpochValue)
.invoke('text')
.as('initialStakeThisEpoch');
cy.contains('OWN STAKE (THIS EPOCH)')
.parent()
.siblings()
.invoke('text')
.as('initialValidatorStake');
});
before('ensure environment fit for test', function() { describe('Able to stake against a validator', function () {
assert.isAtLeast(parseInt(this.initialUnstakedBalance), 0.1, 'Checking we have at least 0.1 unstaked vega to play with'); it('Able to stake against a validator', function () {
assert.isAtLeast(this.validatorNames.length, 2, 'Checking we have at least 2 validators'); // Check - ability to fill in fields and request a stake of 0.1 tokens
// Ensure we are not in last minute - as this adds flake cy.get(staking.addStakeRadioButton).click({ force: true });
cy.get(staking.epochEndingText).contains('Next epoch in 1 minutes', {timeout:65000}).should('not.exist'); cy.get(staking.tokenAmountInput).type('0.1');
}) cy.get('button').contains('Add 0.1 $VEGA tokens').click();
before('drill into a specific validator - and note values', function() { // Check - relevant successfull feedback provided after staking - Note: Wallet auto approves at this stage
cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); cy.contains(
cy.contains('Manage your stake').should('be.visible'); `Adding 0.1 $VEGA to validator ${this.validatorNames[0]}`
cy.get(staking.stakeNextEpochValue).invoke('text').as('initialStakeNextEpoch'); ).should('be.visible');
cy.get(staking.stakeThisEpochValue).invoke('text').as('initialStakeThisEpoch'); cy.contains(
cy.contains('OWN STAKE (THIS EPOCH)').parent().siblings().invoke('text').as('initialValidatorStake'); 'Waiting for confirmation that your change in nomination has been received'
}) ).should('be.visible');
cy.contains(
'Waiting for confirmation that your change in nomination has been received',
{ timeout: 120000 }
).should('not.exist');
cy.contains(
'At the beginning of the next epoch your $VEGA will be nominated to the validator'
);
describe('Able to stake against a validator', function() { // Check - staking page - stake on node (next epoch) - updates to reflect stake
let expectedStakeNextEpochValue =
parseFloat(this.initialStakeNextEpoch) + 0.1;
cy.get(staking.stakeNextEpochValue, { timeout: 10000 }).contains(
expectedStakeNextEpochValue.toFixed(2),
{ timeout: 10000 }
);
it('Able to stake against a validator', function() { //Check - wallet staked amount - updates balance for validator
// Check - ability to fill in fields and request a stake of 0.1 tokens let expectedValStakeNextEpochValue =
cy.get(staking.addStakeRadioButton).click({force:true}); parseFloat(this.initialStakeNextEpoch) + 0.1;
cy.get(staking.tokenAmountInput).type('0.1'); cy.walletVega_getNextEpochStakeForSpecifiedValidator(
cy.get('button').contains('Add 0.1 $VEGA tokens').click(); this.validatorNames[0]
).then((actualNextEpochStake) => {
assert.equal(
parseFloat(actualNextEpochStake).toPrecision(12),
parseFloat(expectedValStakeNextEpochValue).toPrecision(12)
);
});
// Check - relevant successfull feedback provided after staking - Note: Wallet auto approves at this stage //Check - wallet unstaked amount - updates balance - Note: Skipping until capsule can enable this test
cy.contains(`Adding 0.1 $VEGA to validator ${this.validatorNames[0]}`).should('be.visible'); // cy.walletVega_getUnstakedAmount().should('equal', this.initialUnstakedBalance - 0.1);
cy.contains('Waiting for confirmation that your change in nomination has been received').should('be.visible'); });
cy.contains('Waiting for confirmation that your change in nomination has been received', {timeout: 120000}).should('not.exist'); });
cy.contains('At the beginning of the next epoch your $VEGA will be nominated to the validator'); });
});
// Check - staking page - stake on node (next epoch) - updates to reflect stake
let expectedStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) + 0.1;
cy.get(staking.stakeNextEpochValue, {timeout:10000})
.contains(expectedStakeNextEpochValue.toFixed(2), {timeout:10000})
//Check - wallet staked amount - updates balance for validator
let expectedValStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) + 0.1;
cy.walletVega_getNextEpochStakeForSpecifiedValidator(this.validatorNames[0])
.then(actualNextEpochStake => {
assert.equal(
parseFloat(actualNextEpochStake).toPrecision(12),
parseFloat(expectedValStakeNextEpochValue).toPrecision(12)
)
})
//Check - wallet unstaked amount - updates balance - Note: Skipping until capsule can enable this test
// cy.walletVega_getUnstakedAmount().should('equal', this.initialUnstakedBalance - 0.1);
})
})
})
})

View File

@ -1,10 +1,10 @@
export default { export default {
section: 'nav', section: 'nav',
home: '[href="/"]', home: '[href="/"]',
vesting: '[href="/vesting"]', vesting: '[href="/vesting"]',
staking: '[href="/staking"]', staking: '[href="/staking"]',
rewards: '[href="/rewards"]', rewards: '[href="/rewards"]',
withdraw: '[href="/withdraw"]', withdraw: '[href="/withdraw"]',
governance: '[href="/governance"]', governance: '[href="/governance"]',
spinner: 'splash-loader' spinner: 'splash-loader',
}; };

View File

@ -1,10 +1,10 @@
export default { export default {
validatorNames: '[data-testid="node-list-item"] > :nth-child(1)', validatorNames: '[data-testid="node-list-item"] > :nth-child(1)',
epochEndingText: '[data-testid="epoch-countdown"]', epochEndingText: '[data-testid="epoch-countdown"]',
addStakeRadioButton: '[data-testid="add-stake-radio"]', addStakeRadioButton: '[data-testid="add-stake-radio"]',
removeStakeRadioButton: '[data-testid="remove-stake-radio"]', removeStakeRadioButton: '[data-testid="remove-stake-radio"]',
tokenAmountInput: '[data-testid="token-amount-input"]', tokenAmountInput: '[data-testid="token-amount-input"]',
stakedAmounts: '[data-testid="staked-validator-item"]', stakedAmounts: '[data-testid="staked-validator-item"]',
stakeNextEpochValue: '[data-testid="stake-next-epoch"]', stakeNextEpochValue: '[data-testid="stake-next-epoch"]',
stakeThisEpochValue: '[data-testid="stake-this-epoch"]', stakeThisEpochValue: '[data-testid="stake-this-epoch"]',
}; };

View File

@ -1,6 +1,6 @@
export default { export default {
connectRestForm: '[data-testid="rest-connector-form"]', connectRestForm: '[data-testid="rest-connector-form"]',
name: '#wallet', name: '#wallet',
passphrase: '#passphrase', passphrase: '#passphrase',
vegawallet: '.vega-wallet' vegawallet: '.vega-wallet',
}; };

View File

@ -1,10 +1,12 @@
import staking from '../locators/staking.locators'; import staking from '../locators/staking.locators';
Cypress.Commands.add("stakingPage_getValidatorNamesSorted", function() { Cypress.Commands.add('stakingPage_getValidatorNamesSorted', function () {
let validatorNames = []; let validatorNames = [];
cy.get(staking.validatorNames) cy.get(staking.validatorNames)
.each(($validatorName) => { .each(($validatorName) => {
validatorNames.push($validatorName.text()); validatorNames.push($validatorName.text());
}) })
.then(() => {return validatorNames.sort()}) .then(() => {
}) return validatorNames.sort();
});
});

View File

@ -1,47 +1,53 @@
import wallet from '../locators/wallet.locators'; import wallet from '../locators/wallet.locators';
Cypress.Commands.add("walletVega_connect", function () {
const walletName = Cypress.env('TRADING_TEST_VEGA_WALLET_NAME'); Cypress.Commands.add('walletVega_connect', function () {
const walletPassphrase = Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE'); const walletName = Cypress.env('TRADING_TEST_VEGA_WALLET_NAME');
const walletTruncatedKey = Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY'); const walletPassphrase = Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE');
const walletTruncatedKey = Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY');
cy.get(wallet.vegawallet).within(() => { cy.get(wallet.vegawallet).within(() => {
cy.get('button') cy.get('button')
.contains('Connect Vega wallet to use associated $VEGA') .contains('Connect Vega wallet to use associated $VEGA')
.should('be.enabled').click(); .should('be.enabled')
}) .click();
});
cy.get('button').contains('rest provider').click(); cy.get('button').contains('rest provider').click();
cy.get(wallet.connectRestForm).within(() => { cy.get(wallet.connectRestForm).within(() => {
cy.get(wallet.name).click().type(walletName); cy.get(wallet.name).click().type(walletName);
cy.get(wallet.passphrase).click().type(walletPassphrase); cy.get(wallet.passphrase).click().type(walletPassphrase);
cy.get('button').contains('Connect').click(); cy.get('button').contains('Connect').click();
}) });
cy.get(wallet.vegawallet).within(() => { cy.get(wallet.vegawallet).within(() => {
cy.contains(walletTruncatedKey).should('be.visible'); cy.contains(walletTruncatedKey).should('be.visible');
cy.contains('Assets', {timeout: 20000}).should('be.visible'); cy.contains('Assets', { timeout: 20000 }).should('be.visible');
}) });
}) });
Cypress.Commands.add("walletVega_getUnstakedAmount", function() { Cypress.Commands.add('walletVega_getUnstakedAmount', function () {
cy.get(wallet.vegawallet).contains('Unstaked').siblings().invoke('text') cy.get(wallet.vegawallet).contains('Unstaked').siblings().invoke('text');
}) });
Cypress.Commands.add("walletVega_getNextEpochStakeForSpecifiedValidator", function(validatorName) { Cypress.Commands.add(
'walletVega_getNextEpochStakeForSpecifiedValidator',
function (validatorName) {
// need to check if validator is present first // need to check if validator is present first
let fieldPresent = false; let fieldPresent = false;
cy.get(wallet.vegawallet) cy.get(wallet.vegawallet)
.within(($wallet) => { .within(($wallet) => {
if ($wallet.text().includes(`${validatorName} (Next epoch)`)) fieldPresent = true if ($wallet.text().includes(`${validatorName} (Next epoch)`))
}) fieldPresent = true;
.then(() => { })
.then(() => {
if (fieldPresent == true) { if (fieldPresent == true) {
cy.contains(`${validatorName} (Next epoch)`) cy.contains(`${validatorName} (Next epoch)`)
.siblings() .siblings()
.invoke('text')} .invoke('text');
else {return "0.000000000000000000"} } else {
}) return '0.000000000000000000';
}) }
});
}
);