chore(governance): 3929 proposal acs (#4008)

This commit is contained in:
Joe Tsang 2023-05-31 17:10:41 +01:00 committed by GitHub
parent f2c70e6da4
commit 9f63fde123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 332 additions and 180 deletions

2
.gitignore vendored
View File

@ -50,3 +50,5 @@ cypress.env.json
#cypress #cypress
/apps/**/cypress/reports/ /apps/**/cypress/reports/
/apps/**/cypress/downloads/
/apps/**/fixtures/wallet/node**

View File

@ -26,6 +26,7 @@ module.exports = defineConfig({
viewportWidth: 1440, viewportWidth: 1440,
viewportHeight: 900, viewportHeight: 900,
numTestsKeptInMemory: 5, numTestsKeptInMemory: 5,
downloadsFolder: 'cypress/downloads',
testIsolation: false, testIsolation: false,
}, },
env: { env: {

View File

@ -80,8 +80,18 @@ describe(
.find('p') .find('p')
.should('have.text', proposalDescription); .should('have.text', proposalDescription);
}); });
// 3001-VOTE-008
getProposalInformationFromTable('ID')
.invoke('text')
.should('not.be.empty')
.and('have.length', 64);
// 3001-VOTE-009
getProposalInformationFromTable('Proposed by')
.invoke('text')
.should('not.be.empty')
.and('have.length', 64);
cy.getByTestId(proposalTermsToggle).click(); cy.getByTestId(proposalTermsToggle).click();
// 3001-VOTE-052 // 3001-VOTE-052 3001-VOTE-010
cy.get('code.language-json') cy.get('code.language-json')
.should('exist') .should('exist')
.within(() => { .within(() => {

View File

@ -11,7 +11,6 @@ import {
governanceProposalType, governanceProposalType,
submitUniqueRawProposal, submitUniqueRawProposal,
voteForProposal, voteForProposal,
waitForProposalSubmitted,
waitForProposalSync, waitForProposalSync,
} from '../../support/governance.functions'; } from '../../support/governance.functions';
@ -46,11 +45,7 @@ const connectToVegaWalletButton = '[data-testid="connect-to-vega-wallet-btn"]';
const newProposalSubmitButton = '[data-testid="proposal-submit"]'; const newProposalSubmitButton = '[data-testid="proposal-submit"]';
const viewProposalButton = '[data-testid="view-proposal-btn"]'; const viewProposalButton = '[data-testid="view-proposal-btn"]';
const rawProposalData = '[data-testid="proposal-data"]'; const rawProposalData = '[data-testid="proposal-data"]';
const minVoteButton = '[data-testid="min-vote"]';
const maxVoteButton = '[data-testid="max-vote"]';
const voteButtons = '[data-testid="vote-buttons"]'; const voteButtons = '[data-testid="vote-buttons"]';
const votingDate = '[data-testid="voting-date"]';
const voteTwoMinExtraNote = '[data-testid="voting-2-mins-extra"]';
const rejectProposalsLink = '[href="/proposals/rejected"]'; const rejectProposalsLink = '[href="/proposals/rejected"]';
const feedbackError = '[data-testid="Error"]'; const feedbackError = '[data-testid="Error"]';
const noOpenProposals = '[data-testid="no-open-proposals"]'; const noOpenProposals = '[data-testid="no-open-proposals"]';
@ -106,8 +101,7 @@ context(
.and('have.text', 'There are no enacted or rejected proposals'); .and('have.text', 'There are no enacted or rejected proposals');
}); });
// 3002-PROP-002 // 3002-PROP-002 3002-PROP-003 3001-VOTE-012 3007-PNE-020 3004-PMAC-004 3005-PASN-004 3008-PFRO-016 3003-PMAN-004
// 3002-PROP-003
it('Proposal form - shows how many vega tokens are required to make a proposal', function () { it('Proposal form - shows how many vega tokens are required to make a proposal', function () {
// 3002-PROP-005 // 3002-PROP-005
goToMakeNewProposal(governanceProposalType.NEW_MARKET); goToMakeNewProposal(governanceProposalType.NEW_MARKET);
@ -116,23 +110,14 @@ context(
).should('be.visible'); ).should('be.visible');
}); });
// Skipping as currently unable to propose using forms other than raw // 3002-PROP-011 3008-PFRO-005
// 3002-PROP-011 it('Able to submit a valid freeform proposal - with minimum required tokens associated', function () {
it.skip('Able to submit a valid freeform proposal - with minimum required tokens associated', function () { ensureSpecifiedUnstakedTokensAreAssociated('1');
goToMakeNewProposal(governanceProposalType.FREEFORM); verifyUnstakedBalance(1);
cy.get(minVoteButton).should('be.visible'); // 3002-PROP-008 createRawProposal();
cy.get(maxVoteButton).should('be.visible');
cy.get(votingDate).should('not.be.empty');
cy.get(voteTwoMinExtraNote).should(
'contain.text',
'we add 2 minutes of extra time'
);
enterUniqueFreeFormProposalBody('50', generateFreeFormProposalTitle());
// 3002-PROP-012
// 3002-PROP-016
waitForProposalSubmitted();
}); });
// 3008-PFRO-002 3008-PFRO-004
it('Able to submit a valid freeform proposal - with minimum required tokens associated - but also staked', function () { it('Able to submit a valid freeform proposal - with minimum required tokens associated - but also staked', function () {
ensureSpecifiedUnstakedTokensAreAssociated('2'); ensureSpecifiedUnstakedTokensAreAssociated('2');
verifyUnstakedBalance(2); verifyUnstakedBalance(2);
@ -148,10 +133,6 @@ context(
it.skip('Creating a proposal - proposal rejected - when closing time sooner than system default', function () { it.skip('Creating a proposal - proposal rejected - when closing time sooner than system default', function () {
goToMakeNewProposal(governanceProposalType.FREEFORM); goToMakeNewProposal(governanceProposalType.FREEFORM);
enterUniqueFreeFormProposalBody('0.1', generateFreeFormProposalTitle()); enterUniqueFreeFormProposalBody('0.1', generateFreeFormProposalTitle());
cy.contains('Awaiting network confirmation', epochTimeout).should(
'not.exist'
);
cy.get('input:invalid') cy.get('input:invalid')
.invoke('prop', 'validationMessage') .invoke('prop', 'validationMessage')
.should('equal', 'Value must be greater than or equal to 1.'); .should('equal', 'Value must be greater than or equal to 1.');
@ -280,6 +261,20 @@ context(
closeDialog(); closeDialog();
}); });
// 3007-PNE-022 3007-PNE-023 3004-PMAC-006 3004-PMAC-007 3005-PASN-006 3005-PASN-007
// 3006-PASC-006 3006-PASC-007 3008-PFRO-018 3008-PFRO-019 3003-PMAN-006 3003-PMAN-007
it('Unable to submit proposal without valid json', function () {
goToMakeNewProposal(governanceProposalType.RAW);
cy.get(newProposalSubmitButton).click();
cy.getByTestId('input-error-text').should('have.text', 'Required');
cy.get(rawProposalData).type('Not a valid json string');
cy.get(newProposalSubmitButton).click();
cy.getByTestId('input-error-text').should(
'have.text',
'Must be valid JSON'
);
});
// 1005-PROP-009 // 1005-PROP-009
it('Unable to vote on a freeform proposal - when some but not enough vega associated', function () { it('Unable to vote on a freeform proposal - when some but not enough vega associated', function () {
const proposalTitle = generateFreeFormProposalTitle(); const proposalTitle = generateFreeFormProposalTitle();

View File

@ -5,12 +5,15 @@ import {
turnTelemetryOff, turnTelemetryOff,
waitForSpinner, waitForSpinner,
} from '../../support/common.functions'; } from '../../support/common.functions';
import {
getDownloadedProposalJsonPath,
submitUniqueRawProposal,
} from '../../support/governance.functions';
import { import {
getProposalInformationFromTable, getProposalInformationFromTable,
goToMakeNewProposal, goToMakeNewProposal,
governanceProposalType, governanceProposalType,
voteForProposal, voteForProposal,
waitForProposalSubmitted,
} from '../../support/governance.functions'; } from '../../support/governance.functions';
import { ensureSpecifiedUnstakedTokensAreAssociated } from '../../support/staking.functions'; import { ensureSpecifiedUnstakedTokensAreAssociated } from '../../support/staking.functions';
import { ethereumWalletConnect } from '../../support/wallet-eth.functions'; import { ethereumWalletConnect } from '../../support/wallet-eth.functions';
@ -26,15 +29,11 @@ const proposalType = '[data-testid="proposal-type"]';
const proposalDetails = '[data-testid="proposal-details"]'; const proposalDetails = '[data-testid="proposal-details"]';
const newProposalSubmitButton = '[data-testid="proposal-submit"]'; const newProposalSubmitButton = '[data-testid="proposal-submit"]';
const proposalVoteDeadline = '[data-testid="proposal-vote-deadline"]'; const proposalVoteDeadline = '[data-testid="proposal-vote-deadline"]';
const proposalValidationDeadline =
'[data-testid="proposal-validation-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"]';
const newProposalDescription = '[data-testid="proposal-description"]'; const newProposalDescription = '[data-testid="proposal-description"]';
const newProposalTerms = '[data-testid="proposal-terms"]'; const newProposalTerms = '[data-testid="proposal-terms"]';
const currentParameterValue =
'[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 minVoteDeadline = '[data-testid="min-vote"]';
@ -54,11 +53,10 @@ const proposalTermsSection = 'proposal';
const vegaWalletPublicKey = Cypress.env('vegaWalletPublicKey'); const vegaWalletPublicKey = Cypress.env('vegaWalletPublicKey');
const fUSDCId = const fUSDCId =
'816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc'; '816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc';
const epochTimeout = Cypress.env('epochTimeout');
const proposalTimeout = { timeout: 14000 }; const proposalTimeout = { timeout: 14000 };
// 3001-VOTE-007 // 3001-VOTE-007
context.skip( context(
'Governance flow - form validations for different governance proposals', 'Governance flow - form validations for different governance proposals',
{ tags: '@slow' }, { tags: '@slow' },
function () { function () {
@ -79,28 +77,10 @@ context.skip(
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
}); });
it('Able to submit valid update network parameter proposal', function () {
goToMakeNewProposal(governanceProposalType.NETWORK_PARAMETER);
// 3002-PROP-006
cy.get(newProposalTitle).type('Test update network parameter proposal');
// 3002-PROP-007
cy.get(newProposalDescription).type('E2E test for proposals');
cy.get(proposalParameterSelect).find('option').should('have.length', 117);
cy.get(proposalParameterSelect).select(
// 3007-PNEC-002
'governance_proposal_asset_minEnact'
);
cy.get(currentParameterValue).should('have.value', '2s');
cy.get(newProposedParameterValue).type('5s'); // 3007-PNEC-003
cy.get(newProposalSubmitButton).should('be.visible').click();
waitForProposalSubmitted();
});
it('Unable to submit network parameter with missing/invalid fields', function () { it('Unable to submit network parameter with missing/invalid fields', function () {
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
goToMakeNewProposal(governanceProposalType.NETWORK_PARAMETER); goToMakeNewProposal(governanceProposalType.NETWORK_PARAMETER);
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(proposalDownloadBtn).click();
cy.get(inputError).should('have.length', 3); cy.get(inputError).should('have.length', 3);
cy.get(newProposalTitle).type( cy.get(newProposalTitle).type(
'Invalid update network parameter proposal' 'Invalid update network parameter proposal'
@ -111,53 +91,64 @@ context.skip(
); );
cy.get(newProposedParameterValue).type('0'); cy.get(newProposedParameterValue).type('0');
cy.get(proposalVoteDeadline).clear().type('0'); cy.get(proposalVoteDeadline).clear().type('0');
cy.get(newProposalSubmitButton).click();
cy.contains('Awaiting network confirmation', epochTimeout).should(
'not.exist'
);
cy.get(proposalVoteDeadline).clear().type('9000');
cy.get(newProposalSubmitButton).click();
cy.contains('Awaiting network confirmation', epochTimeout).should(
'not.exist'
);
});
it('Able to download network param proposal json', function () {
const downloadFolder = './cypress/downloads/';
goToMakeNewProposal(governanceProposalType.NETWORK_PARAMETER);
cy.log('Download proposal file');
cy.get(proposalDownloadBtn) cy.get(proposalDownloadBtn)
.should('be.visible')
.click() .click()
.then(() => { .then(() => {
const filename = cy.wrap(
downloadFolder + getDownloadedProposalJsonPath('vega-network-param-proposal-')
'vega-network-param-proposal-' + ).then((filePath) => {
getFormattedTime() + goToMakeNewProposal(governanceProposalType.RAW);
'.json'; submitUniqueRawProposal({ proposalBody: filePath, submit: false });
cy.readFile(filename, proposalTimeout) });
.its('terms.updateNetworkParameter') cy.get(newProposalSubmitButton).click();
.should('exist'); validateDialogContentMsg('PROPOSAL_ERROR_CLOSE_TIME_TOO_SOON');
});
}); });
// 3007-PNEC-001 3007-PNEC-003
it('Able to download and submit network param proposal', function () {
goToMakeNewProposal(governanceProposalType.NETWORK_PARAMETER);
// 3007-PNEC-006
cy.get(newProposalTitle)
.siblings()
.should('contain.text', '(100 characters or less)');
// 3007-PNEC-004 3007-PNEC-005
cy.get(newProposalTitle).type('Test update network parameter proposal');
// 3007-PNEC-009
cy.get(newProposalDescription)
.siblings()
.should('contain.text', '(20,000 characters or less)');
// 3007-PNEC-007 3007-PNEC-008
cy.get(newProposalDescription).type('E2E test for downloading proposals'); cy.get(newProposalDescription).type('E2E test for downloading proposals');
// 3007-PNEC-010
cy.get(proposalParameterSelect).select( cy.get(proposalParameterSelect).select(
'governance_proposal_asset_minClose' 'governance_proposal_asset_minClose'
); );
// 3007-PNEC-011
cy.get(newProposedParameterValue).type('10s'); cy.get(newProposedParameterValue).type('10s');
// 3007-PNEC-012
cy.get(proposalVoteDeadline).clear().type('2');
// 3007-PNEC-013 3007-PNEC-014
cy.getByTestId('voting-date').invoke('text').should('not.be.empty');
// 3007-PNEC-015
cy.get(maxEnactDeadline).click();
// 3007-PNEC-016
cy.getByTestId('enactment-date').invoke('text').should('not.be.empty');
// 3007-PNEC-017
cy.contains(
'Time till enactment (must be equal to or after vote close)'
).should('be.visible');
// 3007-PNE-018
cy.log('Download updated proposal file'); cy.log('Download updated proposal file');
cy.get(proposalDownloadBtn) cy.get(proposalDownloadBtn)
.should('be.visible') .should('be.visible')
.click() .click()
.then(() => { .then(() => {
const filename = cy.wrap(
downloadFolder + getDownloadedProposalJsonPath('vega-network-param-proposal-')
'vega-network-param-proposal-' + ).then((filePath) => {
getFormattedTime() + cy.readFile(String(filePath), { timeout: 14000 }).then(
'.json'; (jsonFile) => {
cy.get(proposalDownloadBtn).should('be.visible').click();
cy.readFile(filename, proposalTimeout).then((jsonFile) => {
cy.wrap(jsonFile) cy.wrap(jsonFile)
.its('rationale.description') .its('rationale.description')
.should('eq', 'E2E test for downloading proposals'); .should('eq', 'E2E test for downloading proposals');
@ -167,6 +158,11 @@ context.skip(
cy.wrap(jsonFile) cy.wrap(jsonFile)
.its('terms.updateNetworkParameter.changes.value') .its('terms.updateNetworkParameter.changes.value')
.should('eq', '10s'); .should('eq', '10s');
}
);
// 3007-PNE-019
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath });
}); });
}); });
}); });
@ -186,14 +182,17 @@ context.skip(
'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.wrap(
getDownloadedProposalJsonPath('vega-network-param-proposal-')
).then((filePath) => {
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath, submit: false });
});
cy.get(newProposalSubmitButton).click(); cy.get(newProposalSubmitButton).click();
cy.get(feedbackError).should( validateFeedBackMsg(
'have.text',
'Invalid params: proposal_submission.terms.closing_timestamp (cannot be after enactment time)' 'Invalid params: proposal_submission.terms.closing_timestamp (cannot be after enactment time)'
); );
closeDialog();
cy.get(minVoteDeadline).click();
cy.get(enactmentDeadlineError).should('not.exist');
}); });
// 3003-PMAN-001 // 3003-PMAN-001
@ -208,8 +207,13 @@ context.skip(
delay: 2, delay: 2,
}); });
}); });
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(proposalDownloadBtn).should('be.visible').click();
waitForProposalSubmitted(); 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 () {
@ -217,7 +221,7 @@ context.skip(
'Invalid params: the transaction does not use a valid Vega command: unknown field "invalid" in vega.NewMarket'; '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(proposalDownloadBtn).should('be.visible').click();
cy.get(inputError).should('have.length', 3); cy.get(inputError).should('have.length', 3);
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');
@ -229,9 +233,16 @@ context.skip(
delay: 2, delay: 2,
}); });
}); });
cy.get(proposalDownloadBtn).should('be.visible').click();
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');
cy.get(feedbackError).should('have.text', errorMsg); validateFeedBackMsg(errorMsg);
}); });
// Will fail if run after 'Able to submit update market proposal and vote for proposal' // Will fail if run after 'Able to submit update market proposal and vote for proposal'
@ -248,11 +259,16 @@ context.skip(
delay: 2, delay: 2,
}); });
}); });
cy.get(proposalDownloadBtn).should('be.visible').click();
cy.wrap(
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');
cy.getByTestId('dialog-content') validateDialogContentMsg('PROPOSAL_ERROR_INSUFFICIENT_EQUITY_LIKE_SHARE');
.find('p')
.should('have.text', 'PROPOSAL_ERROR_INSUFFICIENT_EQUITY_LIKE_SHARE');
ensureSpecifiedUnstakedTokensAreAssociated('1'); ensureSpecifiedUnstakedTokensAreAssociated('1');
}); });
@ -275,15 +291,21 @@ context.skip(
delay: 2, delay: 2,
}); });
}); });
cy.get(proposalDownloadBtn).should('be.visible').click();
cy.wrap(
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');
cy.get(feedbackError).should( validateFeedBackMsg(
'have.text',
'Network error: the network blocked the transaction through the spam protection: party has insufficient associated governance tokens in their staking account to submit proposal request (ABCI code 89)' 'Network error: the network blocked the transaction through the spam protection: party has insufficient associated governance tokens in their staking account to submit proposal request (ABCI code 89)'
); );
}); });
// 3001-VOTE-092 3004-PMAC-001 // 3001-VOTE-092 3004-PMAC-001 3004-PMAC-003
it('Able to submit update market proposal and vote for proposal', function () { it('Able to submit update market proposal and vote for proposal', function () {
vegaWalletFaucetAssetsWithoutCheck( vegaWalletFaucetAssetsWithoutCheck(
fUSDCId, fUSDCId,
@ -313,11 +335,16 @@ context.skip(
delay: 2, delay: 2,
}); });
}); });
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(proposalDownloadBtn).should('be.visible').click();
waitForProposalSubmitted(); cy.wrap(
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)) cy.contains(String(marketId).slice(0, 6))
.parentsUntil(proposalListItem) .parentsUntil(proposalListItem)
.last() .last()
.within(() => { .within(() => {
@ -341,6 +368,7 @@ context.skip(
'contain.text', 'contain.text',
'Currently expected to pass' 'Currently expected to pass'
); );
cy.getByTestId('vote-breakdown-toggle').click();
getProposalInformationFromTable('Expected to pass') getProposalInformationFromTable('Expected to pass')
.contains('👍 by token vote') .contains('👍 by token vote')
.should('be.visible'); .should('be.visible');
@ -362,25 +390,20 @@ context.skip(
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).should('be.visible').click();
cy.wrap(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();
cy.contains('Awaiting network confirmation', epochTimeout).should(
'be.visible'
);
cy.contains('Proposal waiting for node vote', proposalTimeout).should(
'be.visible'
);
closeDialog(); closeDialog();
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(newProposalSubmitButton).should('be.visible').click();
// cannot submit a proposal with ERC20 address already in use // cannot submit a proposal with ERC20 address already in use
cy.contains('Proposal rejected', proposalTimeout).should('be.visible'); cy.contains('Proposal rejected', proposalTimeout).should('be.visible');
cy.getByTestId('dialog-content') validateDialogContentMsg('PROPOSAL_ERROR_ERC20_ADDRESS_ALREADY_IN_USE');
.last()
.within(() => {
cy.get('p').should(
'have.text',
'PROPOSAL_ERROR_ERC20_ADDRESS_ALREADY_IN_USE'
);
});
closeDialog(); closeDialog();
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
cy.contains(proposalTitle) cy.contains(proposalTitle)
@ -389,6 +412,7 @@ context.skip(
.within(() => { .within(() => {
cy.getByTestId(viewProposalBtn).click(); cy.getByTestId(viewProposalBtn).click();
}); });
cy.getByTestId('proposal-terms-toggle').click();
cy.getByTestId(proposalTermsSection).within(() => { cy.getByTestId(proposalTermsSection).within(() => {
cy.contains('USDT Coin').should('be.visible'); cy.contains('USDT Coin').should('be.visible');
cy.contains('USDT').should('be.visible'); cy.contains('USDT').should('be.visible');
@ -397,15 +421,8 @@ context.skip(
it('Unable to submit new asset proposal with missing/invalid fields', function () { it('Unable to submit new asset proposal with missing/invalid fields', function () {
goToMakeNewProposal(governanceProposalType.NEW_ASSET); goToMakeNewProposal(governanceProposalType.NEW_ASSET);
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(proposalDownloadBtn).should('be.visible').click();
cy.get(inputError).should('have.length', 3); cy.get(inputError).should('have.length', 3);
cy.get(newProposalTitle).type('Invalid new asset proposal');
cy.get(newProposalDescription).type('Invalid E2E test for proposals');
cy.get(proposalValidationDeadline).clear().type('2');
cy.get(newProposalSubmitButton).click();
cy.contains('Awaiting network confirmation', epochTimeout).should(
'not.exist'
);
}); });
it('Able to submit update asset proposal using min deadline', function () { it('Able to submit update asset proposal using min deadline', function () {
@ -416,8 +433,13 @@ context.skip(
enterUpdateAssetProposalDetails(); enterUpdateAssetProposalDetails();
cy.get(minVoteDeadline).click(); cy.get(minVoteDeadline).click();
cy.get(minEnactDeadline).click(); cy.get(minEnactDeadline).click();
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(proposalDownloadBtn).should('be.visible').click();
waitForProposalSubmitted(); cy.wrap(
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)
@ -425,7 +447,7 @@ context.skip(
.parentsUntil(proposalListItem) .parentsUntil(proposalListItem)
.last() .last()
.within(() => { .within(() => {
cy.get(proposalDetails).should('contain.text', assetId); // 3001-VOTE-029 cy.get(proposalDetails).should('contain.text', assetId.slice(0, 6)); // 3001-VOTE-029
cy.getByTestId(viewProposalBtn).click(); cy.getByTestId(viewProposalBtn).click();
}); });
}); });
@ -433,37 +455,86 @@ context.skip(
.invoke('text') .invoke('text')
.should('not.be.empty'); .should('not.be.empty');
// 3001-VOTE-030 3001-VOTE-031 // 3001-VOTE-030 3001-VOTE-031
cy.getByTestId(proposalTermsSection).within(() => { cy.getByTestId('proposal-terms-toggle').click();
cy.contains('UpdateAsset').should('be.visible'); cy.getByTestId('proposal-terms').within(() => {
cy.contains('UpdateERC20').should('be.visible'); getProposalInformationFromTable('assetId').should('have.text', assetId);
cy.contains('"lifetimeLimit": "10"').should('be.visible'); getProposalInformationFromTable('lifetimeLimit').should(
'have.text',
'10'
);
}); });
}); });
// 3006-PASC-001 3006-PASC-003
it('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();
cy.get(maxEnactDeadline).click(); cy.get(maxEnactDeadline).click();
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(proposalDownloadBtn).should('be.visible').click();
waitForProposalSubmitted(); cy.wrap(
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 () {
goToMakeNewProposal(governanceProposalType.UPDATE_ASSET); goToMakeNewProposal(governanceProposalType.UPDATE_ASSET);
cy.get(newProposalSubmitButton).should('be.visible').click(); cy.get(proposalDownloadBtn).should('be.visible').click();
cy.get(inputError).should('have.length', 3); cy.get(inputError).should('have.length', 3);
}); });
function getFormattedTime() { it('Able to download and submit freeform proposal', function () {
const now = new Date(); goToMakeNewProposal(governanceProposalType.FREEFORM);
const day = now.getDate().toString().padStart(2, '0'); // 3008-PFRO-006
const month = now.toLocaleString('en-US', { month: 'short' }); cy.get(newProposalTitle)
const year = now.getFullYear().toString(); .siblings()
const hours = now.getHours().toString().padStart(2, '0'); .should('contain.text', '(100 characters or less)'); // 3008-PFRO-007
const minutes = now.getMinutes().toString().padStart(2, '0'); // 3008-PFRO-005
cy.get(newProposalTitle).type('Test freeform proposal form');
// 3008-PFRO-009
cy.get(newProposalDescription)
.siblings()
.should('contain.text', '(20,000 characters or less)'); // 3008-PFRO-010
// 3008-PFRO-008 3002-PROP-012 3002-PROP-016
cy.get(newProposalDescription).type(
'E2E test for downloading freeform proposal'
);
// 3008-PFRO-012
cy.get(minVoteDeadline).should('exist'); // 3002-PROP-008
cy.get(maxVoteDeadline).should('exist');
// 3008-PFRO-011
cy.get(proposalVoteDeadline).clear().type('2');
// 3008-PFRO-013 3008-PFRO-014
cy.getByTestId('voting-date').invoke('text').should('not.be.empty');
// 3008-PFRO-015
cy.log('Download updated proposal file');
cy.get(proposalDownloadBtn)
.should('be.visible')
.click()
.then(() => {
cy.wrap(
getDownloadedProposalJsonPath('vega-freeform-proposal-')
).then((filePath) => {
// 3008-PFRO-019
goToMakeNewProposal(governanceProposalType.RAW);
submitUniqueRawProposal({ proposalBody: filePath });
});
});
});
return `${day}-${month}-${year}-${hours}-${minutes}`; function validateDialogContentMsg(expectedMsg: string) {
cy.getByTestId('dialog-content')
.last()
.within(() => {
cy.get('p').should('have.text', expectedMsg);
});
}
function validateFeedBackMsg(expectedMsg: string) {
cy.get(feedbackError).should('have.text', expectedMsg);
} }
function enterUpdateAssetProposalDetails() { function enterUpdateAssetProposalDetails() {

View File

@ -11,7 +11,6 @@ import {
import { mockNetworkUpgradeProposal } from '../../support/proposal.functions'; import { mockNetworkUpgradeProposal } from '../../support/proposal.functions';
const proposalDocumentationLink = '[data-testid="proposal-documentation-link"]'; const proposalDocumentationLink = '[data-testid="proposal-documentation-link"]';
const newProposalLink = '[data-testid="new-proposal-link"]';
const governanceDocsUrl = 'https://vega.xyz/governance'; const governanceDocsUrl = 'https://vega.xyz/governance';
const connectToVegaWalletButton = '[data-testid="connect-to-vega-wallet-btn"]'; const connectToVegaWalletButton = '[data-testid="connect-to-vega-wallet-btn"]';
@ -32,6 +31,14 @@ context(
verifyPageHeader('Proposals'); verifyPageHeader('Proposals');
}); });
// 3002-PROP-023 3004-PMAC-002 3005-PASN-002 3006-PASC-002 3007-PNEC-002 3008-PFRO-003
it('should have button for link to more information on proposals', function () {
const proposalsUrl = 'https://docs.vega.xyz/mainnet/tutorials/proposals';
cy.getByTestId('new-proposal-link')
.find('a')
.should('have.attr', 'href', proposalsUrl);
});
it('should be able to see a working link for - find out more about Vega governance', function () { it('should be able to see a working link for - find out more about Vega governance', function () {
// 3001-VOTE-001 // 3001-VOTE-001
cy.get(proposalDocumentationLink) cy.get(proposalDocumentationLink)
@ -54,17 +61,62 @@ context(
}); });
}); });
it.skip('should be able to see button for - new proposal', function () { // 3007-PNE-021
// 3001-VOTE-002 it('should have documentation links for network parameter proposal', function () {
cy.get(newProposalLink) goToMakeNewProposal(governanceProposalType.NETWORK_PARAMETER);
.should('be.visible') cy.getByTestId('proposal-docs-link')
.and('have.text', 'New proposal') .find('a')
.and('have.attr', 'href') .should('have.attr', 'href')
.and('equal', '/proposals/propose'); .and('contain', '/tutorials/proposals/network-parameter-proposal');
}); });
it.skip('should be able to see a connect wallet button - if vega wallet disconnected and user is submitting new proposal', function () { // 3003-PMAN-002 3003-PMAN-005
goToMakeNewProposal(governanceProposalType.NETWORK_PARAMETER); it('should have documentation links for new market proposal', function () {
goToMakeNewProposal(governanceProposalType.NEW_MARKET);
cy.getByTestId('proposal-docs-link')
.find('a')
.should('have.attr', 'href')
.and('contain', '/tutorials/proposals/new-market-proposal');
});
// 3004-PMAC-005
it('should have documentation links for update market proposal', function () {
goToMakeNewProposal(governanceProposalType.UPDATE_MARKET);
cy.getByTestId('proposal-docs-link')
.find('a')
.should('have.attr', 'href')
.and('contain', '/tutorials/proposals/update-market-proposal');
});
// 3005-PASN-002 005-PASN-005
it('should have documentation links for new asset proposal', function () {
goToMakeNewProposal(governanceProposalType.NEW_ASSET);
cy.getByTestId('proposal-docs-link')
.find('a')
.should('have.attr', 'href')
.and('contain', '/tutorials/proposals/new-asset-proposal');
});
// 3006-PASC-002 3006-PASC-005
it('should have documentation links for update asset proposal', function () {
goToMakeNewProposal(governanceProposalType.UPDATE_ASSET);
cy.getByTestId('proposal-docs-link')
.find('a')
.should('have.attr', 'href')
.and('contain', '/tutorials/proposals/update-asset-proposal');
});
// 3008-PFRO-003 3008-PFRO-017
it('should have documentation links for freeform proposal', function () {
goToMakeNewProposal(governanceProposalType.FREEFORM);
cy.getByTestId('proposal-docs-link')
.find('a')
.should('have.attr', 'href')
.and('contain', '/tutorials/proposals/freeform-proposal');
});
it('should be able to see a connect wallet button - if vega wallet disconnected and user is submitting new proposal', function () {
goToMakeNewProposal(governanceProposalType.RAW);
cy.get(connectToVegaWalletButton) cy.get(connectToVegaWalletButton)
.should('be.visible') .should('be.visible')
.and('have.text', 'Connect Vega wallet'); .and('have.text', 'Connect Vega wallet');

View File

@ -63,7 +63,8 @@ export function submitUniqueRawProposal(proposalFields: {
if (proposalFields.proposalBody) { if (proposalFields.proposalBody) {
proposalBodyPath = proposalFields.proposalBody; proposalBodyPath = proposalFields.proposalBody;
} }
cy.fixture(proposalBodyPath).then((rawProposal) => { cy.readFile(proposalBodyPath).then((rawProposal) => {
if (!proposalFields.proposalBody) {
if (proposalFields.proposalTitle) { if (proposalFields.proposalTitle) {
rawProposal.rationale.title = proposalFields.proposalTitle; rawProposal.rationale.title = proposalFields.proposalTitle;
cy.wrap(proposalFields.proposalTitle).as('proposalTitle'); cy.wrap(proposalFields.proposalTitle).as('proposalTitle');
@ -78,7 +79,9 @@ export function submitUniqueRawProposal(proposalFields: {
rawProposal.terms.closingTimestamp = minTimeStamp; rawProposal.terms.closingTimestamp = minTimeStamp;
} }
if (proposalFields.enactmentTimestamp) { if (proposalFields.enactmentTimestamp) {
rawProposal.terms.enactmentTimestamp = proposalFields.enactmentTimestamp; rawProposal.terms.enactmentTimestamp =
proposalFields.enactmentTimestamp;
}
} }
const proposalPayload = JSON.stringify(rawProposal); const proposalPayload = JSON.stringify(rawProposal);
@ -106,7 +109,7 @@ export function enterUniqueFreeFormProposalBody(
'this is a e2e freeform proposal description' 'this is a e2e freeform proposal description'
); );
cy.get(proposalVoteDeadline).clear().click().type(timestamp); cy.get(proposalVoteDeadline).clear().click().type(timestamp);
cy.getByTestId('proposal-submit').should('be.visible').click(); cy.getByTestId('proposal-download-json').should('be.visible').click();
} }
export function getProposalFromTitle(proposalTitle: string) { export function getProposalFromTitle(proposalTitle: string) {
@ -188,6 +191,7 @@ export function goToMakeNewProposal(proposalType: governanceProposalType) {
} }
} }
// 3001-VOTE-013 3001-VOTE-014
export function waitForProposalSubmitted() { export function waitForProposalSubmitted() {
cy.contains('Awaiting network confirmation', epochTimeout).should( cy.contains('Awaiting network confirmation', epochTimeout).should(
'be.visible' 'be.visible'
@ -222,6 +226,23 @@ export function createFreeformProposal(proposalTitle: string) {
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
} }
export function getDownloadedProposalJsonPath(proposalType: string) {
const downloadPath = './cypress/downloads/';
const filepath = downloadPath + proposalType + getFormattedTime() + '.json';
return filepath;
}
function getFormattedTime() {
const now = new Date();
const day = now.getDate().toString().padStart(2, '0');
const month = now.toLocaleString('en-US', { month: 'short' });
const year = now.getFullYear().toString();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
return `${day}-${month}-${year}-${hours}-${minutes}`;
}
export enum governanceProposalType { export enum governanceProposalType {
NETWORK_PARAMETER = 'Network parameter', NETWORK_PARAMETER = 'Network parameter',
NEW_MARKET = 'New market', NEW_MARKET = 'New market',