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

View File

@ -1,38 +1,38 @@
import { MarketState } from '@vegaprotocol/types'; import { MarketState } from '@vegaprotocol/types';
import { mockTradingPage } from '../support/trading'; import { mockTradingPage } from '../support/trading';
import { connectVegaWallet } from '../support/vega-wallet'; import { connectVegaWallet } from '../support/vega-wallet';
import { connectEthereumWallet } from '../support/ethereum-wallet';
beforeEach(() => { beforeEach(() => {
cy.mockGQL((req) => { cy.mockGQL((req) => {
mockTradingPage(req, MarketState.STATE_ACTIVE); mockTradingPage(req, MarketState.STATE_ACTIVE);
}); });
cy.mockWeb3Provider();
cy.mockGQLSubscription(); cy.mockGQLSubscription();
cy.visit('/markets/market-0'); cy.visit('/markets/market-0');
}); });
describe('accounts', { tags: '@smoke' }, () => { describe('accounts', { tags: '@smoke' }, () => {
it('renders accounts', () => { 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('Collateral').click();
cy.getByTestId('tab-accounts').contains('Please connect Vega wallet'); cy.getByTestId('tab-accounts').contains('Please connect Vega wallet');
connectVegaWallet(); connectVegaWallet();
connectEthereumWallet();
cy.getByTestId('tab-accounts').should('be.visible'); cy.getByTestId('tab-accounts').should('be.visible');
cy.getByTestId('tab-accounts') cy.getByTestId('tab-accounts')
.should('be.visible')
.get(tradingAccountRowId) .get(tradingAccountRowId)
.find('[col-id="asset.symbol"]') .find('[col-id="asset.symbol"]')
.should('have.text', 'tEURO'); .should('have.text', 'AST0');
cy.getByTestId('tab-accounts') cy.getByTestId('tab-accounts')
.should('be.visible')
.get(tradingAccountRowId) .get(tradingAccountRowId)
.find('[col-id="breakdown"]') .find('[col-id="breakdown"]')
.should('have.text', 'Collateral breakdown'); .should('have.text', 'Collateral breakdown');
cy.getByTestId('tab-accounts') cy.getByTestId('tab-accounts')
.should('be.visible')
.get(tradingAccountRowId) .get(tradingAccountRowId)
.find('[col-id="deposited"]') .find('[col-id="deposited"]')
.should('have.text', '1,000.00000'); .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 // Test for Ethereum address
cy.get(toAddressField).should('have.value', ethAddressValue); cy.get(toAddressField).should('have.value', ethAddressValue);
});
// Test min amount it('min amount', () => {
cy.get(assetSelectField).select('Asset 1'); // Select asset so we have a min viable amount calculated cy.get(assetSelectField).select('Asset 0'); // Select asset so we have a min viable amount calculated
cy.get(amountField) cy.get(amountField).clear().type('0');
.clear() cy.getByTestId(submitWithdrawBtn).click();
.type('0') cy.get('[data-testid="input-error-text"]').should(
.next('[data-testid="input-error-text"]') 'contain.text',
.should('contain.text', 'Value is below minimum'); 'Value is below minimum'
);
// Test max amount });
cy.get(amountField) it('max amount', () => {
.clear() cy.get(assetSelectField).select('Asset 1'); // Will be above maximum because the vega wallet doesnt have any collateral
.type('1') // Will be above maximum because the vega wallet doesnt have any collateral cy.get(amountField).clear().type('1');
.next('[data-testid="input-error-text"]') cy.getByTestId(submitWithdrawBtn).click();
.should('contain.text', 'Insufficient amount in account'); cy.get('[data-testid="input-error-text"]').should(
'contain.text',
'Insufficient amount in account'
);
}); });
it('can set amount using use maximum button', () => { it('can set amount using use maximum button', () => {
cy.get(assetSelectField).select('Asset 0'); cy.get(assetSelectField).select('Asset 0');
cy.getByTestId(useMaximumAmount).click(); 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', () => { it('triggers transaction when submitted', () => {
@ -87,7 +90,7 @@ describe('withdraw', { tags: '@smoke' }, () => {
cy.getByTestId('balance-available') cy.getByTestId('balance-available')
.should('contain.text', 'Balance available') .should('contain.text', 'Balance available')
.find('td') .find('td')
.should('have.text', '1,000'); .should('have.text', '1,000.00000');
cy.getByTestId('withdrawal-threshold') cy.getByTestId('withdrawal-threshold')
.should('contain.text', 'Delayed withdrawal threshold') .should('contain.text', 'Delayed withdrawal threshold')
.find('td') .find('td')

View File

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

View File

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