diff --git a/tests/e2e/specs/proposal.spec.js b/tests/e2e/specs/proposal.spec.js index 8a5a2d4..8a95c75 100644 --- a/tests/e2e/specs/proposal.spec.js +++ b/tests/e2e/specs/proposal.spec.js @@ -3,11 +3,14 @@ import { phrasesList, getTimeUntilVoteClose, DEFAULT_TIMEOUT } from '../utils'; describe('Make Proposal Tests', () => { let startTime; - const networkPhrases = phrasesList[Cypress.env('AGORIC_NET') || 'local']; + const AGORIC_NET = Cypress.env('AGORIC_NET') || 'local'; + const networkPhrases = phrasesList[AGORIC_NET]; const txRetryCount = 2; context('PSM tests', () => { it('should setup two econ committee member wallets', () => { + cy.task('info', `${AGORIC_NET}`); + cy.setupWallet({ secretWords: networkPhrases.gov1Phrase, walletName: 'gov1', @@ -16,6 +19,12 @@ describe('Make Proposal Tests', () => { secretWords: networkPhrases.gov2Phrase, walletName: 'gov2', }); + if (AGORIC_NET !== 'local') { + cy.setupWallet({ + secretWords: networkPhrases.gov4Phrase, + walletName: 'gov4', + }); + } }); it('should connect to wallet', () => { @@ -54,7 +63,11 @@ describe('Make Proposal Tests', () => { cy.acceptAccess(); }); - it('should allow gov1 to create a proposal', () => { + it('should allow gov2 to create a proposal', () => { + if (AGORIC_NET !== 'local') { + cy.switchWallet('gov2'); + } + cy.reload(); // open PSM and select token cy.get('button').contains('PSM').click(); cy.get('button').contains('AUSD').click(); @@ -78,7 +91,7 @@ describe('Make Proposal Tests', () => { }); it( - 'should confirm transaction for gov1 to create a proposal', + 'should confirm transaction for gov2 to create a proposal', { retries: { runMode: txRetryCount, @@ -290,4 +303,133 @@ describe('Make Proposal Tests', () => { }); }); }); + + context('Gov4 tests', () => { + it('should allow gov4 to create a proposal', () => { + cy.skipWhen(AGORIC_NET === 'local'); + + cy.switchWallet('gov4'); + cy.visit(`/?agoricNet=${networkPhrases.network}`); + + // open Values and select manager 0 + cy.get('button').contains('Vaults').click(); + cy.get('button').contains('Select Manager').click(); + cy.get('button').contains('manager0').click(); + + // Change debt limit and proposal time to 1 min + cy.get('label') + .contains('DebtLimit') + .parent() + .within(() => { + cy.get('input').spread(element => { + cy.get('input').clear().type(element.value); + }); + }); + cy.get('label') + .contains('Minutes until close of vote') + .parent() + .within(() => { + cy.get('input').clear().type(networkPhrases.minutes); + }); + }); + + it( + 'should confirm transaction for gov4 to create a proposal', + { + retries: { + runMode: txRetryCount, + }, + }, + () => { + cy.skipWhen(AGORIC_NET === 'local'); + cy.get('[value="Propose Parameter Change"]').click(); + + // Submit proposal and wait for confirmation + cy.confirmTransaction(); + cy.get('p') + .contains('sent', { timeout: DEFAULT_TIMEOUT }) + .should('be.visible') + .then(() => { + startTime = Date.now(); + }); + }, + ); + + it('should allow gov4 to vote on the proposal', () => { + cy.skipWhen(AGORIC_NET === 'local'); + cy.visit(`/?agoricNet=${networkPhrases.network}`); + + // Open vote, click on yes and submit + cy.get('button').contains('Vote').click(); + cy.get('p').contains('YES').click(); + }); + + it( + 'should confirm transaction for gov4 to vote on the proposal', + { + retries: { + runMode: txRetryCount, + }, + }, + () => { + cy.skipWhen(AGORIC_NET === 'local'); + cy.get('input:enabled[value="Submit Vote"]').click(); + + // Wait for vote to confirm + cy.confirmTransaction(); + cy.get('p') + .contains('sent', { timeout: DEFAULT_TIMEOUT }) + .should('be.visible'); + }, + ); + + it('should allow gov2 to vote on the proposal', () => { + cy.skipWhen(AGORIC_NET === 'local'); + cy.switchWallet('gov2'); + cy.visit(`/?agoricNet=${networkPhrases.network}`); + + // Open vote, click on yes and submit + cy.get('button').contains('Vote').click(); + cy.get('p').contains('YES').click(); + }); + + it( + 'should confirm transaction for gov2 to vote on the proposal', + { + retries: { + runMode: txRetryCount, + }, + }, + () => { + cy.skipWhen(AGORIC_NET === 'local'); + cy.get('input:enabled[value="Submit Vote"]').click(); + + // Wait for vote to confirm + cy.confirmTransaction(); + cy.get('p') + .contains('sent', { timeout: DEFAULT_TIMEOUT }) + .should('be.visible'); + }, + ); + + it('should wait for proposal to pass', () => { + cy.skipWhen(AGORIC_NET === 'local'); + // Wait for 1 minute to pass + cy.wait(getTimeUntilVoteClose(startTime, networkPhrases.minutes)); + cy.visit(`/?agoricNet=${networkPhrases.network}`); + + cy.get('button').contains('History').click(); + + // Select the first element proposal containing ATOM and check + // its status should be accepted + cy.get('code') + .contains('VaultFactory - ATOM') + .parent() + .parent() + .parent() + .within(() => { + cy.get('span').contains('Change Accepted').should('be.visible'); + }); + }); + }); }); diff --git a/tests/e2e/support.js b/tests/e2e/support.js index 73d2d1f..171e77a 100644 --- a/tests/e2e/support.js +++ b/tests/e2e/support.js @@ -1 +1,7 @@ import '@agoric/synpress/support/index'; + +Cypress.Commands.add('skipWhen', function (expression) { + if (expression) { + this.skip(); + } +}); diff --git a/tests/e2e/utils.js b/tests/e2e/utils.js index 7737e3d..68be15a 100644 --- a/tests/e2e/utils.js +++ b/tests/e2e/utils.js @@ -9,6 +9,7 @@ export const phrasesList = { networkConfigURL: 'https://emerynet.agoric.net/network-config', gov1Phrase: Cypress.env('GOV1_PHRASE'), gov2Phrase: Cypress.env('GOV2_PHRASE'), + gov4Phrase: Cypress.env('GOV4_PHRASE'), }, devnet: { isLocal: false, @@ -18,6 +19,7 @@ export const phrasesList = { networkConfigURL: 'https://devnet.agoric.net/network-config', gov1Phrase: Cypress.env('GOV1_PHRASE'), gov2Phrase: Cypress.env('GOV2_PHRASE'), + gov4Phrase: Cypress.env('GOV4_PHRASE'), }, xnet: { isLocal: false, @@ -27,6 +29,7 @@ export const phrasesList = { networkConfigURL: 'https://xnet.agoric.net/network-config', gov1Phrase: Cypress.env('GOV1_PHRASE'), gov2Phrase: Cypress.env('GOV2_PHRASE'), + gov4Phrase: Cypress.env('GOV4_PHRASE'), }, local: { isLocal: true,