Test/governance update (#1838)

* test: unskip test

* chore: add ac for 3001-VOTE-052

* test: tests for min/max deadlines

* chore: lint

* chore: use network param for min voter number
This commit is contained in:
Joe Tsang 2022-10-26 17:13:52 +01:00 committed by GitHub
parent 05ab49cb4c
commit 51deb0b718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 20 deletions

View File

@ -61,7 +61,7 @@ context(
cy.verify_page_header('The $VEGA token'); cy.verify_page_header('The $VEGA token');
cy.get_network_parameters().then((network_parameters) => { cy.get_network_parameters().then((network_parameters) => {
cy.wrap( cy.wrap(
network_parameters['spam.protection.voting.min.tokens'] / network_parameters['spam.protection.proposal.min.tokens'] /
1000000000000000000 1000000000000000000
).as('minProposerBalance'); ).as('minProposerBalance');
cy.wrap( cy.wrap(
@ -115,6 +115,11 @@ context(
0.00001, 0.00001,
'Asserting that value is at least 0.00001 for network parameter minProposerBalance' 'Asserting that value is at least 0.00001 for network parameter minProposerBalance'
); );
assert.isAtLeast(
parseInt(this.minVoterBalance),
0.00001,
'Asserting that value is at least 0.00001 for network parameter minVoterBalance'
);
assert.isAtLeast( assert.isAtLeast(
parseFloat(this.requiredParticipation), parseFloat(this.requiredParticipation),
0.00001, 0.00001,
@ -227,6 +232,7 @@ context(
// 3001-VOTE-008 // 3001-VOTE-008
// 3001-VOTE-034 // 3001-VOTE-034
cy.get(`#${proposalId}`) cy.get(`#${proposalId}`)
// 3001-VOTE-097
.should('contain', rawProposal.rationale.title) .should('contain', rawProposal.rationale.title)
.and('be.visible'); .and('be.visible');
cy.get(`#${proposalId}`) cy.get(`#${proposalId}`)
@ -363,6 +369,14 @@ context(
.should('contain', rawProposal.rationale.description) .should('contain', rawProposal.rationale.description)
.and('be.visible'); .and('be.visible');
}); });
// 3001-VOTE-052
cy.get('code.language-json')
.should('exist')
.within(() => {
cy.get('.hljs-string')
.eq(0)
.should('have.text', '"ProposalTerms"');
});
}); });
}); });
@ -717,9 +731,8 @@ context(
); );
}); });
// Have to skip because #1326 bug doesn't handle below scenario // 1005-PROP-009
// 1005-todo-PROP-009 it('Unable to vote on a freeform proposal - when some but not enough vega associated', function () {
it.skip('Unable to vote on a freeform proposal - when some but not enough vega associated', function () {
cy.ensure_specified_unstaked_tokens_are_associated( cy.ensure_specified_unstaked_tokens_are_associated(
this.minProposerBalance this.minProposerBalance
); );
@ -741,8 +754,11 @@ context(
.as('submittedProposal') .as('submittedProposal')
.within(() => cy.get(viewProposalButton).click()); .within(() => cy.get(viewProposalButton).click());
cy.contains('Vote breakdown').should('be.visible', { timeout: 10000 }); cy.contains('Vote breakdown').should('be.visible', { timeout: 10000 });
cy.get(voteButtons).contains('for').should('not.exist'); cy.get(voteButtons).should('not.exist');
cy.get(voteButtons).contains('against').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 () { it('Unable to vote on a proposal - when vega wallet disconnected - option to connect from within', function () {

View File

@ -2,7 +2,6 @@ const newProposalSubmitButton = '[data-testid="proposal-submit"]';
const proposalVoteDeadline = '[data-testid="proposal-vote-deadline"]'; const proposalVoteDeadline = '[data-testid="proposal-vote-deadline"]';
const proposalValidationDeadline = const proposalValidationDeadline =
'[data-testid="proposal-validation-deadline"]'; '[data-testid="proposal-validation-deadline"]';
const proposalEnactmentDeadline = '[data-testid="proposal-enactment-deadline"]';
const proposalParameterSelect = '[data-testid="proposal-parameter-select"]'; const proposalParameterSelect = '[data-testid="proposal-parameter-select"]';
const proposalMarketSelect = '[data-testid="proposal-market-select"]'; const proposalMarketSelect = '[data-testid="proposal-market-select"]';
const newProposalTitle = '[data-testid="proposal-title"]'; const newProposalTitle = '[data-testid="proposal-title"]';
@ -12,6 +11,11 @@ const currentParameterValue =
'[data-testid="selected-proposal-param-current-value"]'; '[data-testid="selected-proposal-param-current-value"]';
const newProposedParameterValue = const newProposedParameterValue =
'[data-testid="selected-proposal-param-new-value"]'; '[data-testid="selected-proposal-param-new-value"]';
const minVoteDeadline = '[data-testid="min-vote"]';
const maxVoteDeadline = '[data-testid="max-vote"]';
const minValidationDeadline = '[data-testid="min-validation"]';
const minEnactDeadline = '[data-testid="min-enactment"]';
const maxEnactDeadline = '[data-testid="max-enactment"]';
const dialogCloseButton = '[data-testid="dialog-close"]'; const dialogCloseButton = '[data-testid="dialog-close"]';
const inputError = '[data-testid="input-error-text"]'; const inputError = '[data-testid="input-error-text"]';
const feedbackError = '[data-testid="Error"]'; const feedbackError = '[data-testid="Error"]';
@ -163,7 +167,7 @@ context(
}); });
// 3001-VOTE-026 3001-VOTE-027 3001-VOTE-028 3001-VOTE-095 3001-VOTE-096 3005-PASN-001 // 3001-VOTE-026 3001-VOTE-027 3001-VOTE-028 3001-VOTE-095 3001-VOTE-096 3005-PASN-001
it('Able to submit new asset proposal', function () { it('Able to submit new asset proposal using min deadlines', function () {
cy.go_to_make_new_proposal(governanceProposalType.NEW_ASSET); cy.go_to_make_new_proposal(governanceProposalType.NEW_ASSET);
cy.get(newProposalTitle).type('Test new asset proposal'); cy.get(newProposalTitle).type('Test new asset proposal');
cy.get(newProposalDescription).type('E2E test for proposals'); cy.get(newProposalDescription).type('E2E test for proposals');
@ -174,6 +178,9 @@ context(
delay: 2, delay: 2,
}); });
}); });
cy.get(minVoteDeadline).click();
cy.get(minValidationDeadline).click();
cy.get(minEnactDeadline).click();
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
cy.contains('Awaiting network confirmation', epochTimeout).should( cy.contains('Awaiting network confirmation', epochTimeout).should(
'be.visible' 'be.visible'
@ -206,19 +213,21 @@ context(
); );
}); });
it('Able to submit update asset proposal', function () { it('Able to submit update asset proposal using min deadline', function () {
cy.go_to_make_new_proposal(governanceProposalType.UPDATE_ASSET); cy.go_to_make_new_proposal(governanceProposalType.UPDATE_ASSET);
cy.get(newProposalTitle).type('Test update asset proposal'); enterUpdateAssetProposalDetails();
cy.get(newProposalDescription).type('E2E test for proposals'); cy.get(minVoteDeadline).click();
cy.fixture('/proposals/update-asset').then((newAssetProposal) => { cy.get(minEnactDeadline).click();
let newAssetPayload = JSON.stringify(newAssetProposal); cy.get(newProposalSubmitButton).should('be.visible').click();
cy.get(newProposalTerms).type(newAssetPayload, { cy.wait_for_proposal_submitted();
parseSpecialCharSequences: false,
delay: 2,
}); });
});
cy.get(proposalVoteDeadline).clear().click().type('50'); // Skipping until #1837 is fixed
cy.get(proposalEnactmentDeadline).clear().click().type('50'); it.skip('Able to submit update asset proposal using max deadline', function () {
cy.go_to_make_new_proposal(governanceProposalType.UPDATE_ASSET);
enterUpdateAssetProposalDetails();
cy.get(maxVoteDeadline).click();
cy.get(maxEnactDeadline).click();
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
cy.wait_for_proposal_submitted(); cy.wait_for_proposal_submitted();
}); });
@ -228,5 +237,17 @@ context(
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
cy.get(inputError).should('have.length', 3); cy.get(inputError).should('have.length', 3);
}); });
function enterUpdateAssetProposalDetails() {
cy.get(newProposalTitle).type('Test update asset proposal');
cy.get(newProposalDescription).type('E2E test for proposals');
cy.fixture('/proposals/update-asset').then((newAssetProposal) => {
let newAssetPayload = JSON.stringify(newAssetProposal);
cy.get(newProposalTerms).type(newAssetPayload, {
parseSpecialCharSequences: false,
delay: 2,
});
});
}
} }
); );