Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: e2e tests added for repo #88

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# E2E tests
screenshots
videos
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"format": "prettier --write src",
"postinstall": "patch-package",
"test": "vitest",
"coverage": "vitest run --coverage"
"coverage": "vitest run --coverage",
"test:e2e": "EXTENSION=keplr SKIP_EXTENSION_SETUP=true synpress run --configFile=tests/e2e/synpress.config.cjs"
},
"dependencies": {
"@agoric/rpc": "^0.0.2-dev-2c6fbc5.0",
Expand Down Expand Up @@ -51,6 +52,7 @@
},
"devDependencies": {
"@agoric/governance": "^0.10.3",
"@agoric/synpress": "^3.7.2-beta.12",
"@keplr-wallet/types": "^0.11.1",
"@tailwindcss/forms": "^0.5.3",
"@types/node": "^18.7.13",
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const path = require('path');
const synpressPath = path.join(process.cwd(), '/node_modules/@agoric/synpress');

module.exports = {
extends: `${synpressPath}/.eslintrc.js`,
};
231 changes: 231 additions & 0 deletions tests/e2e/specs/proposal.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
/* eslint-disable ui-testing/no-disabled-tests */
describe('Make Proposal Tests', () => {
let startTime;
context('PSM tests', () => {
it('should setup two econ committee member wallets', () => {
cy.setupWallet({
secretWords:
'purse park grow equip size away dismiss used evolve live blouse scorpion enjoy crunch combine day second news off crowd broken crop zoo subject',
walletName: 'gov1',
});
cy.setupWallet({
secretWords:
'tilt add stairs mandate extra wash choose fashion earth feature reopen until move lazy carbon pledge sure own comfort this nasty clap tower table',
walletName: 'gov2',
});
});

it('should connect to wallet', () => {
cy.visit('/?agoricNet=local');
cy.acceptAccess();
});

it('should have value of 1000 on psm inter', () => {
cy.origin('https://psm.inter.trade', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's good to depend on the live UI here since a service disruption could impede workflows. Although, even when using a local build of PSM and connecting to a local chain, the app will make a request to https://wallet.agoric.app/network-config. Maybe it's enough to just check that the history item shows up with the new value, below the check for 'Change Accepted', instead of looking at the PSM app.

cc @turadg

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, @samsiegart . Could the e2e tests intercept https://wallet.agoric.app/network-config to provide a local result?

I don't see this as a blocking concern for having these tests in CI, but it should be addressed before required green to merge. (I.e. adding it to branch protection)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. I'll remove the check from the external PSM URL

cy.visit('/');
// Switch to local network
cy.get('button').contains('Agoric Mainnet').click();
cy.get('button').contains('Local Network').click();

// Click the connect button
cy.get('button').contains('Connect Keplr').click();
cy.get('input[type="checkbox"]').click();
cy.get('button:enabled').contains('Proceed').click();
});

// Accept access and confirm
cy.acceptAccess();

cy.origin('https://psm.inter.trade', () => {
cy.get('button').contains('Keplr Connected').should('be.visible');

// Select asset and verify original value
cy.get('button').contains('Select asset').click();
cy.get('button').contains('USDT_axl').click();
cy.get('div')
.contains('IST Available')
.children()
.first()
.should('have.text', '1000.00');
});
});

it('should allow gov1 to create a proposal', () => {
cy.visit('/?agoricNet=local');

// open PSM and select USDT_axl
cy.get('button').contains('PSM').click();
cy.get('button').contains('AUSD').click();
cy.get('button').contains('USDT_axl').click();

// Change mint limit to 100 and proposal time to 1 min
cy.get('label')
.contains('Set Mint Limit')
.parent()
.within(() => {
cy.get('input').clear().type(100);
});
cy.get('label')
.contains('Minutes until close of vote')
.parent()
.within(() => {
cy.get('input').clear().type(1);
});
cy.get('[value="Propose Parameter Change"]').click();

// Submit proposal and wait for confirmation
cy.confirmTransaction();
cy.get('p')
.contains('sent')
.should('be.visible')
.then(() => {
startTime = Date.now();
});
});

it('should allow gov2 to vote on the proposal', () => {
cy.visit('/?agoricNet=local');

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
cy.get('input:enabled[value="Submit Vote"]').click();

// Wait for vote to confirm
cy.confirmTransaction();
cy.get('p').contains('sent').should('be.visible');
});

it('should allow gov1 to vote on the proposal', () => {
cy.switchWallet('gov1');
cy.visit('/?agoricNet=local');

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
cy.get('input:enabled[value="Submit Vote"]').click();

// Wait for vote to confirm
cy.confirmTransaction();
cy.get('p').contains('sent').should('be.visible');
});

it('should wait for proposal to pass', () => {
// Wait for 1 minute to pass
cy.wait(60000 - Date.now() + startTime);
cy.visit('/?agoricNet=local');

cy.get('button').contains('History').click();

// Select the first element proposal containing USDT_axl and check
// its status should be accepted
cy.get('code')
.contains('psm-IST-USDT_axl')
.parent()
.parent()
.parent()
.within(() => {
cy.get('span').contains('Change Accepted').should('be.visible');
});
});

it('should update the value of 100 on psm inter', () => {
cy.origin('https://psm.inter.trade', () => {
cy.visit('/');

// Click the connect button
cy.get('button').contains('Connect Keplr').click();
cy.get('button').contains('Keplr Connected').should('be.visible');

// Select asset and verify new value
cy.get('button').contains('Select asset').click();
cy.get('button').contains('USDT_axl').click();
cy.get('div')
.contains('IST Available')
.children()
.first()
.should('have.text', '100.00');
});
});
});
context('Vaults tests', () => {
it('should allow gov1 to create a proposal', () => {
cy.visit('/?agoricNet=local');

// 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 to 1.22M and proposal time to 1 min
cy.get('label')
.contains('DebtLimit')
.parent()
.within(() => {
cy.get('input').clear().type('122,000,000');
});
cy.get('label')
.contains('Minutes until close of vote')
.parent()
.within(() => {
cy.get('input').clear().type(1);
});
cy.get('[value="Propose Parameter Change"]').click();

// Submit proposal and wait for confirmation
cy.confirmTransaction();
cy.get('p')
.contains('sent')
.should('be.visible')
.then(() => {
startTime = Date.now();
});
});

it('should allow gov1 to vote on the proposal', () => {
cy.visit('/?agoricNet=local');

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
cy.get('input:enabled[value="Submit Vote"]').click();

// Wait for vote to confirm
cy.confirmTransaction();
cy.get('p').contains('sent').should('be.visible');
});

it('should allow gov2 to vote on the proposal', () => {
cy.switchWallet('gov2');
cy.visit('/?agoricNet=local');

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
cy.get('input:enabled[value="Submit Vote"]').click();

// Wait for vote to confirm
cy.confirmTransaction();
cy.get('p').contains('sent').should('be.visible');
});

it('should wait for proposal to pass', () => {
// Wait for 1 minute to pass
cy.wait(60000 - Date.now() + startTime);
cy.visit('/?agoricNet=local');

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');
});
});
});
});
1 change: 1 addition & 0 deletions tests/e2e/support.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@agoric/synpress/support/index';
10 changes: 10 additions & 0 deletions tests/e2e/synpress.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const config = require('@agoric/synpress/synpress.config');
const { defineConfig } = require('cypress');

module.exports = defineConfig({
...config,
e2e: {
...config.e2e,
baseUrl: 'http://localhost:5173',
},
});
3 changes: 2 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { mergeConfig } from 'vite';
import { defineConfig } from 'vitest/config';
import { defineConfig, configDefaults } from 'vitest/config';
import viteConfig from './vite.config';

export default mergeConfig(
viteConfig,
defineConfig({
test: {
setupFiles: ['src/installSesLockdown.ts'],
exclude: [...configDefaults.exclude, 'tests/e2e/**'],
},
}),
);
Loading