chore: deposit and withdrawal capsule e2e tests (#2720)

This commit is contained in:
daro-maj 2023-01-25 08:21:17 +01:00 committed by GitHub
parent b0de4dfbf3
commit 10fe82dea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 170 additions and 26 deletions

View File

@ -42,5 +42,6 @@ module.exports = defineConfig({
grepTags: '@regression @smoke @slow',
grepFilterSpecs: true,
grepOmitFiltered: true,
txTimeout: { timeout: 70000 },
},
});

View File

@ -8,6 +8,7 @@ import {
} from '@vegaprotocol/types';
import { isBefore, isAfter, addSeconds, subSeconds } from 'date-fns';
import { createOrder } from '../support/create-order';
import { connectEthereumWallet } from '../support/ethereum-wallet';
const orderSize = 'size';
const orderType = 'type';
@ -17,6 +18,16 @@ const orderPrice = 'price';
const orderTimeInForce = 'timeInForce';
const orderCreatedAt = 'createdAt';
const orderUpdatedAt = 'updatedAt';
const assetSelectField = 'select[name="asset"]';
const amountField = 'input[name="amount"]';
const txTimeout = Cypress.env('txTimeout');
const btcName = 'BTC (local)';
const btcSymbol = 'tBTC';
const usdcSymbol = 'fUSDC';
const toastContent = 'toast-content';
const ordersTab = 'Orders';
const depositsTab = 'Deposits';
const toastCloseBtn = 'toast-close';
// TODO: ensure this test runs only if capsule is running via workflow
describe('capsule', { tags: '@slow' }, () => {
@ -25,6 +36,7 @@ describe('capsule', { tags: '@slow' }, () => {
cy.get('@markets').then((markets) => {
cy.wrap(markets[0]).as('market');
});
cy.updateCapsuleMultiSig();
});
beforeEach(() => {
@ -45,15 +57,16 @@ describe('capsule', { tags: '@slow' }, () => {
const rawPrice = removeDecimal(order.price, market.decimalPlaces);
const rawSize = removeDecimal(order.size, market.positionDecimalPlaces);
cy.getByTestId('Collateral').click();
cy.getByTestId('asset', txTimeout).should('contain.text', usdcSymbol);
createOrder(order);
cy.getByTestId('dialog-title').should(
cy.getByTestId(toastContent).should(
'contain.text',
'Awaiting network confirmation'
`ConfirmedYour transaction has been confirmed View in block explorerSubmit order - activeTEST.24h+0.0005 @ 390.00 ${usdcSymbol}`
);
cy.getByTestId('dialog-title').should('contain.text', 'Order submitted');
cy.getByTestId('dialog-close').click();
cy.getByTestId(toastCloseBtn).click();
// orderbook cells are keyed by price level
cy.getByTestId('tab-orderbook')
.get(`[data-testid="price-${rawPrice}"]`)
@ -61,7 +74,8 @@ describe('capsule', { tags: '@slow' }, () => {
.get(`[data-testid="bid-vol-${rawPrice}"]`)
.should('contain.text', rawSize);
cy.getByTestId('Orders').click();
cy.getByTestId(ordersTab).click();
cy.getByTestId('edit').should('contain.text', 'Edit');
cy.getByTestId('tab-orders').within(() => {
cy.get('.ag-center-cols-container')
.children()
@ -99,14 +113,18 @@ describe('capsule', { tags: '@slow' }, () => {
checkIfDataAndTimeOfCreationAndUpdateIsEqual(orderCreatedAt);
});
});
cy.getByTestId('edit').first().click();
//edit order
cy.getByTestId(ordersTab).click();
cy.getByTestId('edit').first().should('be.visible').click();
cy.getByTestId('dialog-title').should('contain.text', 'Edit order');
cy.get('#limitPrice').focus().clear().type('200');
cy.getByTestId('edit-order').find('[type="submit"]').click();
cy.getByTestId('dialog-title').should('contain.text', 'Order updated');
cy.getByTestId('dialog-close').click();
cy.getByTestId(toastContent).should(
'contain.text',
`ConfirmedYour transaction has been confirmed View in block explorerEdit order - activeTEST.24h+0.0005 @ 200.00 ${usdcSymbol}+0.0005 @ 200.00 ${usdcSymbol}`
);
cy.getByTestId(ordersTab).click();
cy.getByTestId(toastCloseBtn).click();
cy.get('.ag-center-cols-container')
.children()
.first()
@ -116,26 +134,144 @@ describe('capsule', { tags: '@slow' }, () => {
});
checkIfDataAndTimeOfCreationAndUpdateIsEqual(orderUpdatedAt);
});
//cancel order
cy.getByTestId(ordersTab).click();
cy.getByTestId('cancel').first().click();
cy.getByTestId('dialog-title').should(
cy.getByTestId(toastContent).should(
'contain.text',
'Awaiting network confirmation'
`ConfirmedYour transaction has been confirmed View in block explorerCancel order - cancelledTEST.24h+0.0005 @ 200.00 ${usdcSymbol}`
);
cy.getByTestId('dialog-title').should('contain.text', 'Order cancelled');
cy.getByTestId('dialog-close').click();
cy.getByTestId(toastCloseBtn).click();
cy.getByTestId('tab-orders')
.get('.ag-center-cols-container')
.children()
.first()
.get(`[col-id='${orderStatus}']`)
.get(`[col-id='${orderStatus}']`, txTimeout)
.should('contain.text', OrderStatusMapping.STATUS_CANCELLED);
});
it('can deposit and withdrawal', function () {
// 1001-DEPO-001
// 1001-DEPO-002
// 1001-DEPO-003
// 1001-DEPO-005
// 1001-DEPO-006
// 1001-DEPO-007
// 1001-DEPO-008
// 1001-DEPO-009
// 1002-WITH-001
// 1002-WITH-006
// 1002-WITH-009
// 002-WITH-011
// 1002-WITH-024
// 1002-WITH-012
// 1002-WITH-013
// 1002-WITH-014
// 1002-WITH-015
// 1002-WITH-016
// 1002-WITH-019
cy.visit('/#/portfolio');
cy.get('main[data-testid="/portfolio"]').should('exist');
cy.highlight('creating deposit');
cy.getByTestId(depositsTab).click();
cy.getByTestId('deposit-button').click();
connectEthereumWallet('Unknown');
cy.get(assetSelectField, txTimeout).select(btcName);
cy.getByTestId('deposit-approve-submit').click();
cy.getByTestId('dialog-title').should('contain.text', 'Approve complete');
cy.get('[data-testid="Return to deposit"]').click();
cy.get(amountField).clear().type('1');
cy.getByTestId('deposit-submit').click();
cy.getByTestId(toastContent, txTimeout).should(
'contain.text',
`Transaction completedYour transaction has been completedView on EtherscanDeposit 1.00 ${btcSymbol}`
);
cy.getByTestId(toastCloseBtn).click();
cy.getByTestId('Collateral').click();
cy.highlight('deposit verification');
cy.getByTestId('asset', txTimeout).should('contain.text', btcSymbol);
// need to reload page to see deposit history complete
cy.reload();
cy.getByTestId(depositsTab).click();
cy.get('.ag-cell-value', txTimeout).should('contain.text', btcSymbol);
cy.get('[col-id="status"]').should('not.have.text', 'Open', txTimeout);
cy.get('[col-id="txHash"]')
.should('have.length.above', 2)
.eq(1)
.parent()
.within(() => {
cy.get('[col-id="asset.symbol"]').should('have.text', btcSymbol);
cy.get('[col-id="amount"]').should('have.text', '1.00');
cy.get('[col-id="createdTimestamp"]').should('not.be.empty');
cy.get('[col-id="status"]').should('have.text', 'Finalized');
cy.get('[col-id="txHash"]')
.find('a')
.should('have.attr', 'href')
.and('contain', 'https://sepolia.etherscan.io/tx');
});
cy.highlight('creating withdrawals');
cy.getByTestId('Withdrawals').click();
cy.getByTestId('withdraw-dialog-button').click();
connectEthereumWallet('Unknown');
cy.get(assetSelectField).select(btcName);
cy.get(amountField).clear().type('1');
cy.getByTestId('submit-withdrawal').click();
cy.getByTestId(toastContent, txTimeout).should(
'contain.text',
'Funds unlocked'
);
cy.getByTestId('tab-withdrawals').within(() => {
cy.get('.ag-center-cols-container')
.children()
.first()
.within(() => {
cy.get('[col-id="status"]').should('contain.text', 'Pending');
});
});
cy.highlight('withdrawals verification');
cy.getByTestId('toast-complete-withdrawal').click();
cy.getByTestId(toastContent, txTimeout).should(
'contain.text',
'Transaction completed'
);
cy.getByTestId('complete-withdrawal', txTimeout).should('not.exist');
cy.get('[col-id="txHash"]', txTimeout)
.should('have.length.above', 1)
.eq(1)
.parent()
.within(() => {
cy.get('[col-id="asset.symbol"]').should('have.text', btcSymbol);
cy.get('[col-id="amount"]').should('have.text', '1.00');
cy.get('[col-id="details.receiverAddress"]')
.find('a')
.should('have.attr', 'href')
.and('contain', 'https://sepolia.etherscan.io/address/');
cy.get('[col-id="createdTimestamp"]').should('not.be.empty');
cy.get('[col-id="withdrawnTimestamp"]').should('not.be.empty');
cy.get('[col-id="status"]').should('have.text', 'Completed');
cy.get('[col-id="txHash"]')
.find('a')
.should('have.attr', 'href')
.and('contain', 'https://sepolia.etherscan.io/tx/0x');
});
});
});
function checkIfDataAndTimeOfCreationAndUpdateIsEqual(date: string) {
cy.get(`[col-id='${date}']`)
cy.get(`[col-id='${date}'] .ag-cell-wrapper`)
.children('span')
.children('span')
.invoke('data', 'value')
.then(($dateTime) => {

View File

@ -16,7 +16,7 @@ describe('deposit form validation', { tags: '@smoke' }, () => {
cy.getByTestId('Deposits').click();
cy.getByTestId('deposit-button').click();
cy.wait('@Assets');
connectEthereumWallet();
connectEthereumWallet('MetaMask');
cy.getByTestId('deposit-submit').click();
});

View File

@ -119,7 +119,7 @@ describe('ethereum wallet', { tags: '@smoke' }, () => {
const ethWalletAddress = Cypress.env('ETHEREUM_WALLET_ADDRESS');
cy.getByTestId('Deposits').click();
cy.getByTestId('deposit-button').click();
connectEthereumWallet();
connectEthereumWallet('MetaMask');
cy.get('#ethereum-address').should('have.value', ethWalletAddress);
cy.getByTestId('disconnect-ethereum-wallet')
.should('have.text', 'Disconnect')

View File

@ -23,7 +23,7 @@ describe('withdraw form validation', { tags: '@smoke' }, () => {
cy.getByTestId('withdraw-dialog-button').click();
// It also requires connection Ethereum wallet
connectEthereumWallet();
connectEthereumWallet('MetaMask');
cy.wait('@Accounts');
cy.wait('@Assets');
@ -79,7 +79,7 @@ describe('withdraw actions', { tags: '@regression' }, () => {
cy.getByTestId('Withdrawals').click();
cy.getByTestId('withdraw-dialog-button').click();
connectEthereumWallet();
connectEthereumWallet('MetaMask');
cy.wait('@Accounts');
cy.wait('@Assets');

View File

@ -1,5 +1,5 @@
export const connectEthereumWallet = () => {
export const connectEthereumWallet = (connectorName: string) => {
cy.getByTestId('connect-eth-wallet-btn').should('be.enabled').click();
cy.getByTestId('web3-connector-list').should('be.visible');
cy.getByTestId('web3-connector-MetaMask').click();
cy.getByTestId(`web3-connector-${connectorName}`).click();
};

View File

@ -430,6 +430,7 @@ const VegaTxCompleteToastsContent = ({ tx }: VegaTxToastContentProps) => {
const completeWithdrawalButton = tx.withdrawal && (
<div className="mt-[10px]">
<Button
data-testid="toast-complete-withdrawal"
size="xs"
onClick={() => {
createEthWithdrawalApproval(

View File

@ -63,7 +63,12 @@ export const getTransactionContent = ({
/>
)}
{(status === EthTxStatus.Confirmed || status === EthTxStatus.Error) && (
<Button size="sm" className="mt-2" onClick={reset}>
<Button
size="sm"
className="mt-2"
data-testid={returnLabel}
onClick={reset}
>
{returnLabel ? returnLabel : t('Return')}
</Button>
)}

View File

@ -110,6 +110,7 @@ export const WithdrawalsTable = (
complete: (withdrawal: WithdrawalFieldsFragment) => {
createWithdrawApproval(withdrawal);
},
ethUrl: ETHERSCAN_URL,
}}
cellRendererSelector={({
data,