chore(governance): assert proposal dates (#3610)
This commit is contained in:
parent
106b040977
commit
d0173f15b2
@ -4,12 +4,11 @@ import {
|
|||||||
navigation,
|
navigation,
|
||||||
} from '../../support/common.functions';
|
} from '../../support/common.functions';
|
||||||
import {
|
import {
|
||||||
convertUnixTimestampToDateformat,
|
|
||||||
createRawProposal,
|
createRawProposal,
|
||||||
createTenDigitUnixTimeStampForSpecifiedDays,
|
createTenDigitUnixTimeStampForSpecifiedDays,
|
||||||
enterUniqueFreeFormProposalBody,
|
enterUniqueFreeFormProposalBody,
|
||||||
generateFreeFormProposalTitle,
|
generateFreeFormProposalTitle,
|
||||||
getGovernanceProposalDateFormatForSpecifiedDays,
|
getDateFormatForSpecifiedDays,
|
||||||
getProposalIdFromList,
|
getProposalIdFromList,
|
||||||
getProposalInformationFromTable,
|
getProposalInformationFromTable,
|
||||||
getSubmittedProposalFromProposalList,
|
getSubmittedProposalFromProposalList,
|
||||||
@ -23,6 +22,7 @@ import { ensureSpecifiedUnstakedTokensAreAssociated } from '../../../../governan
|
|||||||
import { ethereumWalletConnect } from '../../../../governance-e2e/src/support/wallet-eth.functions';
|
import { ethereumWalletConnect } from '../../../../governance-e2e/src/support/wallet-eth.functions';
|
||||||
import { vegaWalletSetSpecifiedApprovalAmount } from '../../../../governance-e2e/src/support/wallet-teardown.functions';
|
import { vegaWalletSetSpecifiedApprovalAmount } from '../../../../governance-e2e/src/support/wallet-teardown.functions';
|
||||||
import type { testFreeformProposal } from '../../support/common-interfaces';
|
import type { testFreeformProposal } from '../../support/common-interfaces';
|
||||||
|
import { formatDateWithLocalTimezone } from '@vegaprotocol/utils';
|
||||||
|
|
||||||
const proposalVoteProgressForPercentage =
|
const proposalVoteProgressForPercentage =
|
||||||
'[data-testid="vote-progress-indicator-percentage-for"]';
|
'[data-testid="vote-progress-indicator-percentage-for"]';
|
||||||
@ -99,20 +99,22 @@ describe(
|
|||||||
getSubmittedProposalFromProposalList(proposalTitle).within(() =>
|
getSubmittedProposalFromProposalList(proposalTitle).within(() =>
|
||||||
cy.get(viewProposalButton).click()
|
cy.get(viewProposalButton).click()
|
||||||
);
|
);
|
||||||
convertUnixTimestampToDateformat(proposalTimeStamp).then(
|
cy.wrap(
|
||||||
(closingDate) => {
|
formatDateWithLocalTimezone(new Date(proposalTimeStamp * 1000))
|
||||||
|
).then((closingDate) => {
|
||||||
getProposalInformationFromTable('Closes on')
|
getProposalInformationFromTable('Closes on')
|
||||||
.contains(closingDate)
|
.contains(closingDate)
|
||||||
.should('be.visible');
|
.should('be.visible');
|
||||||
}
|
});
|
||||||
);
|
cy.wrap(
|
||||||
getGovernanceProposalDateFormatForSpecifiedDays(0).then(
|
formatDateWithLocalTimezone(
|
||||||
(proposalDate) => {
|
new Date(createTenDigitUnixTimeStampForSpecifiedDays(0) * 1000)
|
||||||
|
)
|
||||||
|
).then((proposalDate) => {
|
||||||
getProposalInformationFromTable('Proposed on')
|
getProposalInformationFromTable('Proposed on')
|
||||||
.contains(proposalDate)
|
.contains(proposalDate)
|
||||||
.should('be.visible');
|
.should('be.visible');
|
||||||
}
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Newly created proposal details - shows default status set to fail', function () {
|
it('Newly created proposal details - shows default status set to fail', function () {
|
||||||
@ -155,8 +157,7 @@ describe(
|
|||||||
cy.getByTestId('vote-buttons').contains('against').should('be.visible');
|
cy.getByTestId('vote-buttons').contains('against').should('be.visible');
|
||||||
cy.getByTestId('vote-buttons').contains('for').should('be.visible');
|
cy.getByTestId('vote-buttons').contains('for').should('be.visible');
|
||||||
voteForProposal('for');
|
voteForProposal('for');
|
||||||
getGovernanceProposalDateFormatForSpecifiedDays(0, 'shortMonth').then(
|
getDateFormatForSpecifiedDays(0).then((votedDate) => {
|
||||||
(votedDate) => {
|
|
||||||
// 3001-VOTE-051
|
// 3001-VOTE-051
|
||||||
// 3001-VOTE-093
|
// 3001-VOTE-093
|
||||||
cy.contains('You voted:')
|
cy.contains('You voted:')
|
||||||
@ -165,8 +166,7 @@ describe(
|
|||||||
.siblings()
|
.siblings()
|
||||||
.contains(votedDate)
|
.contains(votedDate)
|
||||||
.should('be.visible');
|
.should('be.visible');
|
||||||
}
|
});
|
||||||
);
|
|
||||||
cy.get(proposalVoteProgressForPercentage) // 3001-VOTE-072
|
cy.get(proposalVoteProgressForPercentage) // 3001-VOTE-072
|
||||||
.contains('100.00%')
|
.contains('100.00%')
|
||||||
.and('be.visible');
|
.and('be.visible');
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { format } from 'date-fns';
|
||||||
import { closeDialog, navigateTo, navigation } from './common.functions';
|
import { closeDialog, navigateTo, navigation } from './common.functions';
|
||||||
import { ensureSpecifiedUnstakedTokensAreAssociated } from './staking.functions';
|
import { ensureSpecifiedUnstakedTokensAreAssociated } from './staking.functions';
|
||||||
|
|
||||||
@ -15,35 +16,6 @@ const newProposalSubmitButton = '[data-testid="proposal-submit"]';
|
|||||||
const epochTimeout = Cypress.env('epochTimeout');
|
const epochTimeout = Cypress.env('epochTimeout');
|
||||||
const proposalTimeout = { timeout: 14000 };
|
const proposalTimeout = { timeout: 14000 };
|
||||||
|
|
||||||
export function convertUnixTimestampToDateformat(
|
|
||||||
unixTimestamp: number,
|
|
||||||
monthTextLength = 'longMonth'
|
|
||||||
) {
|
|
||||||
const dateSupplied = new Date(unixTimestamp * 1000);
|
|
||||||
const year = dateSupplied.getFullYear();
|
|
||||||
const months = [
|
|
||||||
'January',
|
|
||||||
'February',
|
|
||||||
'March',
|
|
||||||
'April',
|
|
||||||
'May',
|
|
||||||
'June',
|
|
||||||
'July',
|
|
||||||
'August',
|
|
||||||
'September',
|
|
||||||
'October',
|
|
||||||
'November',
|
|
||||||
'December',
|
|
||||||
];
|
|
||||||
const month = months[dateSupplied.getMonth()];
|
|
||||||
const shortMonth = months[dateSupplied.getMonth()].substring(0, 3),
|
|
||||||
date = dateSupplied.getDate();
|
|
||||||
|
|
||||||
if (monthTextLength === 'longMonth') {
|
|
||||||
return cy.wrap(`${date} ${month} ${year}`);
|
|
||||||
} else return cy.wrap(`${date} ${shortMonth} ${year}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createTenDigitUnixTimeStampForSpecifiedDays(
|
export function createTenDigitUnixTimeStampForSpecifiedDays(
|
||||||
durationDays: number
|
durationDays: number
|
||||||
) {
|
) {
|
||||||
@ -52,6 +24,13 @@ export function createTenDigitUnixTimeStampForSpecifiedDays(
|
|||||||
return (timestamp = Math.floor(timestamp / 1000));
|
return (timestamp = Math.floor(timestamp / 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDateFormatForSpecifiedDays(days: number) {
|
||||||
|
const date = new Date(
|
||||||
|
createTenDigitUnixTimeStampForSpecifiedDays(days) * 1000
|
||||||
|
);
|
||||||
|
return cy.wrap(format(date, 'dd MMM yyyy'));
|
||||||
|
}
|
||||||
|
|
||||||
export function enterRawProposalBody(timestamp: number) {
|
export function enterRawProposalBody(timestamp: number) {
|
||||||
cy.fixture('/proposals/raw.json').then((rawProposal) => {
|
cy.fixture('/proposals/raw.json').then((rawProposal) => {
|
||||||
rawProposal.terms.closingTimestamp = timestamp;
|
rawProposal.terms.closingTimestamp = timestamp;
|
||||||
@ -104,16 +83,6 @@ export function getProposalIdFromList(proposalTitle: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGovernanceProposalDateFormatForSpecifiedDays(
|
|
||||||
days: number,
|
|
||||||
shortOrLong?: string
|
|
||||||
) {
|
|
||||||
return convertUnixTimestampToDateformat(
|
|
||||||
createTenDigitUnixTimeStampForSpecifiedDays(days),
|
|
||||||
shortOrLong
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getProposalInformationFromTable(heading: string) {
|
export function getProposalInformationFromTable(heading: string) {
|
||||||
return cy.get(proposalInformationTableRows).contains(heading).siblings();
|
return cy.get(proposalInformationTableRows).contains(heading).siblings();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user