test(2229): unhappy path test updates (#2417)

* test: update tests and add workaround

* chore: remove smoke test due to bug

* chore: remove only

* chore: add wallet teardown

* chore: increase wait
This commit is contained in:
Joe Tsang 2022-12-16 10:06:02 +00:00 committed by GitHub
parent bbfef16889
commit 7a56e1695d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 158 additions and 121 deletions

View File

@ -29,7 +29,7 @@ const voteButtons = '[data-testid="vote-buttons"]';
const votingDate = '[data-testid="voting-date"]';
const voteTwoMinExtraNote = '[data-testid="voting-2-mins-extra"]';
const voteStatus = '[data-testid="vote-status"]';
const rejectProposalsLink = '[href="/governance/rejected"]';
const rejectProposalsLink = '[href="/proposals/rejected"]';
const feedbackError = '[data-testid="Error"]';
const noOpenProposals = '[data-testid="no-open-proposals"]';
const noClosedProposals = '[data-testid="no-closed-proposals"]';
@ -123,6 +123,8 @@ context(
parseInt(this.minCloseDays + 1),
'Asserting that network parameter maxCloseDays is at least 1 day higher than minCloseDays'
);
// workaround for first eth tx hanging
associateTokenStartOfTests();
}
);
@ -132,7 +134,6 @@ context(
cy.connectVegaWallet();
cy.ethereum_wallet_connect();
cy.navigate_to('proposals');
cy.wait_for_spinner();
});
it('Should be able to see that no proposals exist', function () {
@ -207,7 +208,6 @@ context(
let arrayOfProposals = [];
cy.navigate_to('proposals');
cy.wait_for_spinner();
cy.get(proposalDetailsTitle)
.each((proposalTitleElement) => {
arrayOfProposals.push(proposalTitleElement.text());
@ -225,14 +225,12 @@ context(
cy.navigate_to_page_if_not_already_loaded('proposals');
cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', '2');
cy.navigate_to('validators');
cy.wait_for_spinner();
cy.click_on_validator_from_list(0);
cy.staking_validator_page_add_stake('2');
cy.get(vegaWalletStakedBalances, txTimeout).should('contain', '2');
cy.navigate_to('proposals');
cy.wait_for_spinner();
cy.go_to_make_new_proposal(governanceProposalType.FREEFORM);
cy.enter_unique_freeform_proposal_body('50', generateProposalTitle());
cy.get(newProposalSubmitButton).should('be.visible').click();
@ -327,7 +325,6 @@ context(
.contains('👍')
.should('be.visible');
cy.navigate_to('proposals');
cy.wait_for_spinner();
cy.get('@submittedProposal').within(() =>
cy.get(voteStatus).should('have.text', 'Participation met')
);
@ -378,7 +375,6 @@ context(
cy.wait_for_proposal_submitted();
cy.wait_for_proposal_sync();
cy.navigate_to('proposals');
cy.wait_for_spinner();
cy.get_submitted_proposal_from_proposal_list(proposalTitle).within(
() => cy.get(viewProposalButton).click()
);
@ -485,7 +481,6 @@ context(
cy.get_proposal_information_from_table('Tokens for proposal')
.should('have.text', parseFloat(this.minProposerBalance).toFixed(2))
.and('be.visible');
cy.wait_for_spinner();
cy.get(changeVoteButton).should('be.visible').click();
cy.vote_for_proposal('against');
cy.get(proposalVoteProgressAgainstPercentage)
@ -611,8 +606,7 @@ context(
cy.get(dialogCloseButton).click();
cy.wait_for_proposal_sync();
cy.navigate_to('proposals');
cy.wait_for_spinner();
cy.get(rejectProposalsLink).click().wait_for_spinner();
cy.get(rejectProposalsLink).click();
cy.get('@rawProposal').then((rawProposal) => {
cy.get_submitted_proposal_from_proposal_list(
rawProposal.rationale.title
@ -650,7 +644,7 @@ context(
cy.contains('Transaction failed', proposalTimeout).should('be.visible');
cy.get(feedbackError).should(
'have.text',
'party has insufficient associated governance tokens in their staking account to submit proposal request'
'Network error: the network blocked the transaction through the spam protection'
);
cy.get(dialogCloseButton).click();
});
@ -669,7 +663,7 @@ context(
cy.contains('Transaction failed', proposalTimeout).should('be.visible');
cy.get(feedbackError).should(
'have.text',
'party has insufficient associated governance tokens in their staking account to submit proposal request'
'Network error: the network blocked the transaction through the spam protection'
);
cy.get(dialogCloseButton).click();
});
@ -698,7 +692,7 @@ context(
cy.contains('Transaction failed', proposalTimeout).should('be.visible');
cy.get(feedbackError).should(
'have.text',
'*: unknown field "unexpected" in vega.commands.v1.ProposalSubmission'
'Invalid params: the transaction is malformed'
);
cy.get(dialogCloseButton).click();
});
@ -728,48 +722,50 @@ context(
cy.contains('Transaction failed', proposalTimeout).should('be.visible');
cy.get(feedbackError).should(
'have.text',
'*: unknown field "unexpectedField" in vega.ProposalTerms'
'Invalid params: the transaction is malformed'
);
cy.get(dialogCloseButton).click();
});
// 1005-PROP-009
it('Unable to vote on a freeform proposal - when some but not enough vega associated', function () {
const proposalTitle = generateProposalTitle();
it(
'Unable to vote on a freeform proposal - when some but not enough vega associated',
{ tags: '@smoke' },
function () {
const proposalTitle = generateProposalTitle();
cy.ensure_specified_unstaked_tokens_are_associated(
this.minProposerBalance
);
cy.go_to_make_new_proposal(governanceProposalType.FREEFORM);
cy.enter_unique_freeform_proposal_body('50', proposalTitle);
cy.get(newProposalSubmitButton).should('be.visible').click();
cy.wait_for_proposal_submitted();
cy.wait_for_proposal_sync();
cy.staking_page_disassociate_tokens('0.0001');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'0.9999'
cy.ensure_specified_unstaked_tokens_are_associated(
this.minProposerBalance
);
});
cy.navigate_to('governance');
cy.wait_for_spinner();
cy.get_submitted_proposal_from_proposal_list(proposalTitle).within(() =>
cy.get(viewProposalButton).click()
);
cy.contains('Vote breakdown').should('be.visible', {
timeout: 10000,
});
cy.get(voteButtons).should('not.exist');
cy.getByTestId('min-proposal-requirements').should(
'have.text',
`You must have at least ${this.minVoterBalance} VEGA associated to vote on this proposal`
);
});
cy.go_to_make_new_proposal(governanceProposalType.FREEFORM);
cy.enter_unique_freeform_proposal_body('50', proposalTitle);
cy.get(newProposalSubmitButton).should('be.visible').click();
cy.wait_for_proposal_submitted();
cy.wait_for_proposal_sync();
cy.staking_page_disassociate_tokens('0.0001');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'0.9999'
);
});
cy.navigate_to('proposals');
cy.get_submitted_proposal_from_proposal_list(proposalTitle).within(
() => cy.get(viewProposalButton).click()
);
cy.contains('Vote breakdown').should('be.visible', {
timeout: 10000,
});
cy.get(voteButtons).should('not.exist');
cy.getByTestId('min-proposal-requirements').should(
'have.text',
`You must have at least ${this.minVoterBalance} VEGA associated to vote on this proposal`
);
}
);
it('Unable to vote on a proposal - when vega wallet disconnected - option to connect from within', function () {
createRawProposal(this.minProposerBalance);
cy.wait_for_spinner();
cy.get('[data-testid="manage-vega-wallet"]').click();
cy.get('[data-testid="disconnect"]').click();
cy.get('@rawProposal').then((rawProposal) => {
@ -809,7 +805,6 @@ context(
cy.wait_for_proposal_submitted();
cy.wait_for_proposal_sync();
cy.navigate_to('proposals');
cy.wait_for_spinner();
}
function createFreeformProposal(proposerBalance, proposalTitle) {
@ -821,13 +816,41 @@ context(
cy.wait_for_proposal_sync();
cy.get(proposalDetailsTitle).invoke('text').as('proposalTitle');
cy.navigate_to('proposals');
cy.wait_for_spinner();
}
function generateProposalTitle() {
const randomNum = Math.floor(Math.random() * 1000) + 1;
return randomNum + ': Freeform e2e proposal';
}
// This is a workaround function to begin tests with associating tokens without failing
// Should be removed when eth transaction bug is fixed
function associateTokenStartOfTests() {
cy.highlight(`Associating tokens for first time`);
cy.ethereum_wallet_connect();
cy.connectVegaWallet();
cy.get('[href="/validators/associate"]').first().click();
cy.getByTestId('associate-radio-wallet', { timeout: 30000 }).click();
cy.getByTestId('token-amount-input', epochTimeout).type('1');
cy.getByTestId('token-input-submit-button', txTimeout)
.should('be.enabled')
.click();
cy.contains(
`Associating with Vega key. Waiting for ${Cypress.env(
'blockConfirmations'
)} more confirmations..`,
txTimeout
).should('be.visible');
cy.getByTestId('associated-amount', txTimeout).should(
'contain.text',
'1'
);
// Wait is needed to allow time for transaction to complete
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(10000);
cy.vega_wallet_teardown();
cy.clearLocalStorage();
}
});
}
);

View File

@ -50,7 +50,6 @@ context(
cy.connectVegaWallet();
cy.ethereum_wallet_connect();
cy.navigate_to('proposals');
cy.wait_for_spinner();
});
it('Able to submit valid update network parameter proposal', function () {
@ -61,7 +60,7 @@ context(
// 3002-PROP-007
cy.get(newProposalDescription).type('E2E test for proposals');
cy.get(proposalParameterSelect).find('option').should('have.length', 109);
cy.get(proposalParameterSelect).find('option').should('have.length', 114);
cy.get(proposalParameterSelect).select(
// 3007-PNEC-002
'governance_proposal_asset_minEnact'

View File

@ -46,7 +46,6 @@ context(
cy.ethereum_wallet_connect();
cy.vega_wallet_teardown();
cy.navigate_to('validators');
cy.wait_for_spinner();
}
);
@ -97,7 +96,11 @@ context(
cy.navigate_to('validators');
// 2002-SINC-007
cy.validate_validator_list_total_stake_and_share('0', '2.00', '100%');
cy.validate_validator_list_total_stake_and_share(
'0',
'2.00',
'100.00%'
);
});
it('Able to stake against a validator - using vega from vesting contract', function () {
@ -144,7 +147,11 @@ context(
cy.navigate_to('validators');
cy.validate_validator_list_total_stake_and_share('0', '2.00', '100%');
cy.validate_validator_list_total_stake_and_share(
'0',
'2.00',
'100.00%'
);
});
it('Able to stake against a validator - using vega from both wallet and vesting contract', function () {
@ -204,7 +211,11 @@ context(
cy.navigate_to('validators');
cy.validate_validator_list_total_stake_and_share('0', '6.00', '100%');
cy.validate_validator_list_total_stake_and_share(
'0',
'6.00',
'100.00%'
);
});
it('Able to stake against multiple validators', function () {
@ -254,7 +265,6 @@ context(
.should('contain', 1.0, txTimeout);
cy.navigate_to('validators');
cy.wait_for_spinner();
cy.get(`[row-id="${0}"]`).within(() => {
cy.get(stakeValidatorListTotalStake)
@ -285,68 +295,76 @@ context(
});
// 2001-STKE-041
it('Able to remove part of a stake against a validator', function () {
cy.staking_page_associate_tokens('4');
it(
'Able to remove part of a stake against a validator',
{ tags: '@smoke' },
function () {
cy.staking_page_associate_tokens('4');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
4.0,
txTimeout
);
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
4.0,
txTimeout
);
cy.get('button').contains('Select a validator to nominate').click();
cy.get('button').contains('Select a validator to nominate').click();
cy.click_on_validator_from_list(0);
cy.click_on_validator_from_list(0);
cy.staking_validator_page_add_stake('3');
cy.staking_validator_page_add_stake('3');
cy.get(stakeNextEpochValue, epochTimeout)
.contains(3.0, epochTimeout)
.should('be.visible');
cy.get(stakeNextEpochValue, epochTimeout)
.contains(3.0, epochTimeout)
.should('be.visible');
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
);
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
1.0,
txTimeout
);
cy.navigate_to('validators');
// 2001-STKE-040
cy.click_on_validator_from_list(0);
cy.navigate_to('validators');
// 2001-STKE-040
cy.click_on_validator_from_list(0);
// 2001-STKE-044, 2001-STKE-048
cy.staking_validator_page_remove_stake('1');
// 2001-STKE-044, 2001-STKE-048
cy.staking_validator_page_remove_stake('1');
// 2001-STKE-049
cy.get(stakeNextEpochValue, epochTimeout).contains(2.0, epochTimeout);
// 2001-STKE-049
cy.get(stakeNextEpochValue, epochTimeout).contains(2.0, epochTimeout);
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
2.0,
txTimeout
);
cy.get(vegaWalletUnstakedBalance, txTimeout).should(
'contain',
2.0,
txTimeout
);
cy.get(vegaWalletStakedBalances, txTimeout).should(
'contain',
2.0,
txTimeout
);
cy.get(vegaWalletStakedBalances, txTimeout).should(
'contain',
2.0,
txTimeout
);
cy.get(stakeNextEpochValue, epochTimeout)
.contains(2.0, epochTimeout)
.should('be.visible');
cy.get(stakeNextEpochValue, epochTimeout)
.contains(2.0, epochTimeout)
.should('be.visible');
cy.get(stakeThisEpochValue, epochTimeout)
.contains(2.0, epochTimeout)
.should('be.visible');
cy.get(stakeThisEpochValue, epochTimeout)
.contains(2.0, epochTimeout)
.should('be.visible');
cy.get(totalStake, epochTimeout).should('contain.text', '2');
cy.get(stakeShare, epochTimeout).should('have.text', '100%');
cy.get(totalStake, epochTimeout).should('contain.text', '2');
cy.get(stakeShare, epochTimeout).should('have.text', '100%');
cy.navigate_to('validators');
cy.navigate_to('validators');
cy.validate_validator_list_total_stake_and_share('0', '2.00', '100%');
});
cy.validate_validator_list_total_stake_and_share(
'0',
'2.00',
'100.00%'
);
}
);
// 2001-STKE-045
it('Able to remove a full stake against a validator', function () {
@ -401,7 +419,7 @@ context(
cy.navigate_to('validators');
cy.validate_validator_list_total_stake_and_share('0', '0.00', '0%');
cy.validate_validator_list_total_stake_and_share('0', '0.00', '0.00%');
});
it('Unable to remove a stake with a negative value for a validator', function () {
@ -538,7 +556,7 @@ context(
cy.navigate_to('validators');
cy.validate_validator_list_total_stake_and_share('0', '0.00', '0%');
cy.validate_validator_list_total_stake_and_share('0', '0.00', '0.00%');
});
it('Disassociating all vesting contract tokens max - removes all staked tokens', function () {
@ -592,7 +610,7 @@ context(
cy.navigate_to('validators');
cy.validate_validator_list_total_stake_and_share('0', '0.00', '0%');
cy.validate_validator_list_total_stake_and_share('0', '0.00', '0.00%');
});
it('Disassociating some tokens - prioritizes unstaked tokens', function () {
@ -639,7 +657,11 @@ context(
cy.navigate_to('validators');
cy.validate_validator_list_total_stake_and_share('0', '2.00', '100%');
cy.validate_validator_list_total_stake_and_share(
'0',
'2.00',
'100.00%'
);
});
it('Associating wallet tokens - when some already staked - auto stakes tokens to staked validator', function () {

View File

@ -15,8 +15,8 @@ const ethWalletDissociateButton = '[href="/validators/disassociate"]';
const vestingContractSection = '[data-testid="vega-in-vesting-contract"]';
const vegaInWalletSection = '[data-testid="vega-in-wallet"]';
const connectedVegaKey = '[data-testid="connected-vega-key"]';
const associatedKey = '[data-test-id="associated-key"]';
const associatedAmount = '[data-test-id="associated-amount"]';
const associatedKey = '[data-testid="associated-key"]';
const associatedAmount = '[data-testid="associated-amount"]';
const associateCompleteText = '[data-testid="transaction-complete-body"]';
const disassociationWarning = '[data-testid="disassociation-warning"]';
const vegaWallet = '[data-testid="vega-wallet"]';
@ -41,7 +41,6 @@ context(
cy.ethereum_wallet_connect();
cy.vega_wallet_teardown();
cy.navigate_to('validators');
cy.wait_for_spinner();
}
);

View File

@ -34,7 +34,6 @@ context(
cy.reload();
cy.visit('/');
cy.navigate_to('withdraw');
cy.wait_for_spinner();
cy.connectVegaWallet();
cy.ethereum_wallet_connect();
cy.vega_wallet_teardown();

View File

@ -100,7 +100,7 @@ context('Staking Page - verify elements on page', function () {
// 2001-STKE-050
describe(
'Should be able to see static information about a validator',
{ tags: '@slow' },
{ tags: '@smoke' },
function () {
before('connect wallets and click on validator', function () {
cy.connectVegaWallet();

View File

@ -299,7 +299,7 @@ context(
});
// 2002-SINC-016
describe.skip('when assets exist in vegawallet', function () {
describe('when assets exist in vegawallet', function () {
before('send-faucet assets to connected vega wallet', function () {
cy.vega_wallet_faucet_assets_without_check(
faucetAssets.USDCFake,

View File

@ -34,5 +34,6 @@ Cypress.Commands.add('verify_page_header', (text) => {
});
Cypress.Commands.add('wait_for_spinner', () => {
cy.get(navigation.pageSpinner).should('exist');
cy.get(navigation.pageSpinner, { timeout: 20000 }).should('not.exist');
});

View File

@ -154,7 +154,6 @@ Cypress.Commands.add('navigate_to_page_if_not_already_loaded', (section) => {
cy.url().then((url) => {
if (url != `http://localhost:4210/${section}`) {
cy.navigate_to(section);
cy.wait_for_spinner();
}
});
});
@ -175,7 +174,6 @@ Cypress.Commands.add('go_to_make_new_proposal', (proposalType) => {
cy.navigate_to_page_if_not_already_loaded('proposals');
cy.get(newProposalButton).should('be.visible').click();
cy.url().should('include', '/proposals/propose');
cy.wait_for_spinner();
cy.get('li').contains(proposalType).click();
});

View File

@ -31,7 +31,6 @@ Cypress.Commands.add('wait_for_beginning_of_epoch', () => {
Cypress.Commands.add('staking_validator_page_add_stake', (stake) => {
cy.highlight(`Adding a stake of ${stake}`);
cy.wait_for_spinner();
cy.get(addStakeRadioButton, epochTimeout).click({ force: true });
cy.get(tokenAmountInputBox).type(stake);
cy.wait_for_beginning_of_epoch();
@ -44,7 +43,6 @@ Cypress.Commands.add('staking_validator_page_add_stake', (stake) => {
Cypress.Commands.add('staking_validator_page_remove_stake', (stake) => {
cy.highlight(`Removing a stake of ${stake}`);
cy.wait_for_spinner();
cy.get(removeStakeRadioButton, epochTimeout).click();
cy.get(tokenAmountInputBox).type(stake);
cy.wait_for_beginning_of_epoch();
@ -83,7 +81,7 @@ Cypress.Commands.add('staking_page_associate_tokens', (amount, options) => {
`Associating with Vega key. Waiting for ${Cypress.env(
'blockConfirmations'
)} more confirmations..`,
epochTimeout
txTimeout
).should('be.visible');
cy.contains(
'can now participate in governance and nominate a validator',
@ -148,7 +146,6 @@ Cypress.Commands.add(
Cypress.Commands.add(
'click_on_validator_from_list',
(validatorNumber, validatorName = null) => {
cy.wait_for_spinner();
cy.contains('Loading...', epochTimeout).should('not.exist');
cy.wait_for_beginning_of_epoch();
// below is to ensure validator list is shown
@ -171,7 +168,6 @@ Cypress.Commands.add(
Cypress.Commands.add(
'validate_validator_list_total_stake_and_share',
(positionOnList, expectedTotalStake, expectedTotalShare) => {
cy.wait_for_spinner();
cy.contains('Loading...', epochTimeout).should('not.exist');
cy.wait_for_beginning_of_epoch();
cy.get(`[row-id="${positionOnList}"]`).within(() => {

View File

@ -101,7 +101,7 @@ Cypress.Commands.add('vega_wallet_teardown', function () {
cy.vega_wallet_teardown_staking(this.stakingBridgeContract);
}
});
cy.get('[data-test-id="associated-amount"]', { timeout: 30000 }).should(
cy.get('[data-testid="associated-amount"]', { timeout: 30000 }).should(
'contain.text',
'0.00'
);

View File

@ -66,14 +66,14 @@ export const WalletCardRow = ({
{label}
</Link>
) : (
<span className="max-w-[200px]" data-test-id="associated-key">
<span className="max-w-[200px]" data-testid="associated-key">
{label}
</span>
)}
{value && (
<span
className="font-mono flex-1 text-right"
data-test-id="associated-amount"
data-testid="associated-amount"
>
<span>{integers}.</span>
<span>{decimalsPlaces}</span>

View File

@ -60,7 +60,7 @@ export const Tranche = () => {
/>
<div
className="flex justify-between gap-x-4 py-2 px-4"
data-test-id="redeemed-tranche-tokens"
data-testid="redeemed-tranche-tokens"
>
<span>{t('alreadyRedeemed')}</span>
<span className="font-mono">{formatNumber(tranche.total_removed)}</span>