chore(governance): fix flaky test failures (#4043)

This commit is contained in:
Joe Tsang 2023-06-06 22:19:23 +01:00 committed by GitHub
parent 71540a90fb
commit d6a32f5090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 144 additions and 104 deletions

View File

@ -105,9 +105,9 @@ context(
goToMakeNewProposal(governanceProposalType.RAW); goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath, submit: false }); submitUniqueRawProposal({ proposalBody: filePath, submit: false });
}); });
cy.get(newProposalSubmitButton).click();
validateDialogContentMsg('PROPOSAL_ERROR_CLOSE_TIME_TOO_SOON');
}); });
cy.get(newProposalSubmitButton).click();
validateDialogContentMsg('PROPOSAL_ERROR_CLOSE_TIME_TOO_SOON');
}); });
// 3007-PNEC-001 3007-PNEC-003 // 3007-PNEC-001 3007-PNEC-003
@ -187,13 +187,17 @@ context(
'have.text', 'have.text',
'Proposal will fail if enactment is earlier than the voting deadline' 'Proposal will fail if enactment is earlier than the voting deadline'
); );
cy.get(proposalDownloadBtn).click(); cy.get(proposalDownloadBtn)
cy.wrap( .should('be.visible')
getDownloadedProposalJsonPath('vega-network-param-proposal-') .click()
).then((filePath) => { .then(() => {
goToMakeNewProposal(governanceProposalType.RAW); cy.wrap(
submitUniqueRawProposal({ proposalBody: filePath, submit: false }); getDownloadedProposalJsonPath('vega-network-param-proposal-')
}); ).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath, submit: false });
});
});
cy.get(newProposalSubmitButton).click(); cy.get(newProposalSubmitButton).click();
validateFeedBackMsg( validateFeedBackMsg(
'Invalid params: proposal_submission.terms.closing_timestamp (cannot be after enactment time)' 'Invalid params: proposal_submission.terms.closing_timestamp (cannot be after enactment time)'
@ -202,9 +206,6 @@ context(
// 3003-PMAN-001 // 3003-PMAN-001
it('Able to submit valid new market proposal', function () { it('Able to submit valid new market proposal', function () {
// Wait needed for test to pass in CI because of report name discrepancy when time passes
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(5000);
goToMakeNewProposal(governanceProposalType.NEW_MARKET); goToMakeNewProposal(governanceProposalType.NEW_MARKET);
cy.get(newProposalTitle).type('Test new market proposal'); cy.get(newProposalTitle).type('Test new market proposal');
cy.get(newProposalDescription).type('E2E test for proposals'); cy.get(newProposalDescription).type('E2E test for proposals');
@ -215,13 +216,17 @@ context(
delay: 2, delay: 2,
}); });
}); });
cy.get(proposalDownloadBtn).should('be.visible').click(); cy.get(proposalDownloadBtn)
cy.wrap(getDownloadedProposalJsonPath('vega-new-market-proposal-')).then( .should('be.visible')
(filePath) => { .click()
goToMakeNewProposal(governanceProposalType.RAW); .then(() => {
submitUniqueRawProposal({ proposalBody: filePath }); // 3003-PMAN-003 cy.wrap(
} getDownloadedProposalJsonPath('vega-new-market-proposal-')
); ).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath }); // 3003-PMAN-003
});
});
}); });
it('Unable to submit new market proposal with missing/invalid fields', function () { it('Unable to submit new market proposal with missing/invalid fields', function () {
@ -241,13 +246,17 @@ context(
delay: 2, delay: 2,
}); });
}); });
cy.get(proposalDownloadBtn).should('be.visible').click(); cy.get(proposalDownloadBtn)
cy.wrap(getDownloadedProposalJsonPath('vega-new-market-proposal-')).then( .should('be.visible')
(filePath) => { .click()
goToMakeNewProposal(governanceProposalType.RAW); .then(() => {
submitUniqueRawProposal({ proposalBody: filePath, submit: false }); cy.wrap(
} getDownloadedProposalJsonPath('vega-new-market-proposal-')
); ).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath, submit: false });
});
});
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
cy.contains('Transaction failed', proposalTimeout).should('be.visible'); cy.contains('Transaction failed', proposalTimeout).should('be.visible');
validateFeedBackMsg(errorMsg); validateFeedBackMsg(errorMsg);
@ -270,13 +279,17 @@ context(
delay: 2, delay: 2,
}); });
}); });
cy.get(proposalDownloadBtn).should('be.visible').click(); cy.get(proposalDownloadBtn)
cy.wrap( .should('be.visible')
getDownloadedProposalJsonPath('vega-update-market-proposal-') .click()
).then((filePath) => { .then(() => {
goToMakeNewProposal(governanceProposalType.RAW); cy.wrap(
submitUniqueRawProposal({ proposalBody: filePath, submit: false }); getDownloadedProposalJsonPath('vega-update-market-proposal-')
}); ).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath, submit: false });
});
});
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
cy.contains('Proposal rejected', proposalTimeout).should('be.visible'); cy.contains('Proposal rejected', proposalTimeout).should('be.visible');
validateDialogContentMsg('PROPOSAL_ERROR_INSUFFICIENT_EQUITY_LIKE_SHARE'); validateDialogContentMsg('PROPOSAL_ERROR_INSUFFICIENT_EQUITY_LIKE_SHARE');
@ -306,13 +319,17 @@ context(
delay: 2, delay: 2,
}); });
}); });
cy.get(proposalDownloadBtn).should('be.visible').click(); cy.get(proposalDownloadBtn)
cy.wrap( .should('be.visible')
getDownloadedProposalJsonPath('vega-update-market-proposal-') .click()
).then((filePath) => { .then(() => {
goToMakeNewProposal(governanceProposalType.RAW); cy.wrap(
submitUniqueRawProposal({ proposalBody: filePath, submit: false }); getDownloadedProposalJsonPath('vega-update-market-proposal-')
}); ).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath, submit: false });
});
});
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
cy.contains('Transaction failed', proposalTimeout).should('be.visible'); cy.contains('Transaction failed', proposalTimeout).should('be.visible');
validateFeedBackMsg( validateFeedBackMsg(
@ -350,13 +367,17 @@ context(
delay: 2, delay: 2,
}); });
}); });
cy.get(proposalDownloadBtn).should('be.visible').click(); cy.get(proposalDownloadBtn)
cy.wrap( .should('be.visible')
getDownloadedProposalJsonPath('vega-update-market-proposal-') .click()
).then((filePath) => { .then(() => {
goToMakeNewProposal(governanceProposalType.RAW); cy.wrap(
submitUniqueRawProposal({ proposalBody: filePath }); getDownloadedProposalJsonPath('vega-update-market-proposal-')
}); ).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath });
});
});
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
cy.get('@EnactedMarketId').then((marketId) => { cy.get('@EnactedMarketId').then((marketId) => {
cy.contains(String(marketId).slice(0, 6)) cy.contains(String(marketId).slice(0, 6))
@ -405,14 +426,17 @@ context(
cy.get(minVoteDeadline).click(); cy.get(minVoteDeadline).click();
cy.get(minValidationDeadline).click(); cy.get(minValidationDeadline).click();
cy.get(minEnactDeadline).click(); cy.get(minEnactDeadline).click();
cy.get(proposalDownloadBtn)
cy.get(proposalDownloadBtn).should('be.visible').click(); .should('be.visible')
cy.wrap(getDownloadedProposalJsonPath('vega-new-asset-proposal-')).then( .click()
(filePath) => { .then(() => {
goToMakeNewProposal(governanceProposalType.RAW); cy.wrap(
submitUniqueRawProposal({ proposalBody: filePath, submit: false }); // 3005-PASN-003 getDownloadedProposalJsonPath('vega-new-asset-proposal-')
} ).then((filePath) => {
); goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath, submit: false }); // 3005-PASN-003
});
});
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
closeDialog(); closeDialog();
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
@ -448,13 +472,17 @@ context(
enterUpdateAssetProposalDetails(); enterUpdateAssetProposalDetails();
cy.get(minVoteDeadline).click(); cy.get(minVoteDeadline).click();
cy.get(minEnactDeadline).click(); cy.get(minEnactDeadline).click();
cy.get(proposalDownloadBtn).should('be.visible').click(); cy.get(proposalDownloadBtn)
cy.wrap( .should('be.visible')
getDownloadedProposalJsonPath('vega-update-asset-proposal-') .click()
).then((filePath) => { .then(() => {
goToMakeNewProposal(governanceProposalType.RAW); cy.wrap(
submitUniqueRawProposal({ proposalBody: filePath }); getDownloadedProposalJsonPath('vega-update-asset-proposal-')
}); ).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath });
});
});
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
cy.get(openProposals).within(() => { cy.get(openProposals).within(() => {
cy.get(proposalType) cy.get(proposalType)
@ -486,13 +514,17 @@ context(
enterUpdateAssetProposalDetails(); enterUpdateAssetProposalDetails();
cy.get(maxVoteDeadline).click(); cy.get(maxVoteDeadline).click();
cy.get(maxEnactDeadline).click(); cy.get(maxEnactDeadline).click();
cy.get(proposalDownloadBtn).should('be.visible').click(); cy.get(proposalDownloadBtn)
cy.wrap( .should('be.visible')
getDownloadedProposalJsonPath('vega-update-asset-proposal-') .click()
).then((filePath) => { .then(() => {
goToMakeNewProposal(governanceProposalType.RAW); cy.wrap(
submitUniqueRawProposal({ proposalBody: filePath }); getDownloadedProposalJsonPath('vega-update-asset-proposal-')
}); ).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath });
});
});
}); });
it('Unable to submit edit asset proposal with missing/invalid fields', function () { it('Unable to submit edit asset proposal with missing/invalid fields', function () {

View File

@ -20,10 +20,8 @@ const vegaAssetAddress = '0x67175Da1D5e966e40D11c4B2519392B2058373de';
const vegaWalletUnstakedBalance = const vegaWalletUnstakedBalance =
'[data-testid="vega-wallet-balance-unstaked"]'; '[data-testid="vega-wallet-balance-unstaked"]';
const rewardsTable = 'epoch-total-rewards-table'; const rewardsTable = 'epoch-total-rewards-table';
const rewardsStartEpoch = 380; // Use 30 running locally
const rewardsEndEpoch = 500; // Change to 200 running locally
const txTimeout = Cypress.env('txTimeout'); const txTimeout = Cypress.env('txTimeout');
const rewardsTimeOut = { timeout: 5 * 60 * 1000 }; const rewardsTimeOut = { timeout: 60000 };
context('rewards - flow', { tags: '@slow' }, function () { context('rewards - flow', { tags: '@slow' }, function () {
before('set up environment to allow rewards', function () { before('set up environment to allow rewards', function () {
@ -40,13 +38,13 @@ context('rewards - flow', { tags: '@slow' }, function () {
); );
vegaWalletTeardown(); vegaWalletTeardown();
cy.associateTokensToVegaWallet('6000'); cy.associateTokensToVegaWallet('6000');
cy.VegaWalletTopUpRewardsPool(rewardsStartEpoch, rewardsEndEpoch); navigateTo(navigation.validators);
cy.VegaWalletTopUpRewardsPool();
cy.get(vegaWalletUnstakedBalance, txTimeout).should( cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain', 'contain',
'6,000.0', '6,000.0',
txTimeout txTimeout
); );
navigateTo(navigation.validators);
clickOnValidatorFromList(0); clickOnValidatorFromList(0);
stakingValidatorPageAddStake('3000'); stakingValidatorPageAddStake('3000');
closeStakingDialog(); closeStakingDialog();

View File

@ -7,44 +7,54 @@ declare global {
namespace Cypress { namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> { interface Chainable<Subject> {
VegaWalletTopUpRewardsPool( VegaWalletTopUpRewardsPool(): void;
transferStartEpoch: number,
transferEndEpoch: number
): void;
} }
} }
} }
export function addVegaWalletTopUpRewardsPool() { export function addVegaWalletTopUpRewardsPool() {
Cypress.Commands.add( Cypress.Commands.add('VegaWalletTopUpRewardsPool', () => {
'VegaWalletTopUpRewardsPool', let transferStartEpoch = 0;
(transferStartEpoch, transferEndEpoch) => { let transferEndEpoch = 0;
const vegaWalletUrl = Cypress.env('VEGA_WALLET_URL'); const vegaWalletUrl = Cypress.env('VEGA_WALLET_URL');
const token = Cypress.env('VEGA_WALLET_API_TOKEN'); const token = Cypress.env('VEGA_WALLET_API_TOKEN');
const vegaPubKey = Cypress.env('VEGA_PUBLIC_KEY'); const vegaPubKey = Cypress.env('VEGA_PUBLIC_KEY');
const assetAddress = const assetAddress =
'b4f2726571fbe8e33b442dc92ed2d7f0d810e21835b7371a7915a365f07ccd9b'; 'b4f2726571fbe8e33b442dc92ed2d7f0d810e21835b7371a7915a365f07ccd9b';
createWalletClient(vegaWalletUrl, token); cy.getByTestId('epoch-countdown')
.within(() => {
cy.get('h3')
.invoke('text')
.then((epochText) => {
transferStartEpoch = Number(epochText.replace('Epoch', '')) + 5;
transferEndEpoch = transferStartEpoch + 100;
const transactionBody: TransferBody = { console.log(transferStartEpoch);
transfer: { console.log(transferEndEpoch);
fromAccountType: AccountType.ACCOUNT_TYPE_GENERAL, });
toAccountType: AccountType.ACCOUNT_TYPE_GLOBAL_REWARD, })
to: '0000000000000000000000000000000000000000000000000000000000000000', .then(() => {
asset: assetAddress, createWalletClient(vegaWalletUrl, token);
amount: '1000000000000000000',
recurring: { const transactionBody: TransferBody = {
factor: '1', transfer: {
startEpoch: transferStartEpoch, fromAccountType: AccountType.ACCOUNT_TYPE_GENERAL,
endEpoch: transferEndEpoch, toAccountType: AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
to: '0000000000000000000000000000000000000000000000000000000000000000',
asset: assetAddress,
amount: '1000000000000000000',
recurring: {
factor: '1',
startEpoch: transferStartEpoch,
endEpoch: transferEndEpoch,
},
}, },
}, };
};
cy.highlight('Topping up rewards pool'); cy.highlight('Topping up rewards pool');
sendVegaTx(vegaPubKey, transactionBody); sendVegaTx(vegaPubKey, transactionBody);
} });
); });
} }