From 3c88cf48eeec44e19edc4b16551387ca879c8f47 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Thu, 6 Jul 2023 11:44:31 -0700 Subject: [PATCH] test: updates to ensure e2e tests run --- .../trading-e2e/src/integration/capsule.cy.ts | 2 +- .../src/integration/market-liquidity.cy.ts | 9 ++-- .../src/integration/market-selector.cy.ts | 41 ++++++++----------- apps/trading-e2e/src/integration/navbar.cy.ts | 3 -- .../src/integration/order-book.cy.ts | 12 +++--- .../src/integration/settings.cy.ts | 40 +++++------------- .../trading-deal-ticket-submit-account.cy.ts | 4 +- .../src/integration/trading-trades.cy.ts | 1 + .../src/integration/withdraw-key-to-key.cy.ts | 27 ++++++------ .../src/integration/withdraw.cy.ts | 10 +++-- .../client-pages/liquidity/liquidity.tsx | 6 ++- .../vega-wallet-connect-button.tsx | 10 +++-- libs/accounts/src/lib/transfer-container.tsx | 2 +- 13 files changed, 73 insertions(+), 94 deletions(-) diff --git a/apps/trading-e2e/src/integration/capsule.cy.ts b/apps/trading-e2e/src/integration/capsule.cy.ts index 023917ba0..65b651951 100644 --- a/apps/trading-e2e/src/integration/capsule.cy.ts +++ b/apps/trading-e2e/src/integration/capsule.cy.ts @@ -120,7 +120,7 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => { cy.get('main[data-testid="/portfolio"]').should('exist'); cy.getByTestId(collateralTab).click(); - cy.getByTestId('open-transfer-dialog').click(); + cy.getByTestId('open-transfer').click(); cy.getByTestId('transfer-form').should('be.visible'); cy.getByTestId('transfer-form').find('[name="toAddress"]').select(1); cy.get('select option') diff --git a/apps/trading-e2e/src/integration/market-liquidity.cy.ts b/apps/trading-e2e/src/integration/market-liquidity.cy.ts index 637bc0e13..2983b80ea 100644 --- a/apps/trading-e2e/src/integration/market-liquidity.cy.ts +++ b/apps/trading-e2e/src/integration/market-liquidity.cy.ts @@ -132,9 +132,10 @@ describe('liquidity table view', { tags: '@smoke' }, () => { it('can see header title', () => { // 5002-LIQP-004 // 5002-LIQP-005 - cy.getByTestId('header-title') - .should('contain.text', 'BTCUSD.MF21 liquidity provision') - .and('contain.text', 'Go to trading'); + cy.getByTestId('header-title').should( + 'contain.text', + 'BTCUSD.MF21 liquidity provision' + ); }); it('can see target stake', () => { @@ -171,7 +172,7 @@ describe('liquidity table view', { tags: '@smoke' }, () => { cy.getByTestId('liquidity-supplied').within(() => { cy.getByTestId(itemHeader).should('have.text', 'Liquidity supplied'); cy.getByTestId('indicator').should('be.visible'); - cy.getByTestId(itemValue).should('have.text', '0.10%').realHover(); + cy.getByTestId(itemValue).should('have.text', ' 0.10%').realHover(); }); }); }); diff --git a/apps/trading-e2e/src/integration/market-selector.cy.ts b/apps/trading-e2e/src/integration/market-selector.cy.ts index 2141aa02d..d9e6ef7ad 100644 --- a/apps/trading-e2e/src/integration/market-selector.cy.ts +++ b/apps/trading-e2e/src/integration/market-selector.cy.ts @@ -22,15 +22,12 @@ describe('markets selector', { tags: '@smoke' }, () => { cy.wait('@Markets'); cy.wait('@MarketsData'); - cy.wait('@MarketsCandles'); }); // 6001-MARK-066 - it('can toggle the sidebar', () => { - cy.getByTestId('market-selector').should('be.visible'); - cy.getByTestId('sidebar-toggle').click(); + it('can open popover to view markets', () => { cy.getByTestId('market-selector').should('not.exist'); - cy.getByTestId('sidebar-toggle').click(); + cy.getByTestId('header-title').should('be.visible').click(); cy.getByTestId('market-selector').should('be.visible'); }); @@ -40,29 +37,30 @@ describe('markets selector', { tags: '@smoke' }, () => { const data = [ { code: 'SOLUSD', - markPrice: '84.41XYZalpha', + markPrice: 'XYZalpha84.41', change: '', - vol: '0.0024h vol', + vol: '24h vol0.00', }, { code: 'ETHBTC.QM21', - markPrice: '46,126.90058tBTC', + markPrice: 'tBTC46,126.90058', change: '', - vol: '0.0024h vol', + vol: '24h vol0.00', }, { code: 'BTCUSD.MF21', - markPrice: '46,126.90058tDAI', + markPrice: 'tDAI46,126.90058', change: '', - vol: '0.0024h vol', + vol: '24h vol0.00', }, { code: 'AAPL.MF21', - markPrice: '46,126.90058tUSDC', + markPrice: 'tUSDC46,126.90058', change: '', - vol: '0.0024h vol', + vol: '24h vol0.00', }, ]; + cy.getByTestId('header-title').should('be.visible').click(); cy.getByTestId(list) .find('a') .each((item, i) => { @@ -86,18 +84,9 @@ describe('markets selector', { tags: '@smoke' }, () => { }); }); - it('can see all markets link', () => { - // 6001-MARK-026 - cy.getByTestId('market-selector').within(() => { - cy.getByTestId('all-markets-link') - .should('be.visible') - .and('have.text', 'All markets') - .and('have.attr', 'href') - .and('contain', '#/markets/all'); - }); - }); - it('can use the filter options', () => { + cy.getByTestId('header-title').should('be.visible').click(); + // 6001-MARK-027 // product type cy.getByTestId('product-Spot').click(); @@ -118,6 +107,8 @@ describe('markets selector', { tags: '@smoke' }, () => { }); it('can sort by by top gaining and top losing market', () => { + cy.getByTestId('header-title').should('be.visible').click(); + // 6001-MARK-030 // 6001-MARK-031 // 6001-MARK-032 @@ -135,6 +126,8 @@ describe('markets selector', { tags: '@smoke' }, () => { }); it('can filter by settlement asset', () => { + cy.getByTestId('header-title').should('be.visible').click(); + // 6001-MARK-028 cy.getByTestId('asset-trigger').click(); cy.getByTestId('asset-id-asset-3').contains('tBTC').click(); diff --git a/apps/trading-e2e/src/integration/navbar.cy.ts b/apps/trading-e2e/src/integration/navbar.cy.ts index 65aeb8104..262478610 100644 --- a/apps/trading-e2e/src/integration/navbar.cy.ts +++ b/apps/trading-e2e/src/integration/navbar.cy.ts @@ -99,9 +99,6 @@ describe('Navbar', { tags: '@smoke' }, () => { cy.getByTestId('menu-drawer').should('not.be.visible'); cy.getByTestId('button-menu-drawer').click(); cy.getByTestId('menu-drawer').should('be.visible'); - cy.getByTestId('menu-drawer') - .find('[data-testid="Settings"]') - .should('be.visible'); cy.getByTestId('button-menu-drawer').click(); cy.getByTestId('menu-drawer').should('not.be.visible'); }); diff --git a/apps/trading-e2e/src/integration/order-book.cy.ts b/apps/trading-e2e/src/integration/order-book.cy.ts index 776a003ea..557df9bfe 100644 --- a/apps/trading-e2e/src/integration/order-book.cy.ts +++ b/apps/trading-e2e/src/integration/order-book.cy.ts @@ -1,10 +1,10 @@ const orderbookTab = 'Orderbook'; const orderbookTable = 'tab-orderbook'; -const askPrice = 'price-9894585'; +const askPrice = 'price-9894185'; const bidPrice = 'price-9889001'; -const askVolume = 'ask-vol-9894585'; +const askVolume = 'ask-vol-9894185'; const bidVolume = 'bid-vol-9889001'; -const askCumulative = 'cumulative-vol-9894585'; +const askCumulative = 'cumulative-vol-9894185'; const bidCumulative = 'cumulative-vol-9889001'; const midPrice = 'middle-mark-price-4612690000'; const priceResolution = 'resolution'; @@ -34,7 +34,7 @@ describe('order book', { tags: '@smoke' }, () => { it('show orders prices', () => { // 6003-ORDB-003 - cy.getByTestId(askPrice).should('have.text', '98.94585'); + cy.getByTestId(askPrice).should('have.text', '98.94185'); cy.getByTestId(bidPrice).should('have.text', '98.89001'); }); @@ -46,7 +46,7 @@ describe('order book', { tags: '@smoke' }, () => { it('show prices cumulative volumes', () => { // 6003-ORDB-005 - cy.getByTestId(askCumulative).should('have.text', '39'); + cy.getByTestId(askCumulative).should('have.text', '38'); cy.getByTestId(bidCumulative).should('have.text', '7'); }); @@ -72,7 +72,7 @@ describe('order book', { tags: '@smoke' }, () => { it('copy price to deal ticket form', () => { // 6003-ORDB-009 cy.getByTestId(askPrice).click(); - cy.getByTestId(dealTicketPrice).should('have.value', '98.94585'); + cy.getByTestId(dealTicketPrice).should('have.value', '98.94185'); }); it('copy size to deal ticket form', () => { diff --git a/apps/trading-e2e/src/integration/settings.cy.ts b/apps/trading-e2e/src/integration/settings.cy.ts index 9d980db6d..615d4636a 100644 --- a/apps/trading-e2e/src/integration/settings.cy.ts +++ b/apps/trading-e2e/src/integration/settings.cy.ts @@ -4,39 +4,21 @@ describe('Settings page', { tags: '@smoke' }, () => { cy.mockTradingPage(); cy.mockSubscription(); cy.visit('/'); - cy.get('[aria-label="cog icon"]').click(); + cy.getByTestId('Settings').click(); }); }); it('telemetry checkbox should work well', () => { - cy.location('hash').should('equal', '#/settings'); - cy.getByTestId('telemetry-approval').should( - 'have.attr', - 'data-state', - 'unchecked' - ); - cy.get('[for="telemetry-approval"]').click(); - cy.getByTestId('telemetry-approval').should( - 'have.attr', - 'data-state', - 'checked' - ); + const telemetrySwitch = '#switch-settings-telemetry-switch'; + cy.get(telemetrySwitch).should('have.attr', 'data-state', 'unchecked'); + cy.get(telemetrySwitch).click(); + cy.get(telemetrySwitch).should('have.attr', 'data-state', 'checked'); cy.reload(); - cy.getByTestId('telemetry-approval').should( - 'have.attr', - 'data-state', - 'checked' - ); - cy.get('[for="telemetry-approval"]').click(); - cy.getByTestId('telemetry-approval').should( - 'have.attr', - 'data-state', - 'unchecked' - ); + cy.getByTestId('Settings').click(); + cy.get(telemetrySwitch).should('have.attr', 'data-state', 'checked'); + cy.get(telemetrySwitch).click(); + cy.get(telemetrySwitch).should('have.attr', 'data-state', 'unchecked'); cy.reload(); - cy.getByTestId('telemetry-approval').should( - 'have.attr', - 'data-state', - 'unchecked' - ); + cy.getByTestId('Settings').click(); + cy.get(telemetrySwitch).should('have.attr', 'data-state', 'unchecked'); }); }); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts index d1963dacd..ce7d9800e 100644 --- a/apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts @@ -74,8 +74,8 @@ describe( 'You may not have enough margin available to open this position. 5.00 tDAI is currently required. You have only 0.01001 tDAI available.' ); cy.getByTestId('deal-ticket-deposit-dialog-button').click(); - cy.getByTestId('dialog-content') - .find('h1') + cy.getByTestId('sidebar-content') + .find('h2') .eq(0) .should('have.text', 'Deposit'); }); diff --git a/apps/trading-e2e/src/integration/trading-trades.cy.ts b/apps/trading-e2e/src/integration/trading-trades.cy.ts index c9aa56d50..80e4d9bdb 100644 --- a/apps/trading-e2e/src/integration/trading-trades.cy.ts +++ b/apps/trading-e2e/src/integration/trading-trades.cy.ts @@ -72,6 +72,7 @@ describe('trades', { tags: '@smoke' }, () => { }); it.skip('copy price to deal ticket form', () => { + cy.getByTestId('order-type-TYPE_LIMIT').click(); // make sure on limit // 6005-THIS-007 cy.get(colIdPrice).last().should('be.visible').click(); cy.getByTestId('order-price').should('have.value', '171.16898'); diff --git a/apps/trading-e2e/src/integration/withdraw-key-to-key.cy.ts b/apps/trading-e2e/src/integration/withdraw-key-to-key.cy.ts index f69b0da10..afbd3e70f 100644 --- a/apps/trading-e2e/src/integration/withdraw-key-to-key.cy.ts +++ b/apps/trading-e2e/src/integration/withdraw-key-to-key.cy.ts @@ -5,16 +5,15 @@ const amountShortName = 'input[name="amount"] + div + span.text-xs'; const assetSelection = 'select-asset'; const assetBalance = 'asset-balance'; const assetOption = 'rich-select-option'; -const closeDialog = 'dialog-close'; -const dialogTitle = 'dialog-title'; -const dialogTransferText = 'dialog-transfer-text'; +const sidebarButton = 'Transfer'; +const transferText = 'transfer-intro-text'; const dropdownMenu = 'dropdown-menu'; const errorText = 'input-error-text'; const formFieldError = 'input-error-text'; const includeTransferFeeRadioBtn = 'include-transfer-fee'; -const keyID = '[data-testid="dialog-transfer-text"] > .rounded-md'; +const keyID = `[data-testid="${transferText}"] > .rounded-md`; const manageVegaWallet = 'manage-vega-wallet'; -const openTransferDialog = 'open-transfer-dialog'; +const openTransferButton = 'open-transfer'; const submitTransferBtn = '[type="submit"]'; const toAddressField = '[name="toAddress"]'; const totalTransferfee = 'total-transfer-fee'; @@ -39,14 +38,15 @@ describe('transfer fees', { tags: '@regression', testIsolation: true }, () => { cy.mockSubscription(); cy.setVegaWallet(); - cy.visit('/#/portfolio'); - cy.getByTestId('Trading').first().click(); + cy.visit('/'); + + cy.wait('@Accounts'); + cy.wait('@Assets'); + cy.getByTestId(collateralTab).click(); cy.getByTestId(dropdownMenu).first().click(); cy.getByTestId(transfer).click(); - cy.wait('@Accounts'); - cy.wait('@Assets'); cy.mockVegaWalletTransaction(); }); @@ -72,21 +72,18 @@ describe('transfer fees', { tags: '@regression', testIsolation: true }, () => { cy.get('[data-side="bottom"] div') .should('be.visible') .should('not.be.empty'); - cy.getByTestId(dialogTitle).click(); //Check Transfer Fee tooltip cy.contains('div', 'Transfer fee').realHover(); cy.get('[data-side="bottom"] div') .should('be.visible') .should('not.be.empty'); - cy.getByTestId(dialogTitle).click(); //Check Amount to be transferred tooltip cy.contains('div', 'Amount to be transferred').realHover(); cy.get('[data-side="bottom"] div') .should('be.visible') .should('not.be.empty'); - cy.getByTestId(dialogTitle).click(); //Check Total amount (with fee) tooltip cy.contains('div', 'Total amount (with fee)').realHover(); @@ -134,6 +131,7 @@ describe('transfer fees', { tags: '@regression', testIsolation: true }, () => { .should('contain.text', '1.00'); }); }); + describe( 'transfer form validation', { tags: '@regression', testIsolation: true }, @@ -154,7 +152,7 @@ describe( it('transfer Text', () => { // 1003-TRAN-003 - cy.getByTestId(dialogTransferText) + cy.getByTestId(transferText) .should('exist') .get(keyID) .invoke('text') @@ -204,7 +202,6 @@ describe( 'contain.text', 'You cannot transfer more than your available collateral' ); - cy.getByTestId(closeDialog).click(); }); } ); @@ -217,7 +214,7 @@ describe('withdraw actions', { tags: '@smoke', testIsolation: true }, () => { cy.visit('/#/portfolio'); cy.getByTestId(collateralTab).click(); - cy.getByTestId(openTransferDialog).click(); + cy.getByTestId(openTransferButton).click(); cy.wait('@Accounts'); cy.wait('@Assets'); diff --git a/apps/trading-e2e/src/integration/withdraw.cy.ts b/apps/trading-e2e/src/integration/withdraw.cy.ts index 35747ae94..8456ee1b5 100644 --- a/apps/trading-e2e/src/integration/withdraw.cy.ts +++ b/apps/trading-e2e/src/integration/withdraw.cy.ts @@ -21,7 +21,7 @@ describe('withdraw form validation', { tags: '@smoke' }, () => { cy.visit('/#/portfolio'); cy.getByTestId('Withdrawals').click(); - cy.getByTestId('withdraw-dialog-button').click(); + cy.getByTestId('Withdraw').click(); // sidebar item // It also requires connection Ethereum wallet connectEthereumWallet('MetaMask'); @@ -87,15 +87,17 @@ describe( cy.setVegaWallet(); cy.visit('/#/portfolio'); + + cy.wait('@Accounts'); + cy.wait('@Assets'); + cy.getByTestId('Withdrawals').click(); - cy.getByTestId('withdraw-dialog-button').click(); + cy.getByTestId('Withdraw').click(); // It also requires connection Ethereum wallet connectEthereumWallet('MetaMask'); - cy.wait('@Accounts'); - cy.wait('@Assets'); cy.mockVegaWalletTransaction(); }); diff --git a/apps/trading/client-pages/liquidity/liquidity.tsx b/apps/trading/client-pages/liquidity/liquidity.tsx index c8ec826c4..cc334fe34 100644 --- a/apps/trading/client-pages/liquidity/liquidity.tsx +++ b/apps/trading/client-pages/liquidity/liquidity.tsx @@ -64,12 +64,14 @@ const LiquidityViewHeader = memo(({ marketId }: { marketId?: string }) => { return (
{market.tradableInstrument.instrument.code && - t('Liquidity provision')} + t( + '%s liquidity provision', + market.tradableInstrument.instrument.code + )} ) } 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 a4cbaf5cb..d7b310c88 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 @@ -35,6 +35,7 @@ const MobileWalletButton = ({ const openVegaWalletDialog = useVegaWalletDialogStore( (store) => store.openVegaWalletDialog ); + const setView = useSidebar((store) => store.setView); const { VEGA_ENV } = useEnvironment(); const isYellow = VEGA_ENV === Networks.TESTNET; const [drawerOpen, setDrawerOpen] = useState(false); @@ -127,8 +128,7 @@ const MobileWalletButton = ({