diff --git a/apps/trading-e2e/src/integration/markets.cy.ts b/apps/trading-e2e/src/integration/markets.cy.ts index ea171b8a5..7603bd2bc 100644 --- a/apps/trading-e2e/src/integration/markets.cy.ts +++ b/apps/trading-e2e/src/integration/markets.cy.ts @@ -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', diff --git a/apps/trading-e2e/src/integration/trading-accounts.cy.ts b/apps/trading-e2e/src/integration/trading-accounts.cy.ts index 6188dadad..dbbbfed52 100644 --- a/apps/trading-e2e/src/integration/trading-accounts.cy.ts +++ b/apps/trading-e2e/src/integration/trading-accounts.cy.ts @@ -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'); diff --git a/apps/trading-e2e/src/integration/trading-collateral.cy.ts b/apps/trading-e2e/src/integration/trading-collateral.cy.ts deleted file mode 100644 index b1368cd8c..000000000 --- a/apps/trading-e2e/src/integration/trading-collateral.cy.ts +++ /dev/null @@ -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'); - }); - }); -}); diff --git a/apps/trading-e2e/src/integration/withdraw.cy.ts b/apps/trading-e2e/src/integration/withdraw.cy.ts index 253174a18..613a8192b 100644 --- a/apps/trading-e2e/src/integration/withdraw.cy.ts +++ b/apps/trading-e2e/src/integration/withdraw.cy.ts @@ -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') diff --git a/libs/withdraws/src/lib/withdraw-form.tsx b/libs/withdraws/src/lib/withdraw-form.tsx index 7e1c1298b..c8846568a 100644 --- a/libs/withdraws/src/lib/withdraw-form.tsx +++ b/libs/withdraws/src/lib/withdraw-form.tsx @@ -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 > {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)} /> )} diff --git a/libs/withdraws/src/lib/withdraw-limits.tsx b/libs/withdraws/src/lib/withdraw-limits.tsx index 16c006b52..cd94fc799 100644 --- a/libs/withdraws/src/lib/withdraw-limits.tsx +++ b/libs/withdraws/src/lib/withdraw-limits.tsx @@ -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 = ({ {t('Balance available')} - {balance.toString()} + {balance}