Fix/console failing tests (#1572)

* fix: market and trading tests

* fix: trading tests

* fix: balance DP

* fix: select asset

* fix: withdrawal tests

Co-authored-by: asiaznik <artur@vegaprotocol.io>
This commit is contained in:
Radosław Szpiech 2022-09-30 15:42:42 +02:00 committed by GitHub
parent d2a5adf6ce
commit 9a88c33458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 61 deletions

View File

@ -15,9 +15,7 @@ describe('markets table', { tags: '@regression' }, () => {
cy.wait('@Markets');
cy.wait('@MarketsDataQuery');
cy.wait('@MarketsCandlesQuery');
cy.get('[data-testid^="market-link-"]')
.should('not.be.empty')
.and('have.attr', 'href');
cy.get('[data-testid^="market-link-"]').should('not.be.empty');
cy.getByTestId('price').invoke('text').should('not.be.empty');
cy.getByTestId('settlement-asset').should('not.be.empty');
cy.getByTestId('price-change-percentage').should('not.be.empty');
@ -113,7 +111,7 @@ describe('markets table', { tags: '@regression' }, () => {
'contain.text',
'This market is in auction until it reaches sufficient liquidity.'
);
cy.getByTestId('link')
cy.getByTestId('external-link')
.should('have.attr', 'href')
.and(
'include',

View File

@ -1,38 +1,38 @@
import { MarketState } from '@vegaprotocol/types';
import { mockTradingPage } from '../support/trading';
import { connectVegaWallet } from '../support/vega-wallet';
import { connectEthereumWallet } from '../support/ethereum-wallet';
beforeEach(() => {
cy.mockGQL((req) => {
mockTradingPage(req, MarketState.STATE_ACTIVE);
});
cy.mockWeb3Provider();
cy.mockGQLSubscription();
cy.visit('/markets/market-0');
});
describe('accounts', { tags: '@smoke' }, () => {
it('renders accounts', () => {
const tradingAccountRowId = '[row-id="ACCOUNT_TYPE_GENERAL-asset-id-null"]';
const tradingAccountRowId = '[row-id="asset-0"]';
cy.getByTestId('Collateral').click();
cy.getByTestId('tab-accounts').contains('Please connect Vega wallet');
connectVegaWallet();
connectEthereumWallet();
cy.getByTestId('tab-accounts').should('be.visible');
cy.getByTestId('tab-accounts')
.should('be.visible')
.get(tradingAccountRowId)
.find('[col-id="asset.symbol"]')
.should('have.text', 'tEURO');
.should('have.text', 'AST0');
cy.getByTestId('tab-accounts')
.should('be.visible')
.get(tradingAccountRowId)
.find('[col-id="breakdown"]')
.should('have.text', 'Collateral breakdown');
cy.getByTestId('tab-accounts')
.should('be.visible')
.get(tradingAccountRowId)
.find('[col-id="deposited"]')
.should('have.text', '1,000.00000');

View File

@ -1,32 +0,0 @@
import { MarketState } from '@vegaprotocol/types';
import { mockTradingPage } from '../support/trading';
import { connectVegaWallet } from '../support/vega-wallet';
beforeEach(() => {
cy.mockGQL((req) => {
mockTradingPage(req, MarketState.STATE_ACTIVE);
});
cy.mockGQLSubscription();
cy.visit('/markets/market-0');
});
describe('collateral', { tags: '@smoke' }, () => {
const collateralTab = 'Collateral';
const assetSymbolColumn = "[col-id='asset.symbol']";
const assetTypeColumn = "[col-id='type']";
const assetMarketName =
"[col-id='market.tradableInstrument.instrument.name']";
it('renders collateral', () => {
connectVegaWallet();
cy.getByTestId(collateralTab).click();
cy.getByTestId(assetSymbolColumn).first().click();
cy.get(assetTypeColumn).should('contain.text', 'General');
cy.get(assetMarketName).should(
'contain.text',
'AAVEDAI Monthly (30 Jun 2022)'
);
cy.getByTestId('price').each(($price) => {
cy.wrap($price).invoke('text').should('not.be.empty');
});
});
});

View File

@ -50,27 +50,30 @@ describe('withdraw', { tags: '@smoke' }, () => {
// Test for Ethereum address
cy.get(toAddressField).should('have.value', ethAddressValue);
// Test min amount
cy.get(assetSelectField).select('Asset 1'); // Select asset so we have a min viable amount calculated
cy.get(amountField)
.clear()
.type('0')
.next('[data-testid="input-error-text"]')
.should('contain.text', 'Value is below minimum');
// Test max amount
cy.get(amountField)
.clear()
.type('1') // Will be above maximum because the vega wallet doesnt have any collateral
.next('[data-testid="input-error-text"]')
.should('contain.text', 'Insufficient amount in account');
});
it('min amount', () => {
cy.get(assetSelectField).select('Asset 0'); // Select asset so we have a min viable amount calculated
cy.get(amountField).clear().type('0');
cy.getByTestId(submitWithdrawBtn).click();
cy.get('[data-testid="input-error-text"]').should(
'contain.text',
'Value is below minimum'
);
});
it('max amount', () => {
cy.get(assetSelectField).select('Asset 1'); // Will be above maximum because the vega wallet doesnt have any collateral
cy.get(amountField).clear().type('1');
cy.getByTestId(submitWithdrawBtn).click();
cy.get('[data-testid="input-error-text"]').should(
'contain.text',
'Insufficient amount in account'
);
});
it('can set amount using use maximum button', () => {
cy.get(assetSelectField).select('Asset 0');
cy.getByTestId(useMaximumAmount).click();
cy.get(amountField).should('have.value', '1,000.00000');
cy.get(amountField).should('have.value', '1000.00000');
});
it('triggers transaction when submitted', () => {
@ -87,7 +90,7 @@ describe('withdraw', { tags: '@smoke' }, () => {
cy.getByTestId('balance-available')
.should('contain.text', 'Balance available')
.find('td')
.should('have.text', '1,000');
.should('have.text', '1,000.00000');
cy.getByTestId('withdrawal-threshold')
.should('contain.text', 'Delayed withdrawal threshold')
.find('td')

View File

@ -1,4 +1,5 @@
import type { Asset } from '@vegaprotocol/react-helpers';
import { formatNumber } from '@vegaprotocol/react-helpers';
import {
ethereumAddress,
minSafe,
@ -113,6 +114,7 @@ export const WithdrawForm = ({
value={selectedAsset?.id || ''}
id="asset"
name="asset"
required
>
<option value="">{t('Please select')}</option>
{assets.filter(isAssetTypeERC20).map((a) => (
@ -145,7 +147,7 @@ export const WithdrawForm = ({
amount={amount}
threshold={threshold}
delay={delay}
balance={balance}
balance={formatNumber(balance, selectedAsset.decimals)}
/>
</div>
)}

View File

@ -5,7 +5,7 @@ import { formatDistanceToNow } from 'date-fns';
interface WithdrawLimitsProps {
amount: string;
threshold: BigNumber;
balance: BigNumber;
balance: string;
delay: number | undefined;
}
@ -35,7 +35,7 @@ export const WithdrawLimits = ({
<tbody>
<tr data-testid="balance-available">
<th className="text-left font-normal">{t('Balance available')}</th>
<td className="text-right">{balance.toString()}</td>
<td className="text-right">{balance}</td>
</tr>
<tr data-testid="withdrawal-threshold">
<th className="text-left font-normal">