test(explorer): add e2e test for asset proposal on explorer (#4616)
This commit is contained in:
parent
570472b739
commit
927e21b045
26
apps/explorer-e2e/src/fixtures/mocks/new-asset-proposal.json
Normal file
26
apps/explorer-e2e/src/fixtures/mocks/new-asset-proposal.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"proposalSubmission": {
|
||||||
|
"rationale": {
|
||||||
|
"title": "Test new asset proposal",
|
||||||
|
"description": "E2E test for proposals"
|
||||||
|
},
|
||||||
|
"terms": {
|
||||||
|
"newAsset": {
|
||||||
|
"changes": {
|
||||||
|
"name": "USDT Coin",
|
||||||
|
"symbol": "USDT",
|
||||||
|
"decimals": "18",
|
||||||
|
"quantum": "1",
|
||||||
|
"erc20": {
|
||||||
|
"contractAddress": "0xb404c51bbc10dcbe948077f18a4b8e553d160084",
|
||||||
|
"withdrawThreshold": "10",
|
||||||
|
"lifetimeLimit": "10"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"closingTimestamp": 1724339572,
|
||||||
|
"enactmentTimestamp": 1724339572,
|
||||||
|
"validationTimestamp": 1692799617
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,10 @@
|
|||||||
|
import { getNewAssetTxBody } from '../support/governance.functions';
|
||||||
|
|
||||||
context('Proposal page', { tags: '@smoke' }, function () {
|
context('Proposal page', { tags: '@smoke' }, function () {
|
||||||
describe('Verify elements on page', function () {
|
describe('Verify elements on page', function () {
|
||||||
const proposalHeading = 'proposals-heading';
|
const proposalHeading = 'proposals-heading';
|
||||||
const dateTimeRegex =
|
const dateTimeRegex =
|
||||||
/(\d{1,2})\/(\d{1,2})\/(\d{4}), (\d{1,2}):(\d{1,2}):(\d{1,2})/gm;
|
/(\d{1,2})\/(\d{1,2})\/(\d{4}), (\d{1,2}):(\d{1,2}):(\d{1,2})/gm;
|
||||||
const proposalTitle = 'Add Lorem Ipsum market';
|
|
||||||
|
|
||||||
before('Create market proposal', function () {
|
before('Create market proposal', function () {
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
@ -11,6 +12,8 @@ context('Proposal page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Able to view proposal', function () {
|
it('Able to view proposal', function () {
|
||||||
|
const proposalTitle = 'Add Lorem Ipsum market';
|
||||||
|
|
||||||
cy.navigate_to('governanceProposals');
|
cy.navigate_to('governanceProposals');
|
||||||
cy.getByTestId(proposalHeading).should('be.visible');
|
cy.getByTestId(proposalHeading).should('be.visible');
|
||||||
cy.contains(proposalTitle)
|
cy.contains(proposalTitle)
|
||||||
@ -22,6 +25,9 @@ context('Proposal page', { tags: '@smoke' }, function () {
|
|||||||
cy.get_element_by_col_id('type').should('have.text', 'NewMarket');
|
cy.get_element_by_col_id('type').should('have.text', 'NewMarket');
|
||||||
cy.get_element_by_col_id('state').should('have.text', 'Enacted');
|
cy.get_element_by_col_id('state').should('have.text', 'Enacted');
|
||||||
cy.getByTestId('vote-progress').should('be.visible');
|
cy.getByTestId('vote-progress').should('be.visible');
|
||||||
|
cy.getByTestId('vote-progress-bar-for')
|
||||||
|
.invoke('attr', 'style')
|
||||||
|
.should('eq', 'width: 100%;');
|
||||||
cy.get('[col-id="cDate"]')
|
cy.get('[col-id="cDate"]')
|
||||||
.invoke('text')
|
.invoke('text')
|
||||||
.should('match', dateTimeRegex);
|
.should('match', dateTimeRegex);
|
||||||
@ -35,9 +41,12 @@ context('Proposal page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
cy.getByTestId('dialog-title').should('have.text', proposalTitle);
|
cy.getByTestId('dialog-title').should('have.text', proposalTitle);
|
||||||
cy.get('.language-json').should('exist');
|
cy.get('.language-json').should('exist');
|
||||||
|
cy.getByTestId('icon-cross').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('Proposal page displayed on mobile', function () {
|
it.skip('Proposal page displayed on mobile', function () {
|
||||||
|
const proposalTitle = 'Add Lorem Ipsum market';
|
||||||
|
|
||||||
cy.common_switch_to_mobile_and_click_toggle();
|
cy.common_switch_to_mobile_and_click_toggle();
|
||||||
cy.navigate_to('governanceProposals', true);
|
cy.navigate_to('governanceProposals', true);
|
||||||
cy.getByTestId(proposalHeading).should('be.visible');
|
cy.getByTestId(proposalHeading).should('be.visible');
|
||||||
@ -45,5 +54,40 @@ context('Proposal page', { tags: '@smoke' }, function () {
|
|||||||
cy.get_element_by_col_id('title').should('have.text', proposalTitle);
|
cy.get_element_by_col_id('title').should('have.text', proposalTitle);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Able to view new asset proposal', function () {
|
||||||
|
const proposalTitle = 'Test new asset proposal';
|
||||||
|
const newAssetProposalBody = getNewAssetTxBody();
|
||||||
|
cy.VegaWalletSubmitProposal(newAssetProposalBody);
|
||||||
|
|
||||||
|
cy.visit('/');
|
||||||
|
cy.navigate_to('governanceProposals');
|
||||||
|
cy.contains(proposalTitle)
|
||||||
|
.parent()
|
||||||
|
.parent()
|
||||||
|
.parent()
|
||||||
|
.within(() => {
|
||||||
|
cy.get_element_by_col_id('title').should('have.text', proposalTitle);
|
||||||
|
cy.get_element_by_col_id('type').should('have.text', 'NewAsset');
|
||||||
|
cy.get_element_by_col_id('state').should(
|
||||||
|
'have.text',
|
||||||
|
'Waiting for Node Vote'
|
||||||
|
);
|
||||||
|
cy.getByTestId('vote-progress').should('be.visible');
|
||||||
|
cy.getByTestId('vote-progress-bar-against')
|
||||||
|
.invoke('attr', 'style')
|
||||||
|
.should('eq', 'width: 100%;');
|
||||||
|
cy.get('[col-id="cDate"]')
|
||||||
|
.invoke('text')
|
||||||
|
.should('match', dateTimeRegex);
|
||||||
|
cy.get('[col-id="eDate"]')
|
||||||
|
.invoke('text')
|
||||||
|
.should('match', dateTimeRegex);
|
||||||
|
cy.getByTestId('external-link')
|
||||||
|
.should('have.attr', 'href')
|
||||||
|
.and('contains', 'https://governance.fairground.wtf/proposals/');
|
||||||
|
cy.contains('View terms').should('exist').click();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
|
import { addSeconds, millisecondsToSeconds } from 'date-fns';
|
||||||
|
|
||||||
export function createSuccessorMarketProposal(parentMarketId) {
|
export function createSuccessorMarketProposal(parentMarketId) {
|
||||||
cy.VegaWalletSubmitProposal(getSuccessorTxBody(parentMarketId));
|
cy.VegaWalletSubmitProposal(getSuccessorTxBody(parentMarketId));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSuccessorTxBody(parentMarketId) {
|
function getSuccessorTxBody(parentMarketId) {
|
||||||
|
const MIN_CLOSE_SEC = 500;
|
||||||
|
const MIN_ENACT_SEC = 700;
|
||||||
|
|
||||||
|
const closingDate = addSeconds(new Date(), MIN_CLOSE_SEC);
|
||||||
|
const enactmentDate = addSeconds(closingDate, MIN_ENACT_SEC);
|
||||||
|
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
||||||
|
const enactmentTimestamp = millisecondsToSeconds(enactmentDate.getTime());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
proposalSubmission: {
|
proposalSubmission: {
|
||||||
rationale: {
|
rationale: {
|
||||||
@ -122,8 +132,49 @@ function getSuccessorTxBody(parentMarketId) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
closingTimestamp: 1695666618,
|
closingTimestamp,
|
||||||
enactmentTimestamp: 1695666618,
|
enactmentTimestamp,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getNewAssetTxBody() {
|
||||||
|
const MIN_CLOSE_SEC = 500;
|
||||||
|
const MIN_ENACT_SEC = 700;
|
||||||
|
const MIN_VALID_SEC = 60;
|
||||||
|
|
||||||
|
const closingDate = addSeconds(new Date(), MIN_CLOSE_SEC);
|
||||||
|
const enactmentDate = addSeconds(closingDate, MIN_ENACT_SEC);
|
||||||
|
const validationDate = addSeconds(new Date(), MIN_VALID_SEC);
|
||||||
|
|
||||||
|
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
||||||
|
const enactmentTimestamp = millisecondsToSeconds(enactmentDate.getTime());
|
||||||
|
const validationTimestamp = millisecondsToSeconds(validationDate.getTime());
|
||||||
|
|
||||||
|
return {
|
||||||
|
proposalSubmission: {
|
||||||
|
rationale: {
|
||||||
|
title: 'Test new asset proposal',
|
||||||
|
description: 'E2E test for proposals',
|
||||||
|
},
|
||||||
|
terms: {
|
||||||
|
newAsset: {
|
||||||
|
changes: {
|
||||||
|
name: 'USDT Coin',
|
||||||
|
symbol: 'USDT',
|
||||||
|
decimals: '18',
|
||||||
|
quantum: '1',
|
||||||
|
erc20: {
|
||||||
|
contractAddress: '0xb404c51bbc10dcbe948077f18a4b8e553d160084',
|
||||||
|
withdrawThreshold: '10',
|
||||||
|
lifetimeLimit: '10',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
closingTimestamp,
|
||||||
|
enactmentTimestamp,
|
||||||
|
validationTimestamp,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -153,8 +153,10 @@ export function waitForProposal(id: string): Promise<{ id: string }> {
|
|||||||
try {
|
try {
|
||||||
const res = await getProposal(id);
|
const res = await getProposal(id);
|
||||||
if (
|
if (
|
||||||
res.proposal !== null &&
|
(res.proposal !== null &&
|
||||||
res.proposal.state === Schema.ProposalState.STATE_OPEN
|
res.proposal.state === Schema.ProposalState.STATE_OPEN) ||
|
||||||
|
res.proposal.state ===
|
||||||
|
Schema.ProposalState.STATE_WAITING_FOR_NODE_VOTE
|
||||||
) {
|
) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
resolve(res.proposal);
|
resolve(res.proposal);
|
||||||
|
Loading…
Reference in New Issue
Block a user