fix(governance): failing nightly tests (#3351)

This commit is contained in:
Joe Tsang 2023-04-13 10:46:01 +01:00 committed by GitHub
parent e8fdb63323
commit ee2aafb99c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 39 deletions

View File

@ -44,7 +44,8 @@ describe(
function () { function () {
before('connect wallets and set approval limit', function () { before('connect wallets and set approval limit', function () {
cy.visit('/'); cy.visit('/');
vegaWalletSetSpecifiedApprovalAmount('1000'); ethereumWalletConnect();
cy.associateTokensToVegaWallet('1');
}); });
beforeEach('visit proposals tab', function () { beforeEach('visit proposals tab', function () {
@ -213,6 +214,7 @@ describe(
// 3001-VOTE-042, 3001-VOTE-057, 3001-VOTE-058, 3001-VOTE-059, 3001-VOTE-060 // 3001-VOTE-042, 3001-VOTE-057, 3001-VOTE-058, 3001-VOTE-059, 3001-VOTE-060
it('Newly created proposal details - ability to increase associated tokens - by voting again after association', function () { it('Newly created proposal details - ability to increase associated tokens - by voting again after association', function () {
vegaWalletSetSpecifiedApprovalAmount('1000');
createRawProposal(); createRawProposal();
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => { cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
getSubmittedProposalFromProposalList(rawProposal.rationale.title) getSubmittedProposalFromProposalList(rawProposal.rationale.title)

View File

@ -13,7 +13,6 @@ import {
createUpdateNetworkProposalTxBody, createUpdateNetworkProposalTxBody,
createFreeFormProposalTxBody, createFreeFormProposalTxBody,
} from '../../support/proposal.functions'; } from '../../support/proposal.functions';
import { ensureSpecifiedUnstakedTokensAreAssociated } from '../../support/staking.functions';
import { ethereumWalletConnect } from '../../support/wallet-eth.functions'; import { ethereumWalletConnect } from '../../support/wallet-eth.functions';
import { vegaWalletSetSpecifiedApprovalAmount } from '../../support/wallet-teardown.functions'; import { vegaWalletSetSpecifiedApprovalAmount } from '../../support/wallet-teardown.functions';
@ -33,10 +32,6 @@ context(
before('Connect wallets and set approval', function () { before('Connect wallets and set approval', function () {
cy.visit('/'); cy.visit('/');
vegaWalletSetSpecifiedApprovalAmount('1000'); vegaWalletSetSpecifiedApprovalAmount('1000');
cy.connectVegaWallet();
ethereumWalletConnect();
ensureSpecifiedUnstakedTokensAreAssociated('1');
cy.clearLocalStorage();
}); });
beforeEach('visit proposals', function () { beforeEach('visit proposals', function () {
@ -114,7 +109,7 @@ context(
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
cy.reload(); cy.reload();
waitForSpinner(); waitForSpinner();
cy.get(openProposals).within(() => { cy.get(openProposals, { timeout: 6000 }).within(() => {
cy.contains(proposalTitle) cy.contains(proposalTitle)
.parentsUntil('[data-testid="proposals-list-item"]') .parentsUntil('[data-testid="proposals-list-item"]')
.within(() => cy.get(viewProposalButton).click()); .within(() => cy.get(viewProposalButton).click());

View File

@ -232,7 +232,7 @@ context(
it('Unable to create a freeform proposal - when json parent section contains unexpected field', function () { it('Unable to create a freeform proposal - when json parent section contains unexpected field', function () {
const errorMsg = const errorMsg =
'Invalid params: the transaction does not use a valid Vega command: unknown field unexpected" in vega.commands.v1.ProposalSubmission'; 'Invalid params: the transaction does not use a valid Vega command: unknown field "unexpected" in vega.commands.v1.ProposalSubmission';
// 3001-VOTE-038 3002-PROP-013 3002-PROP-014 // 3001-VOTE-038 3002-PROP-013 3002-PROP-014
goToMakeNewProposal(governanceProposalType.RAW); goToMakeNewProposal(governanceProposalType.RAW);
@ -313,7 +313,7 @@ context(
it('Unable to vote on a proposal - when vega wallet disconnected - option to connect from within', function () { it('Unable to vote on a proposal - when vega wallet disconnected - option to connect from within', function () {
createRawProposal(); createRawProposal();
cy.get('[data-testid="manage-vega-wallet"]').click(); cy.get('[data-testid="manage-vega-wallet"]:visible').click();
cy.get('[data-testid="disconnect"]').click(); cy.get('[data-testid="disconnect"]').click();
cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => { cy.get<testFreeformProposal>('@rawProposal').then((rawProposal) => {
getSubmittedProposalFromProposalList( getSubmittedProposalFromProposalList(

View File

@ -218,7 +218,7 @@ context(
it('Unable to submit new market proposal with missing/invalid fields', function () { it('Unable to submit new market proposal with missing/invalid fields', function () {
const errorMsg = const errorMsg =
'Invalid params: the transaction is not a valid Vega command: unknown field "filters" in vega.DataSourceDefinition'; 'Invalid params: the transaction does not use a valid Vega command: unknown field "invalid" in vega.NewMarket';
goToMakeNewProposal(governanceProposalType.NEW_MARKET); goToMakeNewProposal(governanceProposalType.NEW_MARKET);
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
@ -436,7 +436,7 @@ context(
}); });
}); });
it.only('Able to submit update asset proposal using max deadline', function () { it('Able to submit update asset proposal using max deadline', function () {
goToMakeNewProposal(governanceProposalType.UPDATE_ASSET); goToMakeNewProposal(governanceProposalType.UPDATE_ASSET);
enterUpdateAssetProposalDetails(); enterUpdateAssetProposalDetails();
cy.get(maxVoteDeadline).click(); cy.get(maxVoteDeadline).click();

View File

@ -25,11 +25,11 @@ const vegaWalletUnstakedBalance =
'[data-testid="vega-wallet-balance-unstaked"]'; '[data-testid="vega-wallet-balance-unstaked"]';
const txTimeout = Cypress.env('txTimeout'); const txTimeout = Cypress.env('txTimeout');
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
const ethWalletAssociateButton = '[data-testid="associate-btn"]'; const ethWalletAssociateButton = '[data-testid="associate-btn"]:visible';
const associateWalletRadioButton = '[data-testid="associate-radio-wallet"]'; const associateWalletRadioButton = '[data-testid="associate-radio-wallet"]';
const tokenAmountInputBox = '[data-testid="token-amount-input"]'; const tokenAmountInputBox = '[data-testid="token-amount-input"]';
const tokenSubmitButton = '[data-testid="token-input-submit-button"]'; const tokenSubmitButton = '[data-testid="token-input-submit-button"]';
const ethWalletDissociateButton = '[href="/token/disassociate"]'; const ethWalletDissociateButton = '[href="/token/disassociate"]:visible';
const vestingContractSection = '[data-testid="vega-in-vesting-contract"]'; const vestingContractSection = '[data-testid="vega-in-vesting-contract"]';
const vegaInWalletSection = '[data-testid="vega-in-wallet"]'; const vegaInWalletSection = '[data-testid="vega-in-wallet"]';
const connectedVegaKey = '[data-testid="connected-vega-key"]'; const connectedVegaKey = '[data-testid="connected-vega-key"]';
@ -78,12 +78,12 @@ context(
cy.getByTestId('currency-title', txTimeout).should( cy.getByTestId('currency-title', txTimeout).should(
'have.length.above', 'have.length.above',
3 6
); );
validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Associated', '0.00');
validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Pending association', '2.00');
validateWalletCurrency('Total associated after pending', '2.00'); validateWalletCurrency('Total associated after pending', '2.00');
cy.getByTestId('currency-title', txTimeout).should('have.length', 3); cy.getByTestId('currency-title', txTimeout).should('have.length', 6);
// 0005-ETXN-002 // 0005-ETXN-002
verifyEthWalletAssociatedBalance('2.0'); verifyEthWalletAssociatedBalance('2.0');
@ -111,12 +111,12 @@ context(
stakingPageDisassociateTokens('2'); stakingPageDisassociateTokens('2');
cy.getByTestId('currency-title', txTimeout).should( cy.getByTestId('currency-title', txTimeout).should(
'have.length.above', 'have.length.above',
3 6
); );
validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Associated', '2.00');
validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Pending association', '2.00');
validateWalletCurrency('Total associated after pending', '0.00'); validateWalletCurrency('Total associated after pending', '0.00');
cy.getByTestId('currency-title', txTimeout).should('have.length', 3); cy.getByTestId('currency-title', txTimeout).should('have.length', 6);
cy.getByTestId('eth-wallet-associated-balances', txTimeout).should( cy.getByTestId('eth-wallet-associated-balances', txTimeout).should(
'not.exist' 'not.exist'
); );
@ -192,12 +192,12 @@ context(
cy.getByTestId('currency-title', txTimeout).should( cy.getByTestId('currency-title', txTimeout).should(
'have.length.above', 'have.length.above',
3 6
); );
validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Associated', '0.00');
validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Pending association', '2.00');
validateWalletCurrency('Total associated after pending', '2.00'); validateWalletCurrency('Total associated after pending', '2.00');
cy.getByTestId('currency-title', txTimeout).should('have.length', 3); cy.getByTestId('currency-title', txTimeout).should('have.length', 6);
verifyEthWalletAssociatedBalance('2.0'); verifyEthWalletAssociatedBalance('2.0');
verifyEthWalletTotalAssociatedBalance('2.0'); verifyEthWalletTotalAssociatedBalance('2.0');
cy.get(vegaWallet).within(() => { cy.get(vegaWallet).within(() => {
@ -210,12 +210,12 @@ context(
}); });
cy.getByTestId('currency-title', txTimeout).should( cy.getByTestId('currency-title', txTimeout).should(
'have.length.above', 'have.length.above',
3 6
); );
validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Associated', '2.00');
validateWalletCurrency('Pending association', '1.00'); validateWalletCurrency('Pending association', '1.00');
validateWalletCurrency('Total associated after pending', '1.00'); validateWalletCurrency('Total associated after pending', '1.00');
cy.getByTestId('currency-title', txTimeout).should('have.length', 3); cy.getByTestId('currency-title', txTimeout).should('have.length', 6);
verifyEthWalletAssociatedBalance('1.0'); verifyEthWalletAssociatedBalance('1.0');
verifyEthWalletTotalAssociatedBalance('1.0'); verifyEthWalletTotalAssociatedBalance('1.0');
}); });
@ -266,7 +266,7 @@ context(
// 1004-ASSO-008 // 1004-ASSO-008
// 1004-ASSO-010 // 1004-ASSO-010
// No warning visible as described in AC, but the button is disabled // No warning visible as described in AC, but the button is disabled
cy.get(ethWalletAssociateButton).first().click(); cy.get(ethWalletAssociateButton).click();
cy.get(associateWalletRadioButton, { timeout: 30000 }).click(); cy.get(associateWalletRadioButton, { timeout: 30000 }).click();
cy.get(tokenSubmitButton, txTimeout).should('be.disabled'); // button disabled with no input cy.get(tokenSubmitButton, txTimeout).should('be.disabled'); // button disabled with no input
cy.get(tokenAmountInputBox, { timeout: 10000 }).type('6500000'); cy.get(tokenAmountInputBox, { timeout: 10000 }).type('6500000');
@ -278,12 +278,12 @@ context(
vegaWalletAssociate('2'); vegaWalletAssociate('2');
cy.getByTestId('currency-title', txTimeout).should( cy.getByTestId('currency-title', txTimeout).should(
'have.length.above', 'have.length.above',
3 6
); );
validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Associated', '0.00');
validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Pending association', '2.00');
validateWalletCurrency('Total associated after pending', '2.00'); validateWalletCurrency('Total associated after pending', '2.00');
cy.getByTestId('currency-title', txTimeout).should('have.length', 3); cy.getByTestId('currency-title', txTimeout).should('have.length', 6);
validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Associated', '2.00');
}); });
@ -294,24 +294,24 @@ context(
}); });
cy.getByTestId('currency-title', txTimeout).should( cy.getByTestId('currency-title', txTimeout).should(
'have.length.above', 'have.length.above',
3 6
); );
validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Associated', '2.00');
validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Pending association', '2.00');
validateWalletCurrency('Total associated after pending', '0.00'); validateWalletCurrency('Total associated after pending', '0.00');
cy.getByTestId('currency-title', txTimeout).should('have.length', 3); cy.getByTestId('currency-title', txTimeout).should('have.length', 6);
validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Associated', '0.00');
}); });
it('Able to associate tokens to different public key of connected vega wallet', function () { it('Able to associate tokens to different public key of connected vega wallet', function () {
cy.get(ethWalletAssociateButton).first().click(); cy.get(ethWalletAssociateButton).click();
cy.get(associateWalletRadioButton).click(); cy.get(associateWalletRadioButton).click();
cy.get(connectedVegaKey).should( cy.get(connectedVegaKey).should(
'have.text', 'have.text',
Cypress.env('vegaWalletPublicKey') Cypress.env('vegaWalletPublicKey')
); );
cy.get('[data-testid="manage-vega-wallet"]').click(); cy.get('[data-testid="manage-vega-wallet"]:visible').click();
cy.get('[data-testid="select-keypair-button"]').eq(0).click(); cy.get('[data-testid="select-keypair-button"]').eq(0).click();
cy.get(connectedVegaKey).should( cy.get(connectedVegaKey).should(
'have.text', 'have.text',

View File

@ -166,6 +166,7 @@ export function goToMakeNewProposal(proposalType: string) {
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
cy.get(newProposalButton).should('be.visible').click(); cy.get(newProposalButton).should('be.visible').click();
cy.url().should('include', '/proposals/propose'); cy.url().should('include', '/proposals/propose');
cy.get(navigation.pageSpinner, { timeout: 20000 }).should('not.exist');
cy.get('li').should('contain.text', proposalType).and('be.visible'); cy.get('li').should('contain.text', proposalType).and('be.visible');
cy.get('li').contains(proposalType).click(); cy.get('li').contains(proposalType).click();
} }

View File

@ -8,6 +8,7 @@ import {
} from '@vegaprotocol/smart-contracts'; } from '@vegaprotocol/smart-contracts';
import { ethers, Wallet } from 'ethers'; import { ethers, Wallet } from 'ethers';
const associatedAmountInWallet = '[data-testid="associated-amount"]:visible';
const vegaWalletContainer = 'aside [data-testid="vega-wallet"]'; const vegaWalletContainer = 'aside [data-testid="vega-wallet"]';
const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic'); const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic');
const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey'); const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey');
@ -59,7 +60,7 @@ export async function faucetAsset(assetEthAddress: string) {
} }
export async function vegaWalletTeardown() { export async function vegaWalletTeardown() {
cy.get('[data-testid="associated-amount"]') cy.get(associatedAmountInWallet)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.then((associatedAmount) => { .then((associatedAmount) => {
@ -68,12 +69,12 @@ export async function vegaWalletTeardown() {
$body.find('[data-testid="eth-wallet-associated-balances"]').length || $body.find('[data-testid="eth-wallet-associated-balances"]').length ||
associatedAmount != '0.00' associatedAmount != '0.00'
) { ) {
vegaWalletTeardownVesting(vestingContract);
vegaWalletTeardownStaking(stakingBridgeContract); vegaWalletTeardownStaking(stakingBridgeContract);
vegaWalletTeardownVesting(vestingContract);
} }
}); });
cy.get(vegaWalletContainer).within(() => { cy.get(vegaWalletContainer).within(() => {
cy.getByTestId('associated-amount', { cy.get(associatedAmountInWallet, {
timeout: transactionTimeout, timeout: transactionTimeout,
}).contains('0.00', { }).contains('0.00', {
timeout: transactionTimeout, timeout: transactionTimeout,
@ -90,7 +91,7 @@ export async function vegaWalletSetSpecifiedApprovalAmount(
await promiseWithTimeout( await promiseWithTimeout(
token.approve( token.approve(
ethStakingBridgeContractAddress, ethStakingBridgeContractAddress,
resetAmount.concat('000000000000000000') resetAmount + '0'.repeat(18)
), ),
10 * 60 * 1000, 10 * 60 * 1000,
'set approval amount' 'set approval amount'
@ -104,12 +105,23 @@ async function vegaWalletTeardownStaking(stakingBridgeContract: StakingBridge) {
{ timeout: transactionTimeout, log: false } { timeout: transactionTimeout, log: false }
).then((stakeBalance) => { ).then((stakeBalance) => {
if (Number(stakeBalance) != 0) { if (Number(stakeBalance) != 0) {
cy.wrap( cy.get('[data-testid="vega-wallet-balance-unstaked"]:visible').within(
stakingBridgeContract.remove_stake( () => {
String(stakeBalance), cy.get(associatedAmountInWallet)
vegaWalletPubKey .invoke('text')
), .then(($walletAmount) => {
{ timeout: transactionTimeout, log: false } cy.wrap(
stakingBridgeContract.remove_stake(
String(stakeBalance),
vegaWalletPubKey
),
{ timeout: transactionTimeout, log: false }
);
cy.get(associatedAmountInWallet, {
timeout: transactionTimeout,
}).should('not.have.text', $walletAmount);
});
}
); );
} }
}); });
@ -124,7 +136,6 @@ async function vegaWalletTeardownVesting(vestingContract: TokenVesting) {
if (Number(vestingAmount) != 0) { if (Number(vestingAmount) != 0) {
// Wait needed to allow time for ganache to process tx for stakingBridgeContract.remove_stake // Wait needed to allow time for ganache to process tx for stakingBridgeContract.remove_stake
// eslint-disable-next-line cypress/no-unnecessary-waiting // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000);
cy.wrap( cy.wrap(
vestingContract.remove_stake(String(vestingAmount), vegaWalletPubKey), vestingContract.remove_stake(String(vestingAmount), vegaWalletPubKey),
{ timeout: transactionTimeout, log: false } { timeout: transactionTimeout, log: false }