From 5e558c4cd3c3fecac462b50873119b295f8296c9 Mon Sep 17 00:00:00 2001 From: daro-maj <119658839+daro-maj@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:28:25 +0200 Subject: [PATCH] test(trading): 7001-COLL-collateral - e2e tests (#3561) Co-authored-by: m.ray <16125548+MadalinaRaicu@users.noreply.github.com> --- .../src/integration/trading-accounts.cy.ts | 82 +++++++++++++++++-- .../trading-deal-ticket-order.cy.ts | 13 +++ .../src/integration/trading-orders.cy.ts | 2 +- libs/accounts/src/lib/accounts-table.tsx | 6 +- 4 files changed, 96 insertions(+), 7 deletions(-) diff --git a/apps/trading-e2e/src/integration/trading-accounts.cy.ts b/apps/trading-e2e/src/integration/trading-accounts.cy.ts index fd0234641..8b337fa8c 100644 --- a/apps/trading-e2e/src/integration/trading-accounts.cy.ts +++ b/apps/trading-e2e/src/integration/trading-accounts.cy.ts @@ -1,17 +1,23 @@ import { checkSorting } from '@vegaprotocol/cypress'; describe('accounts', { tags: '@smoke' }, () => { - before(() => { - cy.clearAllLocalStorage(); + beforeEach(() => { cy.mockTradingPage(); cy.mockWeb3Provider(); cy.mockSubscription(); cy.setVegaWallet(); cy.visit('/#/markets/market-0'); - cy.wait('@Assets'); }); it('renders accounts', () => { + // 7001-COLL-001 + // 7001-COLL-002 + // 7001-COLL-003 + // 7001-COLL-004 + // 7001-COLL-005 + // 7001-COLL-006 + // 7001-COLL-007 + const tradingAccountRowId = '[row-id="t-0"]'; cy.getByTestId('Collateral').click(); @@ -22,6 +28,21 @@ describe('accounts', { tags: '@smoke' }, () => { .find('[col-id="asset.symbol"]') .should('have.text', 'AST0'); + cy.getByTestId('tab-accounts') + .get(tradingAccountRowId) + .find('[col-id="used"]') + .should('have.text', '1.010.00%'); + + cy.getByTestId('tab-accounts') + .get(tradingAccountRowId) + .find('[col-id="available"]') + .should('have.text', '100,000.00'); + + cy.getByTestId('tab-accounts') + .get(tradingAccountRowId) + .find('[col-id="total"]') + .should('have.text', '100,001.01'); + cy.getByTestId('tab-accounts') .get(tradingAccountRowId) .find('[col-id="accounts-actions"]') @@ -31,12 +52,63 @@ describe('accounts', { tags: '@smoke' }, () => { .get(tradingAccountRowId) .find('[col-id="total"]') .should('have.text', '100,001.01'); + + cy.getByTestId('tab-accounts') + .get('[col-id="accounts-actions"]') + .find('[data-testid="dropdown-menu"]') + .eq(1) + .click(); + cy.getByTestId('deposit').should('be.visible'); + cy.getByTestId('withdraw').should('be.visible'); + cy.getByTestId('breakdown').should('be.visible'); + cy.getByTestId('Collateral').click({ force: true }); }); it('should open asset details dialog when clicked on symbol', () => { + // 7001-COLL-008 cy.getByTestId('asset').contains('tEURO').click(); - cy.get('[data-testid="dialog-content"]:visible').should('exist'); - cy.get('[data-testid="dialog-close"]:visible').click(); + cy.get('[data-testid$="_label"]').should('have.length', 16); + cy.get('[data-testid="dialog-close"]').click(); + }); + + it('should open asset details dialog when clicked on symbol', () => { + // 7001-COLL-008 + cy.getByTestId('asset').contains('tEURO').click(); + cy.get('[data-testid$="_label"]').should('have.length', 16); + cy.get('[data-testid="dialog-close"]').click(); + }); + + it('should open usage breakdown dialog when clicked on used', () => { + // 7001-COLL-009 + cy.getByTestId('breakdown').contains('1.01').click(); + const headers = ['Market', 'Account type', 'Balance']; + cy.getByTestId('usage-breakdown').within(($headers) => { + cy.wrap($headers) + .get('.ag-header-cell-text') + .each(($header, i) => { + cy.wrap($header).should('have.text', headers[i]); + }); + }); + cy.get('[data-testid="dialog-close"]').click(); + }); + + it('sorting usage breakdown columns should work well', () => { + // 7001-COLL-010 + cy.getByTestId('breakdown').contains('1.01').click(); + cy.getByTestId('usage-breakdown') + .find('[col-id="type"]') + .eq(1) + .should('have.text', 'Margin'); + cy.getByTestId('usage-breakdown') + .find('[col-id="type"]') + .eq(2) + .should('have.text', 'Margin'); + cy.getByTestId('usage-breakdown') + .find('[col-id="type"]') + .eq(3) + .should('have.text', 'General'); + + cy.get('[data-testid="dialog-close"]').click(); }); describe('sorting by ag-grid columns should work well', () => { diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts index 1c74e5415..418d1c290 100644 --- a/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts @@ -88,5 +88,18 @@ describe('deal ticker order validation', { tags: '@smoke' }, () => { 'Size cannot be lower than 1' ); }); + it('must have total margin available', () => { + // 7001-COLL-011 + cy.getByTestId('tab-ticket') + .find('.text-xs') + .eq(5) + .within(() => { + cy.get('[data-state="closed"]').should( + 'have.text', + 'Total margin available' + ); + cy.get('.text-neutral-500').should('have.text', '~100,000.01 tDAI'); + }); + }); }); }); diff --git a/apps/trading-e2e/src/integration/trading-orders.cy.ts b/apps/trading-e2e/src/integration/trading-orders.cy.ts index f3a459f7a..8d8524f8b 100644 --- a/apps/trading-e2e/src/integration/trading-orders.cy.ts +++ b/apps/trading-e2e/src/integration/trading-orders.cy.ts @@ -455,7 +455,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => { }); }); it('must be warned (pre-submit) if the input price has too many digits after the decimal place for the market', () => { - // 7003-MORD-016 + // 7003-MORD-013 updateOrder({ id: orderId, status: Schema.OrderStatus.STATUS_ACTIVE, diff --git a/libs/accounts/src/lib/accounts-table.tsx b/libs/accounts/src/lib/accounts-table.tsx index ff820a428..170abbc17 100644 --- a/libs/accounts/src/lib/accounts-table.tsx +++ b/libs/accounts/src/lib/accounts-table.tsx @@ -299,6 +299,7 @@ export const AccountTable = forwardRef( } > @@ -359,7 +360,10 @@ export const AccountTable = forwardRef( } -
+

{row?.asset?.symbol} {t('usage breakdown')}