test(trading): update of capsule and live tests (#3635)

This commit is contained in:
daro-maj 2023-05-08 16:52:33 +02:00 committed by GitHub
parent 313eff1c95
commit d1265a6af7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 245 additions and 230 deletions

View File

@ -138,7 +138,7 @@ context('Network parameters page', { tags: '@smoke' }, function () {
}); });
}); });
it('should list each network parameter displayed as a currency value with four decimals - in the correct format', function () { it.skip('should list each network parameter displayed as a currency value with four decimals - in the correct format', function () {
cy.get_network_parameters().then((network_parameters) => { cy.get_network_parameters().then((network_parameters) => {
network_parameters = Object.entries(network_parameters); network_parameters = Object.entries(network_parameters);
network_parameters.forEach((network_parameter) => { network_parameters.forEach((network_parameter) => {

View File

@ -9,6 +9,7 @@ import {
import { isBefore, isAfter, addSeconds, subSeconds } from 'date-fns'; import { isBefore, isAfter, addSeconds, subSeconds } from 'date-fns';
import { createOrder } from '../support/create-order'; import { createOrder } from '../support/create-order';
import { connectEthereumWallet } from '../support/ethereum-wallet'; import { connectEthereumWallet } from '../support/ethereum-wallet';
import { selectAsset } from '../support/helpers';
const orderSize = 'size'; const orderSize = 'size';
const orderType = 'type'; const orderType = 'type';
@ -22,15 +23,13 @@ const assetSelectField = 'select[name="asset"]';
const amountField = 'input[name="amount"]'; const amountField = 'input[name="amount"]';
const txTimeout = Cypress.env('txTimeout'); const txTimeout = Cypress.env('txTimeout');
const sepoliaUrl = Cypress.env('ETHERSCAN_URL'); const sepoliaUrl = Cypress.env('ETHERSCAN_URL');
const btcName = const btcName = 0;
'BTC (local)5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c - tBTC'; const vegaName = 4;
const vegaName =
'Vegab4f2726571fbe8e33b442dc92ed2d7f0d810e21835b7371a7915a365f07ccd9b - VEGA';
const btcSymbol = 'tBTC'; const btcSymbol = 'tBTC';
const vegaSymbol = 'VEGA'; const vegaSymbol = 'VEGA';
const usdcSymbol = 'fUSDC'; const usdcSymbol = 'fUSDC';
const toastContent = 'toast-content'; const toastContent = 'toast-content';
const ordersTab = 'Orders'; const openOrdersTab = 'Open';
const depositsTab = 'Deposits'; const depositsTab = 'Deposits';
const collateralTab = 'Collateral'; const collateralTab = 'Collateral';
const toastCloseBtn = 'toast-close'; const toastCloseBtn = 'toast-close';
@ -50,6 +49,7 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => {
cy.get('@markets').then((markets) => { cy.get('@markets').then((markets) => {
cy.wrap(markets[0]).as('market'); cy.wrap(markets[0]).as('market');
}); });
cy.visit('/#/portfolio');
}); });
beforeEach(() => { beforeEach(() => {
@ -73,7 +73,7 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => {
cy.getByTestId(depositsTab).click(); cy.getByTestId(depositsTab).click();
cy.getByTestId('deposit-button').click(); cy.getByTestId('deposit-button').click();
connectEthereumWallet('Unknown'); connectEthereumWallet('Unknown');
cy.get(assetSelectField, txTimeout).select(btcName, { force: true }); selectAsset(btcName);
cy.getByTestId('approve-default').should( cy.getByTestId('approve-default').should(
'contain.text', 'contain.text',
`Before you can make a deposit of your chosen asset, ${btcSymbol}, you need to approve its use in your Ethereum wallet` `Before you can make a deposit of your chosen asset, ${btcSymbol}, you need to approve its use in your Ethereum wallet`
@ -81,6 +81,7 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => {
cy.getByTestId(approveSubmit).click(); cy.getByTestId(approveSubmit).click();
cy.getByTestId('approve-pending').should('exist'); cy.getByTestId('approve-pending').should('exist');
cy.getByTestId('approve-confirmed').should('exist'); cy.getByTestId('approve-confirmed').should('exist');
cy.get(amountField).focus();
cy.get(amountField).clear().type('10'); cy.get(amountField).clear().type('10');
cy.getByTestId(depositSubmit).click(); cy.getByTestId(depositSubmit).click();
cy.getByTestId(toastContent, txTimeout).should( cy.getByTestId(toastContent, txTimeout).should(
@ -115,7 +116,6 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => {
}); });
it('can key to key transfers', function () { it('can key to key transfers', function () {
cy.visit('/#/portfolio');
cy.get('main[data-testid="/portfolio"]').should('exist'); cy.get('main[data-testid="/portfolio"]').should('exist');
cy.getByTestId(collateralTab).click(); cy.getByTestId(collateralTab).click();
@ -147,8 +147,8 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => {
cy.getByTestId('Withdrawals').click(); cy.getByTestId('Withdrawals').click();
cy.getByTestId('withdraw-dialog-button').click(); cy.getByTestId('withdraw-dialog-button').click();
connectEthereumWallet('Unknown'); selectAsset(0);
cy.get(assetSelectField, txTimeout).select(btcName, { force: true }); cy.get(amountField).focus();
cy.get(amountField).clear().type('1'); cy.get(amountField).clear().type('1');
cy.getByTestId('submit-withdrawal').click(); cy.getByTestId('submit-withdrawal').click();
cy.getByTestId(toastContent, txTimeout).should( cy.getByTestId(toastContent, txTimeout).should(
@ -170,7 +170,7 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => {
cy.getByTestId(toastContent, txTimeout).should( cy.getByTestId(toastContent, txTimeout).should(
'contain.text', 'contain.text',
'Error occurredprocessing response error' 'Error occurredcannot estimate gas'
); );
cy.getByTestId(toastCloseBtn).click({ multiple: true }); cy.getByTestId(toastCloseBtn).click({ multiple: true });
cy.getByTestId(completeWithdrawalBtn).should( cy.getByTestId(completeWithdrawalBtn).should(
@ -180,7 +180,7 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => {
}); });
}); });
describe('capsule', { tags: '@slow' }, () => { describe('capsule', { tags: '@slow', testIsolation: true }, () => {
before(() => { before(() => {
cy.updateCapsuleMultiSig(); cy.updateCapsuleMultiSig();
}); });
@ -231,7 +231,7 @@ describe('capsule', { tags: '@slow' }, () => {
cy.getByTestId(toastContent).should( cy.getByTestId(toastContent).should(
'contain.text', 'contain.text',
`ConfirmedYour transaction has been confirmed View in block explorerSubmit order - activeTEST.24h+${order.size} @ ${order.price}.00 ${usdcSymbol}`, `Order submittedYour transaction has been confirmed View in block explorerSubmit order - activeTEST.24h+${order.size} @ ${order.price}.00 ${usdcSymbol}`,
{ matchCase: false } { matchCase: false }
); );
cy.getByTestId(toastCloseBtn).click(); cy.getByTestId(toastCloseBtn).click();
@ -242,9 +242,9 @@ describe('capsule', { tags: '@slow' }, () => {
.get(`[data-testid="bid-vol-${rawPrice}"]`) .get(`[data-testid="bid-vol-${rawPrice}"]`)
.should('contain.text', order.size); .should('contain.text', order.size);
cy.getByTestId(ordersTab).click(); cy.getByTestId(openOrdersTab).click();
cy.getByTestId('edit', txTimeout).should('contain.text', 'Edit'); cy.getByTestId('edit', txTimeout).should('contain.text', 'Edit');
cy.getByTestId('tab-orders').within(() => { cy.getByTestId('tab-open-orders').within(() => {
cy.get('.ag-center-cols-container') cy.get('.ag-center-cols-container')
.children() .children()
.first() .first()
@ -283,7 +283,9 @@ describe('capsule', { tags: '@slow' }, () => {
}); });
}); });
it('can edit order', function () { it('can edit order', function () {
cy.getByTestId(ordersTab).click(); const market = this.market;
cy.visit(`/#/markets/${market.id}`);
cy.getByTestId(openOrdersTab).click();
cy.getByTestId('edit').first().should('be.visible').click(); cy.getByTestId('edit').first().should('be.visible').click();
cy.getByTestId('dialog-title').should('contain.text', 'Edit order'); cy.getByTestId('dialog-title').should('contain.text', 'Edit order');
cy.get('#limitPrice').focus().clear().type(newPrice); cy.get('#limitPrice').focus().clear().type(newPrice);
@ -291,12 +293,12 @@ describe('capsule', { tags: '@slow' }, () => {
cy.getByTestId(toastContent).should( cy.getByTestId(toastContent).should(
'contain.text', 'contain.text',
`ConfirmedYour transaction has been confirmed View in block explorerEdit order - activeTEST.24h+${size} @ ${price}.00 ${usdcSymbol}+${size} @ ${newPrice}.00 ${usdcSymbol}`, `Order submittedYour transaction has been confirmed View in block explorerEdit order - activeTEST.24h+${size} @ ${price}.00 ${usdcSymbol}+${size} @ ${newPrice}.00 ${usdcSymbol}`,
{ matchCase: false } { matchCase: false }
); );
cy.getByTestId(toastCloseBtn).click({ multiple: true }); cy.getByTestId(toastCloseBtn).click({ multiple: true });
cy.getByTestId(ordersTab).click(); cy.getByTestId(openOrdersTab).click();
cy.get('.ag-center-cols-container') cy.get('.ag-center-cols-container')
.children() .children()
.first() .first()
@ -307,18 +309,20 @@ describe('capsule', { tags: '@slow' }, () => {
checkIfDataAndTimeOfCreationAndUpdateIsEqual(orderUpdatedAt); checkIfDataAndTimeOfCreationAndUpdateIsEqual(orderUpdatedAt);
}); });
}); });
// comment because of bug #2695
it.skip('can cancel order', function () { it('can cancel order', function () {
cy.getByTestId(ordersTab).click(); const market = this.market;
cy.visit(`/#/markets/${market.id}`);
cy.getByTestId(openOrdersTab).click();
cy.getByTestId('cancel').first().click(); cy.getByTestId('cancel').first().click();
cy.getByTestId(toastContent).should( cy.getByTestId(toastContent).should(
'contain.text', 'contain.text',
`ConfirmedYour transaction has been confirmed View in block explorerCancel order - cancelledTEST.24h+${size} @ ${newPrice}.00 ${usdcSymbol}`, `Order cancelledYour transaction has been confirmed View in block explorerCancel order - cancelledTEST.24h+${size} @ ${newPrice}.00 ${usdcSymbol}`,
{ matchCase: false } { matchCase: false }
); );
cy.getByTestId(toastCloseBtn).click({ multiple: true }); cy.getByTestId(toastCloseBtn).click({ multiple: true });
cy.getByTestId('Closed').click();
cy.getByTestId('tab-orders') cy.getByTestId('tab-closed-orders')
.get('.ag-center-cols-container') .get('.ag-center-cols-container')
.children() .children()
.first() .first()
@ -348,7 +352,7 @@ describe('capsule', { tags: '@slow' }, () => {
cy.getByTestId('Withdrawals').click(); cy.getByTestId('Withdrawals').click();
cy.getByTestId('withdraw-dialog-button').click(); cy.getByTestId('withdraw-dialog-button').click();
connectEthereumWallet('Unknown'); connectEthereumWallet('Unknown');
cy.get(assetSelectField, txTimeout).select(btcName, { force: true }); selectAsset(btcName);
cy.get(amountField).clear().type('1'); cy.get(amountField).clear().type('1');
cy.getByTestId('submit-withdrawal').click(); cy.getByTestId('submit-withdrawal').click();
cy.getByTestId(toastContent, txTimeout).should( cy.getByTestId(toastContent, txTimeout).should(
@ -371,19 +375,15 @@ describe('capsule', { tags: '@slow' }, () => {
'contain.text', 'contain.text',
'Transaction confirmed' 'Transaction confirmed'
); );
cy.getByTestId(toastCloseBtn).click({ multiple: true }); cy.getByTestId(toastContent, txTimeout).should(
'contain.text',
cy.wrap(null).then(() => { 'Funds unlockedYour funds have been unlocked for withdrawalView in block explorerWithdraw 1.00 tBTCComplete withdrawal'
try {
cy.getByTestId(completeWithdrawalBtn)
.eq(0, txTimeout)
.should('not.exist');
} catch (error) {
console.log(
'Assertion failed, but we are continuing because this is our wait to complete transaction'
); );
}
}); cy.get('.ag-center-cols-container')
.find('[col-id="status"]')
.eq(0, txTimeout)
.should('contain.text', 'Completed');
cy.get('[col-id="txHash"]', txTimeout) cy.get('[col-id="txHash"]', txTimeout)
.should('have.length.above', 1) .should('have.length.above', 1)
@ -404,17 +404,20 @@ describe('capsule', { tags: '@slow' }, () => {
.should('have.attr', 'href') .should('have.attr', 'href')
.and('contain', `${sepoliaUrl}/tx/0x`); .and('contain', `${sepoliaUrl}/tx/0x`);
}); });
// comment because of bug #2819
// cy.getByTestId('withdraw-dialog-button').click(); cy.getByTestId('withdraw-dialog-button').click({ force: true });
// cy.getByTestId('BALANCE_AVAILABLE_value').should('have.text', '0') cy.getByTestId('BALANCE_AVAILABLE_value').should('have.text', '7.999');
}); });
it('approved amount is less than deposit', function () { it('approved amount is less than deposit', function () {
// 1001-DEPO-006 // 1001-DEPO-006
// 1001-DEPO-007 // 1001-DEPO-007
cy.visit('/#/portfolio');
cy.get('main[data-testid="/portfolio"]').should('exist');
cy.getByTestId(depositsTab).click(); cy.getByTestId(depositsTab).click();
cy.getByTestId('deposit-button').click(); cy.getByTestId('deposit-button').click();
cy.get(assetSelectField, txTimeout).select(btcName, { force: true }); connectEthereumWallet('Unknown');
selectAsset(btcName);
cy.contains('Deposits of tBTC not approved').should('not.exist'); cy.contains('Deposits of tBTC not approved').should('not.exist');
cy.contains('Use maximum').should('be.visible'); cy.contains('Use maximum').should('be.visible');
cy.get(amountField).clear().type('20000000'); cy.get(amountField).clear().type('20000000');
@ -422,11 +425,7 @@ describe('capsule', { tags: '@slow' }, () => {
cy.getByTestId(depositSubmit).click(); cy.getByTestId(depositSubmit).click();
cy.getByTestId('input-error-text').should( cy.getByTestId('input-error-text').should(
'contain.text', 'contain.text',
'Amount is above approved amount' `You can't deposit more than you have in your Ethereum wallet`
);
cy.getByTestId('reapprove-default').should(
'contain.text',
'Approve again to deposit more than'
); );
}); });
@ -440,11 +439,11 @@ describe('capsule', { tags: '@slow' }, () => {
cy.getByTestId(depositsTab).click(); cy.getByTestId(depositsTab).click();
cy.getByTestId('deposit-button').click(); cy.getByTestId('deposit-button').click();
connectEthereumWallet('Unknown'); connectEthereumWallet('Unknown');
cy.get(assetSelectField, txTimeout).select(vegaName, { force: true }); selectAsset(vegaName);
cy.getByTestId('approve-submit').click(); cy.getByTestId('approve-submit').click();
cy.getByTestId('approve-confirmed').should( cy.getByTestId('approve-confirmed').should(
'contain.text', 'contain.text',
'You can now make deposits in VEGA, up to a maximum of' 'You approved deposits of up to VEGA'
); );
cy.get(amountField).clear().type('10000'); cy.get(amountField).clear().type('10000');
cy.getByTestId('deposit-submit').click(); cy.getByTestId('deposit-submit').click();
@ -478,9 +477,9 @@ describe('capsule', { tags: '@slow' }, () => {
.and('contain', `${sepoliaUrl}/tx/0x`); .and('contain', `${sepoliaUrl}/tx/0x`);
}); });
cy.getByTestId('Withdrawals').click(); cy.getByTestId('Withdrawals').click(txTimeout);
cy.getByTestId('withdraw-dialog-button').click(); cy.getByTestId('withdraw-dialog-button').click();
cy.get(assetSelectField, txTimeout).select(vegaName, { force: true }); selectAsset(1);
cy.get(amountField).clear().type('10000'); cy.get(amountField).clear().type('10000');
cy.getByTestId('DELAY_TIME_value').should('have.text', '5 days'); cy.getByTestId('DELAY_TIME_value').should('have.text', '5 days');
cy.getByTestId('submit-withdrawal').click(); cy.getByTestId('submit-withdrawal').click();

View File

@ -14,7 +14,10 @@ const itemHeader = 'item-header';
const itemValue = 'item-value'; const itemValue = 'item-value';
const marketListContent = 'popover-content'; const marketListContent = 'popover-content';
describe('Console - market list - live env', { tags: '@live' }, () => { describe(
'Console - market list - live env',
{ tags: '@live', testIsolation: true },
() => {
beforeEach(() => { beforeEach(() => {
cy.visit('/'); cy.visit('/');
}); });
@ -47,9 +50,13 @@ describe('Console - market list - live env', { tags: '@live' }, () => {
cy.contains('Loading...').should('not.exist'); cy.contains('Loading...').should('not.exist');
cy.getByTestId('popover-trigger').should('not.be.empty'); cy.getByTestId('popover-trigger').should('not.be.empty');
}); });
}); }
);
describe('Console - market info - live env', { tags: '@live' }, () => { describe(
'Console - market info - live env',
{ tags: '@live', testIsolation: true },
() => {
before(() => { before(() => {
cy.visit('/'); cy.visit('/');
cy.contains('Loading market data...').should('not.exist'); cy.contains('Loading market data...').should('not.exist');
@ -105,9 +112,13 @@ describe('Console - market info - live env', { tags: '@live' }, () => {
cy.get('[col-id="party.id"]').eq(1).should('not.be.empty'); cy.get('[col-id="party.id"]').eq(1).should('not.be.empty');
}); });
}); });
}); }
);
describe('Console - market summary - live env', { tags: '@live' }, () => { describe(
'Console - market summary - live env',
{ tags: '@live', testIsolation: true },
() => {
before(() => { before(() => {
cy.visit('/'); cy.visit('/');
cy.getByTestId('dialog-close').click(); cy.getByTestId('dialog-close').click();
@ -172,9 +183,13 @@ describe('Console - market summary - live env', { tags: '@live' }, () => {
}); });
}); });
}); });
}); }
);
describe('Console - markets table - live env', { tags: '@live' }, () => { describe(
'Console - markets table - live env',
{ tags: '@live', testIsolation: true },
() => {
beforeEach(() => { beforeEach(() => {
cy.visit('/'); cy.visit('/');
}); });
@ -217,7 +232,8 @@ describe('Console - markets table - live env', { tags: '@live' }, () => {
cy.getByTestId('popover-trigger').should('not.be.equal', marketName); cy.getByTestId('popover-trigger').should('not.be.equal', marketName);
}); });
}); });
}); }
);
function openMarketDropDown() { function openMarketDropDown() {
cy.contains('Loading...').should('not.exist'); cy.contains('Loading...').should('not.exist');