From 7edf4fc64c32312a2062ae9dc2144b57fc5ad2b8 Mon Sep 17 00:00:00 2001
From: Joe Tsang <30622993+jtsang586@users.noreply.github.com>
Date: Wed, 31 Aug 2022 11:47:08 +0100
Subject: [PATCH] test: margin positions and collateral tests added (#1204)
---
.../src/integration/trading-collateral.cy.ts | 32 +++++++++++++++++++
.../src/integration/trading-positions.cy.ts | 10 +++++-
.../src/support/mocks/generate-accounts.ts | 6 +++-
.../vega-wallet-connect-button.tsx | 2 +-
4 files changed, 47 insertions(+), 3 deletions(-)
create mode 100644 apps/trading-e2e/src/integration/trading-collateral.cy.ts
diff --git a/apps/trading-e2e/src/integration/trading-collateral.cy.ts b/apps/trading-e2e/src/integration/trading-collateral.cy.ts
new file mode 100644
index 000000000..229046660
--- /dev/null
+++ b/apps/trading-e2e/src/integration/trading-collateral.cy.ts
@@ -0,0 +1,32 @@
+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.visit('/markets/market-0');
+});
+
+describe('collateral', () => {
+ const collateralTab = 'Collateral';
+ const assetSymbolColumn = "[col-id='asset.symbol']";
+ const assetTypeColumn = "[col-id='type']";
+ const assetMarketName = "[col-id='market.name']";
+ it('renders collateral', () => {
+ connectVegaWallet();
+ cy.getByTestId(collateralTab).click();
+ cy.get(assetSymbolColumn).each(($symbol) => {
+ cy.wrap($symbol).invoke('text').should('not.be.empty');
+ });
+ 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/trading-positions.cy.ts b/apps/trading-e2e/src/integration/trading-positions.cy.ts
index 6eb1a7dd8..16fcf521e 100644
--- a/apps/trading-e2e/src/integration/trading-positions.cy.ts
+++ b/apps/trading-e2e/src/integration/trading-positions.cy.ts
@@ -28,11 +28,19 @@ describe('positions', () => {
.each(($openVolume) => {
cy.wrap($openVolume).invoke('text').should('not.be.empty');
});
- // includes average entry price, mark price & realised PNL
+ // includes average entry price, mark price, realised PNL & leverage
cy.getByTestId('tab-positions')
.getByTestId('flash-cell')
.each(($prices) => {
cy.wrap($prices).invoke('text').should('not.be.empty');
});
+
+ cy.get('[col-id="averageEntryPrice"]')
+ .should('contain.text', '11.29935') // entry price
+ .should('contain.text', '9.21954'); // liquidation price
+
+ cy.get('[col-id="capitalUtilisation"]') // margin allocated
+ .should('contain.text', '0.00%')
+ .should('contain.text', '1,000.01000');
});
});
diff --git a/apps/trading-e2e/src/support/mocks/generate-accounts.ts b/apps/trading-e2e/src/support/mocks/generate-accounts.ts
index a45143379..3c6d4e36e 100644
--- a/apps/trading-e2e/src/support/mocks/generate-accounts.ts
+++ b/apps/trading-e2e/src/support/mocks/generate-accounts.ts
@@ -27,7 +27,11 @@ export const generateAccounts = (
__typename: 'Account',
type: AccountType.ACCOUNT_TYPE_GENERAL,
balance: '100000000',
- market: null,
+ market: {
+ id: '0604e8c918655474525e1a95367902266ade70d318c2c908f0cca6e3d11dcb13',
+ name: 'AAVEDAI Monthly (30 Jun 2022)',
+ __typename: 'Market',
+ },
asset: {
__typename: 'Asset',
id: 'asset-id-2',
diff --git a/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx b/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx
index 188b6ee34..eb1b78ffa 100644
--- a/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx
+++ b/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx
@@ -49,7 +49,7 @@ export const VegaWalletConnectButton = ({
))}
-
+
{t('Disconnect')}