From e4a51061a30144ba40888923b8f7a3575a57b4e5 Mon Sep 17 00:00:00 2001 From: Art Date: Thu, 20 Apr 2023 13:56:33 +0200 Subject: [PATCH] chore(ci): bump typescript (#3444) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mikołaj Młodzikowski --- .github/workflows/ci-cd-trigger.yml | 4 +- .github/workflows/cypress-run.yml | 2 +- .github/workflows/publish-dist.yml | 2 +- apps/explorer-e2e/cypress.config.js | 1 + apps/governance-e2e/cypress.config.js | 1 + .../src/integration/flow/staking-flow.cy.ts | 72 ++- .../src/integration/view/pubkey-view.cy.ts | 10 +- .../src/integration/view/validators.cy.ts | 5 +- .../src/integration/view/vesting.cy.ts | 36 +- .../src/integration/view/wallet-eth.cy.ts | 2 +- .../src/integration/view/wallet-vega.cy.ts | 3 +- .../src/support/common.functions.ts | 8 +- .../src/support/staking.functions.ts | 32 +- .../src/support/wallet-teardown.functions.ts | 2 +- apps/trading-e2e/cypress.config.js | 1 + .../market-proposal-notification.cy.ts | 47 ++ .../market-split-bottom-panels.cy.ts | 41 ++ .../src/integration/market-summary.cy.ts | 136 +--- apps/trading-e2e/src/integration/navbar.cy.ts | 147 +++-- .../src/integration/trading-accounts.cy.ts | 32 +- .../trading-deal-ticket-basic-submit.cy.ts | 110 ++++ .../trading-deal-ticket-basics.cy.ts | 96 +++ .../trading-deal-ticket-order.cy.ts | 92 +++ .../trading-deal-ticket-submit-account.cy.ts | 173 ++++++ ...ing-deal-ticket-submit-batch-auction.cy.ts | 87 +++ ...eal-ticket-submit-monitoring-auction.cy.ts | 85 +++ ...g-deal-ticket-submit-opening-auction.cy.ts | 85 +++ ...trading-deal-ticket-submit-suspended.cy.ts | 68 ++ .../trading-deal-ticket-submit.cy.ts | 580 ------------------ .../trading-deal-ticket-time-in-force.cy.ts | 157 +++++ .../trading-deal-ticket-validations.cy.ts | 329 ---------- .../src/integration/trading-orders.cy.ts | 28 +- .../src/integration/trading-positions.cy.ts | 18 +- .../src/integration/wallet-eth.cy.ts | 2 +- .../src/integration/wallet-vega.cy.ts | 188 +++--- .../src/integration/withdraw-key-to-key.cy.ts | 88 +-- .../src/integration/withdraw.cy.ts | 96 +-- apps/trading-e2e/src/support/deal-ticket.ts | 18 + .../lib/commands/add-connect-public-key.ts | 19 +- .../src/lib/commands/vega-wallet-connect.ts | 34 +- libs/cypress/tsconfig.json | 3 +- libs/datagrid/src/lib/cell-class-rules.ts | 6 +- libs/react-helpers/src/hooks/use-fetch.ts | 1 + package.json | 6 +- yarn.lock | 28 +- 45 files changed, 1534 insertions(+), 1447 deletions(-) create mode 100644 apps/trading-e2e/src/integration/market-proposal-notification.cy.ts create mode 100644 apps/trading-e2e/src/integration/market-split-bottom-panels.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-basic-submit.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-basics.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-submit-batch-auction.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-submit-monitoring-auction.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-submit-opening-auction.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-submit-suspended.cy.ts delete mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-submit.cy.ts create mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-time-in-force.cy.ts delete mode 100644 apps/trading-e2e/src/integration/trading-deal-ticket-validations.cy.ts create mode 100644 apps/trading-e2e/src/support/deal-ticket.ts diff --git a/.github/workflows/ci-cd-trigger.yml b/.github/workflows/ci-cd-trigger.yml index 4e8a88113..23450bda5 100644 --- a/.github/workflows/ci-cd-trigger.yml +++ b/.github/workflows/ci-cd-trigger.yml @@ -26,7 +26,7 @@ jobs: with: path: node_modules key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }} - # comment out "resotre-keys" if you need to rebuild yarn from 0 + # comment out "restore-keys" if you need to rebuild yarn from 0 restore-keys: | ${{ runner.os }}-cache-node-modules- @@ -50,7 +50,7 @@ jobs: secrets: inherit lint-test-build: - timeout-minutes: 60 + timeout-minutes: 35 needs: node-modules runs-on: ubuntu-22.04 name: '(CI) lint + unit test + build' diff --git a/.github/workflows/cypress-run.yml b/.github/workflows/cypress-run.yml index 15edc3967..14186fadf 100644 --- a/.github/workflows/cypress-run.yml +++ b/.github/workflows/cypress-run.yml @@ -20,7 +20,7 @@ jobs: project: ${{ fromJSON(inputs.projects) }} name: ${{ matrix.project }} runs-on: self-hosted-runner - timeout-minutes: 30 + timeout-minutes: 40 steps: # Checks if skip cache was requested - name: Set skip-nx-cache flag diff --git a/.github/workflows/publish-dist.yml b/.github/workflows/publish-dist.yml index 5b878bf87..a81b29fe7 100644 --- a/.github/workflows/publish-dist.yml +++ b/.github/workflows/publish-dist.yml @@ -15,7 +15,7 @@ jobs: app: ${{ fromJSON(inputs.projects) }} name: ${{ matrix.app }} runs-on: ubuntu-22.04 - timeout-minutes: 20 + timeout-minutes: 25 steps: - name: Check out code uses: actions/checkout@v3 diff --git a/apps/explorer-e2e/cypress.config.js b/apps/explorer-e2e/cypress.config.js index 94f67efec..9b91a7946 100644 --- a/apps/explorer-e2e/cypress.config.js +++ b/apps/explorer-e2e/cypress.config.js @@ -21,6 +21,7 @@ module.exports = defineConfig({ chromeWebSecurity: false, viewportWidth: 1440, viewportHeight: 900, + testIsolation: false, }, env: { environment: 'CUSTOM', diff --git a/apps/governance-e2e/cypress.config.js b/apps/governance-e2e/cypress.config.js index a2f72829c..38de2c722 100644 --- a/apps/governance-e2e/cypress.config.js +++ b/apps/governance-e2e/cypress.config.js @@ -25,6 +25,7 @@ module.exports = defineConfig({ viewportWidth: 1440, viewportHeight: 900, numTestsKeptInMemory: 5, + testIsolation: false, }, env: { ethProviderUrl: 'http://localhost:8545/', diff --git a/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts b/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts index 83300d0d5..f811276fc 100644 --- a/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts @@ -40,18 +40,22 @@ const stakeAddStakeRadioButton = 'add-stake-radio'; const stakeMaximumTokens = 'token-amount-use-maximum'; const vegaWalletAssociatedBalance = 'currency-value'; const vegaWalletStakedBalances = 'vega-wallet-balance-staked-validators'; -const ethWalletContainer = 'ethereum-wallet'; +const ethWallet = 'ethereum-wallet'; const vegaWallet = 'vega-wallet'; const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const txTimeout = Cypress.env('txTimeout'); const epochTimeout = Cypress.env('epochTimeout'); +const getEthereumWallet = () => cy.get(`[data-testid="${ethWallet}"]:visible`); +const getVegaWallet = () => cy.get(`[data-testid="${vegaWallet}"]:visible`); + context( 'Staking Tab - with eth and vega wallets connected', { tags: '@slow' }, function () { // 2001-STKE-002, 2001-STKE-032 before('visit staking tab and connect vega wallet', function () { + cy.clearAllLocalStorage(); cy.visit('/'); ethereumWalletConnect(); // this is a workaround for #2422 which can be removed once issue is resolved @@ -187,31 +191,35 @@ context( .should('contain', 1.0, txTimeout); closeStakingDialog(); navigateTo(navigation.validators); - cy.get(`[row-id="${0}"]`).within(() => { - cy.getByTestId(stakeValidatorListTotalStake) - .should('have.text', '2.00') - .and('be.visible'); - cy.getByTestId(stakeValidatorListTotalShare) - .should('have.text', '66.67%') - .and('be.visible'); - cy.getByTestId(stakeValidatorListTotalStake) - .scrollIntoView() - .should('have.text', '2.00') - .and('be.visible'); - }); - cy.get(`[row-id="${1}"]`).within(() => { - cy.getByTestId(stakeValidatorListTotalStake) - .scrollIntoView() - .should('have.text', '1.00') - .and('be.visible'); - cy.getByTestId(stakeValidatorListTotalShare) - .should('have.text', '33.33%') - .and('be.visible'); - cy.getByTestId(stakeValidatorListTotalStake) - .scrollIntoView() - .should('have.text', '1.00') - .and('be.visible'); - }); + cy.get(`[row-id="${0}"]`) + .eq(1) + .within(() => { + cy.getByTestId(stakeValidatorListTotalStake) + .should('have.text', '2.00') + .and('be.visible'); + cy.getByTestId(stakeValidatorListTotalShare) + .should('have.text', '66.67%') + .and('be.visible'); + cy.getByTestId(stakeValidatorListTotalStake) + .scrollIntoView() + .should('have.text', '2.00') + .and('be.visible'); + }); + cy.get(`[row-id="${1}"]`) + .eq(1) + .within(() => { + cy.getByTestId(stakeValidatorListTotalStake) + .scrollIntoView() + .should('have.text', '1.00') + .and('be.visible'); + cy.getByTestId(stakeValidatorListTotalShare) + .should('have.text', '33.33%') + .and('be.visible'); + cy.getByTestId(stakeValidatorListTotalStake) + .scrollIntoView() + .should('have.text', '1.00') + .and('be.visible'); + }); }); // 2001-STKE-041 @@ -329,11 +337,11 @@ context( verifyStakedBalance(2.0); closeStakingDialog(); stakingPageDisassociateAllTokens(); - cy.getByTestId(ethWalletContainer).within(() => { + getEthereumWallet().within(() => { cy.contains(vegaWalletPublicKeyShort, txTimeout).should('not.exist'); }); verifyEthWalletTotalAssociatedBalance('0.0'); - cy.getByTestId(vegaWallet).within(() => { + getVegaWallet().within(() => { cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should( 'contain', '0.00' @@ -357,11 +365,11 @@ context( verifyStakedBalance(2.0); closeStakingDialog(); stakingPageDisassociateAllTokens('contract'); - cy.getByTestId(ethWalletContainer).within(() => { + getEthereumWallet().within(() => { cy.contains(vegaWalletPublicKeyShort, txTimeout).should('not.exist'); }); verifyEthWalletTotalAssociatedBalance('0.0'); - cy.getByTestId(vegaWallet).within(() => { + getVegaWallet().within(() => { cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should( 'contain', '0.00' @@ -386,7 +394,7 @@ context( closeStakingDialog(); stakingPageDisassociateTokens('1'); verifyEthWalletTotalAssociatedBalance('2.0'); - cy.getByTestId(vegaWallet).within(() => { + getVegaWallet().within(() => { cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should( 'contain', '2.00' @@ -453,7 +461,7 @@ context( verifyUnstakedBalance(0.0); closeStakingDialog(); stakingPageAssociateTokens('6'); - cy.getByTestId(vegaWallet).within(() => { + getVegaWallet().within(() => { cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should( 'contain', '12.00' diff --git a/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts b/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts index 45ed99a6b..8727ab164 100644 --- a/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts +++ b/apps/governance-e2e/src/integration/view/pubkey-view.cy.ts @@ -45,10 +45,12 @@ context('View functionality with public key', { tags: '@smoke' }, function () { navigateTo(navigation.proposals); goToMakeNewProposal('Freeform'); enterUniqueFreeFormProposalBody('50', 'pub key proposal test'); - cy.getByTestId('dialog-content').within(() => { - cy.get('h1').should('have.text', 'Transaction failed'); - cy.getByTestId('Error').should('have.text', expectedErrorTxt); - }); + cy.getByTestId('dialog-content') + .first() + .within(() => { + cy.get('h1').should('have.text', 'Transaction failed'); + cy.getByTestId('Error').should('have.text', expectedErrorTxt); + }); }); it('Able to disconnect via banner', function () { diff --git a/apps/governance-e2e/src/integration/view/validators.cy.ts b/apps/governance-e2e/src/integration/view/validators.cy.ts index 8f1e22fff..d167c98c0 100644 --- a/apps/governance-e2e/src/integration/view/validators.cy.ts +++ b/apps/governance-e2e/src/integration/view/validators.cy.ts @@ -1,7 +1,6 @@ /// import { - navigateTo, navigation, verifyPageHeader, verifyTabHighlighted, @@ -34,8 +33,8 @@ const stakeNumberRegex = /^\d*\.?\d*$/; context('Validators Page - verify elements on page', function () { before('navigate to validators page', function () { - cy.visit('/'); - navigateTo(navigation.validators); + cy.clearAllLocalStorage(); + cy.visit('/validators'); }); describe('with wallets disconnected', { tags: '@smoke' }, function () { diff --git a/apps/governance-e2e/src/integration/view/vesting.cy.ts b/apps/governance-e2e/src/integration/view/vesting.cy.ts index 82f6ff113..14f118693 100644 --- a/apps/governance-e2e/src/integration/view/vesting.cy.ts +++ b/apps/governance-e2e/src/integration/view/vesting.cy.ts @@ -43,23 +43,25 @@ context( // 1005-VEST-020 1005-VEST-021 it('Tokens in vesting contract for eth wallet is displayed on wallet window', function () { - cy.getByTestId('vega-in-vesting-contract').within(() => { - cy.getByTestId('currency-title') - .should('contain.text', 'VEGA') - .and('contain.text', 'In vesting contract'); - cy.get('[data-testid="currency-value"]:visible').should( - 'have.text', - lockedTokensInVestingContract - ); - cy.get('[data-testid="currency-locked"]:visible').should( - 'have.text', - lockedTokensInVestingContract - ); - cy.get('[data-testid="currency-unlocked"]:visible').should( - 'have.text', - '0.00' - ); - }); + cy.get('[data-testid="vega-in-vesting-contract"]:visible').within( + () => { + cy.getByTestId('currency-title') + .should('contain.text', 'VEGA') + .and('contain.text', 'In vesting contract'); + cy.get('[data-testid="currency-value"]:visible').should( + 'have.text', + lockedTokensInVestingContract + ); + cy.get('[data-testid="currency-locked"]:visible').should( + 'have.text', + lockedTokensInVestingContract + ); + cy.get('[data-testid="currency-unlocked"]:visible').should( + 'have.text', + '0.00' + ); + } + ); }); // 1005-VEST-022 1005-VEST-023 it('Tokens amount displayed in vesting page', function () { diff --git a/apps/governance-e2e/src/integration/view/wallet-eth.cy.ts b/apps/governance-e2e/src/integration/view/wallet-eth.cy.ts index cac1af3c9..36759c0be 100644 --- a/apps/governance-e2e/src/integration/view/wallet-eth.cy.ts +++ b/apps/governance-e2e/src/integration/view/wallet-eth.cy.ts @@ -17,7 +17,7 @@ const vegaInWallet = '[data-testid="vega-in-wallet"]:visible'; const progressBar = '[data-testid="progress-bar"]:visible'; const currencyLocked = '[data-testid="currency-locked"]:visible'; const currencyUnlocked = '[data-testid="currency-unlocked"]:visible'; -const dialog = '[role="dialog"]'; +const dialog = '[role="dialog"]:visible'; const dialogHeader = '[data-testid="dialog-title"]'; const dialogCloseBtn = '[data-testid="dialog-close"]'; diff --git a/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts b/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts index 39d94b647..e69ebbbd6 100644 --- a/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts +++ b/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts @@ -7,7 +7,7 @@ const walletContainer = 'aside [data-testid="vega-wallet"]'; const walletHeader = '[data-testid="wallet-header"] h1'; const connectButton = '[data-testid="connect-vega-wallet"]'; const getVegaLink = '[data-testid="link"]'; -const dialog = '[role="dialog"]'; +const dialog = '[role="dialog"]:visible'; const dialogHeader = '[data-testid="dialog-title"]'; const walletDialogHeader = '[data-testid="wallet-dialog-title"]'; const connectorsList = '[data-testid="connectors-list"]'; @@ -35,6 +35,7 @@ context( { tags: '@regression' }, () => { before('visit token home page', () => { + cy.clearAllLocalStorage(); cy.visit('/'); cy.get(walletContainer, { timeout: 60000 }).should('be.visible'); }); diff --git a/apps/governance-e2e/src/support/common.functions.ts b/apps/governance-e2e/src/support/common.functions.ts index bcbe7b5a1..d095e43d6 100644 --- a/apps/governance-e2e/src/support/common.functions.ts +++ b/apps/governance-e2e/src/support/common.functions.ts @@ -26,9 +26,11 @@ const topLevelRoutes = [ export function navigateTo(page: navigation) { if (!topLevelRoutes.includes(page)) { cy.getByTestId(tokenDropDown, { timeout: 10000 }).eq(0).click(); - cy.getByTestId('token-dropdown').within(() => { - cy.get(page).eq(0).click(); - }); + cy.getByTestId('token-dropdown') + .first() + .within(() => { + cy.get(page).eq(0).click(); + }); } else { return cy.get(navigation.section, { timeout: 10000 }).within(() => { cy.get(page).eq(0).click(); diff --git a/apps/governance-e2e/src/support/staking.functions.ts b/apps/governance-e2e/src/support/staking.functions.ts index 1e08b5afa..b34ed6ef5 100644 --- a/apps/governance-e2e/src/support/staking.functions.ts +++ b/apps/governance-e2e/src/support/staking.functions.ts @@ -184,16 +184,18 @@ export function validateValidatorListTotalStakeAndShare( ) { cy.contains('Loading...', epochTimeout).should('not.exist'); waitForBeginningOfEpoch(); - cy.get(`[row-id="${positionOnList}"]`).within(() => { - cy.getByTestId(stakeValidatorListTotalStake, epochTimeout).should( - 'have.text', - expectedTotalStake - ); - cy.getByTestId(stakeValidatorListTotalShare, epochTimeout).should( - 'have.text', - expectedTotalShare - ); - }); + cy.get(`[row-id="${positionOnList}"]:visible`) + .eq(1) + .within(() => { + cy.getByTestId(stakeValidatorListTotalStake, epochTimeout).should( + 'have.text', + expectedTotalStake + ); + cy.getByTestId(stakeValidatorListTotalShare, epochTimeout).should( + 'have.text', + expectedTotalShare + ); + }); } export function ensureSpecifiedUnstakedTokensAreAssociated( @@ -218,13 +220,15 @@ export function ensureSpecifiedUnstakedTokensAreAssociated( } export function closeStakingDialog() { - cy.getByTestId('dialog-title').should( + cy.get('[data-testid="dialog-title"]:visible').should( 'contain.text', 'At the beginning of the next epoch' ); - cy.getByTestId('dialog-content').within(() => { - cy.get('a').should('have.text', 'Back to Staking').click(); - }); + cy.get('[data-testid="dialog-content"]:visible') + .first() + .within(() => { + cy.get('a').should('have.text', 'Back to Staking').click(); + }); } export function validateWalletCurrency( diff --git a/apps/governance-e2e/src/support/wallet-teardown.functions.ts b/apps/governance-e2e/src/support/wallet-teardown.functions.ts index be36d19de..7d1366e83 100644 --- a/apps/governance-e2e/src/support/wallet-teardown.functions.ts +++ b/apps/governance-e2e/src/support/wallet-teardown.functions.ts @@ -9,7 +9,7 @@ import { import { ethers, Wallet } from 'ethers'; const associatedAmountInWallet = '[data-testid="associated-amount"]:visible'; -const vegaWalletContainer = 'aside [data-testid="vega-wallet"]'; +const vegaWalletContainer = 'aside [data-testid="vega-wallet"]:visible'; const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic'); const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey'); const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress'); diff --git a/apps/trading-e2e/cypress.config.js b/apps/trading-e2e/cypress.config.js index 022bd41e2..1177739ca 100644 --- a/apps/trading-e2e/cypress.config.js +++ b/apps/trading-e2e/cypress.config.js @@ -23,6 +23,7 @@ module.exports = defineConfig({ responseTimeout: 50000, requestTimeout: 20000, retries: 2, + testIsolation: false, }, env: { ETHERSCAN_URL: 'https://sepolia.etherscan.io', diff --git a/apps/trading-e2e/src/integration/market-proposal-notification.cy.ts b/apps/trading-e2e/src/integration/market-proposal-notification.cy.ts new file mode 100644 index 000000000..c78fc8786 --- /dev/null +++ b/apps/trading-e2e/src/integration/market-proposal-notification.cy.ts @@ -0,0 +1,47 @@ +import { aliasGQLQuery } from '@vegaprotocol/cypress'; +import { proposalListQuery, marketUpdateProposal } from '@vegaprotocol/mock'; +import * as Schema from '@vegaprotocol/types'; + +const marketSummaryBlock = 'header-summary'; + +describe('Market proposal notification', { tags: '@smoke' }, () => { + before(() => { + cy.setVegaWallet(); + cy.mockTradingPage( + Schema.MarketState.STATE_ACTIVE, + Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, + Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET + ); + cy.mockGQL((req) => { + aliasGQLQuery( + req, + 'ProposalsList', + proposalListQuery({ + proposalsConnection: { + edges: [{ node: marketUpdateProposal }], + }, + }) + ); + }); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@MarketData'); + cy.getByTestId(marketSummaryBlock).should('be.visible'); + }); + + it('should display market proposal notification if proposal found', () => { + cy.getByTestId(marketSummaryBlock).within(() => { + cy.getByTestId('market-proposal-notification').should( + 'contain.text', + 'Changes have been proposed for this market' + ); + cy.getByTestId('market-proposal-notification').within(() => { + cy.getByTestId('external-link').should( + 'have.attr', + 'href', + `${Cypress.env('VEGA_TOKEN_URL')}/proposals/123` + ); + }); + }); + }); +}); diff --git a/apps/trading-e2e/src/integration/market-split-bottom-panels.cy.ts b/apps/trading-e2e/src/integration/market-split-bottom-panels.cy.ts new file mode 100644 index 000000000..2c860042b --- /dev/null +++ b/apps/trading-e2e/src/integration/market-split-bottom-panels.cy.ts @@ -0,0 +1,41 @@ +describe('market bottom panel', { tags: '@smoke' }, () => { + before(() => { + cy.clearAllLocalStorage(); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@MarketData'); + }); + + it('on xxl screen should be splitted out into two tables', () => { + cy.getByTestId('tab-positions').should('have.attr', 'data-state', 'active'); + cy.getByTestId('tab-orders').should('have.attr', 'data-state', 'inactive'); + cy.getByTestId('tab-fills').should('have.attr', 'data-state', 'inactive'); + cy.getByTestId('tab-accounts').should( + 'have.attr', + 'data-state', + 'inactive' + ); + + cy.viewport(1801, 1000); + cy.getByTestId('tab-positions').should('have.attr', 'data-state', 'active'); + cy.getByTestId('tab-orders').should('have.attr', 'data-state', 'active'); + cy.getByTestId('tab-fills').should('have.attr', 'data-state', 'inactive'); + cy.getByTestId('tab-accounts').should( + 'have.attr', + 'data-state', + 'inactive' + ); + + cy.getByTestId('Fills').click(); + cy.getByTestId('Collateral').click(); + cy.getByTestId('tab-positions').should( + 'have.attr', + 'data-state', + 'inactive' + ); + cy.getByTestId('tab-orders').should('have.attr', 'data-state', 'inactive'); + cy.getByTestId('tab-fills').should('have.attr', 'data-state', 'active'); + cy.getByTestId('tab-accounts').should('have.attr', 'data-state', 'active'); + }); +}); diff --git a/apps/trading-e2e/src/integration/market-summary.cy.ts b/apps/trading-e2e/src/integration/market-summary.cy.ts index bd6ac01aa..2658a7682 100644 --- a/apps/trading-e2e/src/integration/market-summary.cy.ts +++ b/apps/trading-e2e/src/integration/market-summary.cy.ts @@ -1,5 +1,3 @@ -import { aliasGQLQuery } from '@vegaprotocol/cypress'; -import { proposalListQuery, marketUpdateProposal } from '@vegaprotocol/mock'; import * as Schema from '@vegaprotocol/types'; const marketSummaryBlock = 'header-summary'; @@ -15,50 +13,9 @@ const priceChangeValue = 'price-change'; const itemHeader = 'item-header'; const itemValue = 'item-value'; -describe('Market proposal notification', { tags: '@smoke' }, () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage( - Schema.MarketState.STATE_ACTIVE, - Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, - Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET - ); - cy.mockGQL((req) => { - aliasGQLQuery( - req, - 'ProposalsList', - proposalListQuery({ - proposalsConnection: { - edges: [{ node: marketUpdateProposal }], - }, - }) - ); - }); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@MarketData'); - cy.getByTestId(marketSummaryBlock).should('be.visible'); - }); - - it('should display market proposal notification if proposal found', () => { - cy.getByTestId(marketSummaryBlock).within(() => { - cy.getByTestId('market-proposal-notification').should( - 'contain.text', - 'Changes have been proposed for this market' - ); - cy.getByTestId('market-proposal-notification').within(() => { - cy.getByTestId('external-link').should( - 'have.attr', - 'href', - `${Cypress.env('VEGA_TOKEN_URL')}/proposals/123` - ); - }); - }); - }); -}); - describe('Market trading page', () => { before(() => { + cy.clearAllLocalStorage(); cy.mockTradingPage( Schema.MarketState.STATE_ACTIVE, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, @@ -165,6 +122,7 @@ describe('Market trading page', () => { }); }); cy.getByTestId('expiry-tooltip') + .eq(0) .should( 'contain.text', 'This market expires when triggered by its oracle, not on a set date.' @@ -202,6 +160,7 @@ describe('Market trading page', () => { 'contain.text', 'This market is in auction until it reaches sufficient liquidity.' ) + .eq(0) .within(() => { cy.getByTestId('external-link') .should('have.attr', 'href') @@ -216,93 +175,4 @@ describe('Market trading page', () => { }); }); }); - - describe('market bottom panel', { tags: '@smoke' }, () => { - it('on xxl screen should be splitted out into two tables', () => { - cy.getByTestId('tab-positions').should( - 'have.attr', - 'data-state', - 'active' - ); - cy.getByTestId('tab-orders').should( - 'have.attr', - 'data-state', - 'inactive' - ); - cy.getByTestId('tab-fills').should('have.attr', 'data-state', 'inactive'); - cy.getByTestId('tab-accounts').should( - 'have.attr', - 'data-state', - 'inactive' - ); - - cy.viewport(1801, 1000); - cy.getByTestId('tab-positions').should( - 'have.attr', - 'data-state', - 'active' - ); - cy.getByTestId('tab-orders').should('have.attr', 'data-state', 'active'); - cy.getByTestId('tab-fills').should('have.attr', 'data-state', 'inactive'); - cy.getByTestId('tab-accounts').should( - 'have.attr', - 'data-state', - 'inactive' - ); - - cy.getByTestId('Fills').click(); - cy.getByTestId('Collateral').click(); - cy.getByTestId('tab-positions').should( - 'have.attr', - 'data-state', - 'inactive' - ); - cy.getByTestId('tab-orders').should( - 'have.attr', - 'data-state', - 'inactive' - ); - cy.getByTestId('tab-fills').should('have.attr', 'data-state', 'active'); - cy.getByTestId('tab-accounts').should( - 'have.attr', - 'data-state', - 'active' - ); - }); - }); -}); - -describe('market states not accepting orders', { tags: '@smoke' }, function () { - //7002-SORD-062 - //7002-SORD-063 - //7002-SORD-066 - - const states = [ - Schema.MarketState.STATE_REJECTED, - Schema.MarketState.STATE_CANCELLED, - Schema.MarketState.STATE_CLOSED, - Schema.MarketState.STATE_SETTLED, - Schema.MarketState.STATE_TRADING_TERMINATED, - ]; - - states.forEach((marketState) => { - describe(marketState, function () { - beforeEach(function () { - cy.mockTradingPage(marketState); - cy.mockSubscription(); - cy.setVegaWallet(); - cy.visit('/#/markets/market-0'); - }); - it('must display that market is not accepting orders', function () { - cy.getByTestId('dealticket-error-message-summary').should( - 'have.text', - `This market is ${marketState - .split('_') - .pop() - ?.toLowerCase()} and not accepting orders` - ); - cy.getByTestId('place-order').should('be.disabled'); - }); - }); - }); }); diff --git a/apps/trading-e2e/src/integration/navbar.cy.ts b/apps/trading-e2e/src/integration/navbar.cy.ts index 22fa67e95..6b04eecac 100644 --- a/apps/trading-e2e/src/integration/navbar.cy.ts +++ b/apps/trading-e2e/src/integration/navbar.cy.ts @@ -1,27 +1,32 @@ import { mockConnectWallet } from '@vegaprotocol/cypress'; -beforeEach(() => { - cy.mockTradingPage(); - cy.mockSubscription(); - cy.visit('/'); - cy.wait('@Markets'); - cy.wait('@MarketsData'); - cy.wait('@MarketsCandles'); - cy.getByTestId('dialog-close').click(); -}); +describe('Navbar', { tags: '@smoke' }, () => { + before(() => { + cy.clearAllLocalStorage(); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.visit('/'); + cy.wait('@Markets'); + cy.wait('@MarketsData'); + cy.wait('@MarketsCandles'); + // close welcome dialog + cy.getByTestId('dialog-close').click(); + }); -describe('Desktop view', { tags: '@smoke' }, () => { - describe('Navbar', () => { - const links = ['Markets', 'Trading', 'Portfolio']; - const hashes = ['#/markets/all', '#/markets/market-1', '#/portfolio']; + const pages = [ + { name: 'Markets', link: '#/markets/all' }, + { name: 'Trading', link: '#/markets' }, + { name: 'Portfolio', link: '#/portfolio' }, + ]; - links.forEach((link, index) => { - it(`${link} should be correctly rendered`, () => { + describe('desktop view', () => { + pages.forEach(({ name, link }) => { + it(`${name} should be correctly rendered`, () => { cy.get('nav') - .find(`a[data-testid=${link}]:visible`) + .find(`a[data-testid=${name}]:visible`) .then((element) => { cy.wrap(element).click(); - cy.location('hash').should('equal', hashes[index]); + cy.location('hash').should('contain', link); }); }); }); @@ -43,73 +48,61 @@ describe('Desktop view', { tags: '@smoke' }, () => { }); }); }); -}); -describe('Mobile view', { tags: '@smoke' }, () => { - const viewportHeight = Cypress.config('viewportHeight'); - const viewportWidth = Cypress.config('viewportWidth'); - before(() => { - // a little hack to keep the viewport size between tests (cypress bug) - Cypress.config({ - viewportWidth: 560, - viewportHeight: 890, + describe('mobile view', () => { + const viewportHeight = Cypress.config('viewportHeight'); + const viewportWidth = Cypress.config('viewportWidth'); + before(() => { + // a little hack to keep the viewport size between tests (cypress bug) + Cypress.config({ + viewportWidth: 560, + viewportHeight: 890, + }); + cy.viewport(560, 890); }); - cy.viewport(560, 890); - }); - describe('wallet drawer', () => { - it('wallet drawer should be correctly rendered', () => { - mockConnectWallet(); - cy.connectVegaWallet(true); - cy.getByTestId('connect-vega-wallet-mobile').click(); - cy.getByTestId('wallets-drawer').should('be.visible'); - cy.getByTestId('wallets-drawer').within((el) => { - cy.wrap(el).get('button').contains('Disconnect').click(); - }); - cy.getByTestId('wallets-drawer').should('not.be.visible'); - }); - }); - - describe('menu drawer', () => { - it('Markets should be correctly rendered', () => { - cy.getByTestId('button-menu-drawer').click(); - cy.getByTestId('menu-drawer').should('be.visible'); - cy.getByTestId('menu-drawer').within((el) => { - cy.wrap(el).getByTestId('Markets').click(); - cy.location('hash').should('equal', '#/markets/all'); - }); - }); - it('Trading should be correctly rendered', () => { - cy.getByTestId('button-menu-drawer').click(); - cy.getByTestId('menu-drawer').within((el) => { - cy.wrap(el).getByTestId('Trading').click(); - cy.location('hash').should('equal', '#/markets/market-1'); - }); - }); - it('Portfolio should be correctly rendered', () => { - cy.getByTestId('button-menu-drawer').click(); - cy.getByTestId('menu-drawer').within((el) => { - cy.wrap(el).getByTestId('Portfolio').click(); - cy.location('hash').should('equal', '#/portfolio'); + describe('wallet drawer', () => { + it('wallet drawer should be correctly rendered', () => { + mockConnectWallet(); + cy.connectVegaWallet(true); + cy.getByTestId('connect-vega-wallet-mobile').click(); + cy.getByTestId('wallets-drawer').should('be.visible'); + cy.getByTestId('wallets-drawer').within((el) => { + cy.wrap(el).get('button').contains('Disconnect').click(); + }); + cy.getByTestId('wallets-drawer').should('not.be.visible'); }); }); - it('Menu drawer should not be visible until opened', () => { - 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="theme-switcher"]') - .should('be.visible'); - cy.getByTestId('button-menu-drawer').click(); - cy.getByTestId('menu-drawer').should('not.be.visible'); + describe('menu drawer', () => { + pages.forEach(({ name, link }) => { + it(`${name} should be correctly rendered`, () => { + cy.getByTestId('button-menu-drawer').click(); + cy.getByTestId('menu-drawer').should('be.visible'); + cy.getByTestId('menu-drawer').within((el) => { + cy.wrap(el).getByTestId(name).click(); + cy.location('hash').should('contain', link); + }); + }); + }); + + it('Menu drawer should not be visible until opened', () => { + 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="theme-switcher"]') + .should('be.visible'); + cy.getByTestId('button-menu-drawer').click(); + cy.getByTestId('menu-drawer').should('not.be.visible'); + }); }); - }); - after(() => { - // a little hack to keep the viewport size between tests (cypress bug) - Cypress.config({ - viewportWidth, - viewportHeight, + after(() => { + // a little hack to keep the viewport size between tests (cypress bug) + Cypress.config({ + viewportWidth, + viewportHeight, + }); }); }); }); diff --git a/apps/trading-e2e/src/integration/trading-accounts.cy.ts b/apps/trading-e2e/src/integration/trading-accounts.cy.ts index e2f9a1dea..0a4ecdc54 100644 --- a/apps/trading-e2e/src/integration/trading-accounts.cy.ts +++ b/apps/trading-e2e/src/integration/trading-accounts.cy.ts @@ -1,14 +1,16 @@ import { checkSorting } from '@vegaprotocol/cypress'; -beforeEach(() => { - cy.mockTradingPage(); - cy.mockWeb3Provider(); - cy.mockSubscription(); - cy.setVegaWallet(); - cy.visit('/#/markets/market-0'); -}); - describe('accounts', { tags: '@smoke' }, () => { + before(() => { + cy.clearAllLocalStorage(); + cy.mockTradingPage(); + cy.mockWeb3Provider(); + cy.mockSubscription(); + cy.setVegaWallet(); + cy.visit('/#/markets/market-0'); + cy.wait('@Assets'); + }); + it('renders accounts', () => { const tradingAccountRowId = '[row-id="t-0"]'; cy.getByTestId('Collateral').click(); @@ -41,13 +43,21 @@ describe('accounts', { tags: '@smoke' }, () => { .should('have.text', '100,001.01'); }); - it('asset detail should be properly rendered', () => { - cy.getByTestId('Collateral').click(); + it('should open asset details dialog when clicked on symbol', () => { cy.getByTestId('asset').contains('tEURO').click(); - cy.get('[data-testid$="_label"]').should('have.length', 16); + cy.get('[data-testid="dialog-content"]:visible').should('exist'); + cy.get('[data-testid="dialog-close"]:visible').click(); }); describe('sorting by ag-grid columns should work well', () => { + before(() => { + const dialogs = Cypress.$('[data-testid="dialog-close"]:visible'); + if (dialogs.length > 0) { + dialogs.each((btn) => { + cy.wrap(btn).click(); + }); + } + }); it('sorting by asset', () => { cy.getByTestId('Collateral').click(); const marketsSortedDefault = ['tBTC', 'tEURO', 'tDAI', 'tBTC']; diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-basic-submit.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-basic-submit.cy.ts new file mode 100644 index 000000000..f22f981f4 --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-basic-submit.cy.ts @@ -0,0 +1,110 @@ +import * as Schema from '@vegaprotocol/types'; +import { testOrderSubmission } from '../support/order-validation'; +import type { OrderSubmission } from '@vegaprotocol/wallet'; +import { createOrder } from '../support/create-order'; + +describe('must submit order', { tags: '@smoke' }, () => { + // 7002-SORD-039 + before(() => { + cy.setVegaWallet(); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + beforeEach(() => { + cy.setVegaWallet(); + }); + + it('successfully places market buy order', () => { + // 7002-SORD-010 + // 0003-WTXN-012 + // 0003-WTXN-003 + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_MARKET, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, + postOnly: false, + reduceOnly: false, + size: '100', + }; + createOrder(order); + testOrderSubmission(order); + }); + + it('successfully places market sell order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_MARKET, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_IOC, + size: '100', + postOnly: false, + reduceOnly: false, + }; + createOrder(order); + testOrderSubmission(order); + }); + + it('successfully places limit buy order', () => { + // 7002-SORD-017 + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + size: '100', + postOnly: false, + reduceOnly: false, + price: '200', + }; + createOrder(order); + testOrderSubmission(order, { price: '20000000' }); + }); + + it('successfully places limit sell order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GFN, + size: '100', + postOnly: false, + reduceOnly: false, + price: '50000', + }; + createOrder(order); + testOrderSubmission(order, { price: '5000000000' }); + }); + + it('successfully places GTT limit buy order', () => { + cy.mockVegaWalletTransaction(); + const expiresAt = new Date(Date.now() + 24 * 60 * 60 * 1000); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, + size: '100', + price: '1.00', + expiresAt: expiresAt.toISOString().substring(0, 16), + postOnly: false, + reduceOnly: false, + }; + + createOrder(order); + testOrderSubmission(order, { + price: '100000', + expiresAt: + new Date(order.expiresAt as string).getTime().toString() + '000000', + postOnly: false, + reduceOnly: false, + }); + }); +}); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-basics.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-basics.cy.ts new file mode 100644 index 000000000..f3af62e90 --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-basics.cy.ts @@ -0,0 +1,96 @@ +import * as Schema from '@vegaprotocol/types'; +import { mockConnectWallet } from '@vegaprotocol/cypress'; +import { + orderPriceField, + placeOrderBtn, + toggleLimit, + toggleLong, + toggleMarket, + toggleShort, +} from '../support/deal-ticket'; + +describe('deal ticket basics', { tags: '@smoke' }, () => { + before(() => { + cy.mockTradingPage(); + cy.mockSubscription(); + cy.clearAllLocalStorage(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + it('must show place order button and connect wallet if wallet is not connected', () => { + // 0003-WTXN-001 + cy.getByTestId('connect-vega-wallet'); // Not connected + cy.getByTestId('order-connect-wallet').should('exist'); + cy.getByTestId(placeOrderBtn).should('exist'); + cy.getByTestId('deal-ticket-connect-wallet').should('exist'); + }); + + it('must be able to select order direction - long/short', function () { + // 7002-SORD-004 + cy.getByTestId(toggleShort).click().children('input').should('be.checked'); + cy.getByTestId(toggleLong).click().children('input').should('be.checked'); + }); + + it('must be able to select order type - limit/market', function () { + // 7002-SORD-005 + // 7002-SORD-006 + // 7002-SORD-007 + cy.getByTestId(toggleLimit).click().children('input').should('be.checked'); + cy.getByTestId(toggleMarket).click().children('input').should('be.checked'); + }); + + it('order connect vega wallet button should connect', () => { + mockConnectWallet(); + cy.getByTestId(toggleLimit).click(); + cy.getByTestId(orderPriceField).clear().type('101'); + cy.getByTestId('order-connect-wallet').click(); + cy.getByTestId('dialog-content').should('be.visible'); + cy.getByTestId('connectors-list') + .find('[data-testid="connector-jsonRpc"]') + .click(); + cy.wait('@walletReq'); + cy.getByTestId(placeOrderBtn).should('be.visible'); + cy.getByTestId(toggleLimit).children('input').should('be.checked'); + cy.getByTestId(orderPriceField).should('have.value', '101'); + }); +}); + +describe( + 'market states not accepting orders', + { tags: '@smoke', testIsolation: true }, + function () { + //7002-SORD-062 + //7002-SORD-063 + //7002-SORD-066 + + const states = [ + Schema.MarketState.STATE_REJECTED, + Schema.MarketState.STATE_CANCELLED, + Schema.MarketState.STATE_CLOSED, + Schema.MarketState.STATE_SETTLED, + Schema.MarketState.STATE_TRADING_TERMINATED, + ]; + + states.forEach((marketState) => { + describe(marketState, function () { + beforeEach(function () { + cy.mockTradingPage(marketState); + cy.mockSubscription(); + cy.setVegaWallet(); + cy.visit('/#/markets/market-0'); + }); + it('must display that market is not accepting orders', function () { + cy.getByTestId('dealticket-error-message-summary').should( + 'have.text', + `This market is ${marketState + .split('_') + .pop() + ?.toLowerCase()} and not accepting orders` + ); + cy.getByTestId('place-order').should('be.disabled'); + }); + }); + }); + } +); 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 new file mode 100644 index 000000000..1c74e5415 --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-order.cy.ts @@ -0,0 +1,92 @@ +import { + orderPriceField, + orderSizeField, + orderTIFDropDown, + placeOrderBtn, + toggleLimit, + toggleMarket, +} from '../support/deal-ticket'; + +describe('deal ticker order validation', { tags: '@smoke' }, () => { + before(() => { + cy.setVegaWallet(); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + describe('limit order', () => { + before(() => { + cy.getByTestId(toggleLimit).click(); + }); + + it('must see the price unit', function () { + // 7002-SORD-018 + cy.getByTestId(orderPriceField) + .siblings('label') + .should('have.text', 'Price (DAI)'); + }); + + it('must see warning when placing an order with expiry date in past', () => { + const expiresAt = new Date(Date.now() - 24 * 60 * 60 * 1000); + const expiresAtInputValue = expiresAt.toISOString().substring(0, 16); + cy.getByTestId(toggleLimit).click(); + cy.getByTestId(orderPriceField).clear().type('0.1'); + cy.getByTestId(orderSizeField).clear().type('1'); + cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_GTT'); + + cy.log('choosing yesterday'); + cy.getByTestId('date-picker-field').type(expiresAtInputValue); + + cy.getByTestId(placeOrderBtn).click(); + + cy.getByTestId('dealticket-error-message-expiry').should( + 'have.text', + 'The expiry date that you have entered appears to be in the past' + ); + }); + + it('must see warning if price has too many digits after decimal place', function () { + // 7002-SORD-059 + cy.getByTestId(toggleLimit).click(); + cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_GTC'); + cy.getByTestId(orderSizeField).clear().type('1'); + cy.getByTestId(orderPriceField).clear().type('1.123456'); + cy.getByTestId('dealticket-error-message-price-limit').should( + 'have.text', + 'Price accepts up to 5 decimal places' + ); + }); + }); + + describe('market order', () => { + before(() => { + cy.getByTestId(toggleMarket).click(); + }); + + it('must not see the price unit', function () { + // 7002-SORD-019 + cy.getByTestId(orderPriceField).should('not.exist'); + }); + + it('must warn if order size input has too many digits after the decimal place', function () { + // 7002-SORD-016 + cy.getByTestId(orderSizeField).clear().type('1.234'); + cy.getByTestId(placeOrderBtn).should('be.disabled'); + cy.getByTestId('dealticket-error-message-size-market').should( + 'have.text', + 'Size must be whole numbers for this market' + ); + }); + + it('must warn if order size is set to 0', function () { + cy.getByTestId(orderSizeField).clear().type('0'); + cy.getByTestId(placeOrderBtn).should('be.disabled'); + cy.getByTestId('dealticket-error-message-size-market').should( + 'have.text', + 'Size cannot be lower than 1' + ); + }); + }); +}); 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 new file mode 100644 index 000000000..c964a485a --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts @@ -0,0 +1,173 @@ +import * as Schema from '@vegaprotocol/types'; +import { aliasGQLQuery } from '@vegaprotocol/cypress'; +import { + accountsQuery, + amendGeneralAccountBalance, + estimateOrderQuery, +} from '@vegaprotocol/mock'; +import type { OrderSubmission } from '@vegaprotocol/wallet'; +import { createOrder } from '../support/create-order'; + +describe( + 'account validation', + { tags: '@regression', testIsolation: true }, + () => { + describe('zero balance error', () => { + beforeEach(() => { + cy.setVegaWallet(); + cy.mockTradingPage(); + const accounts = accountsQuery(); + amendGeneralAccountBalance(accounts, 'market-0', '0'); + cy.mockGQL((req) => { + aliasGQLQuery(req, 'Accounts', accounts); + }); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + it('should show an error if your balance is zero', () => { + cy.getByTestId('place-order').should('be.disabled'); + // 7002-SORD-003 + cy.getByTestId('dealticket-error-message-zero-balance').should( + 'have.text', + 'You need ' + + 'tDAI' + + ' in your wallet to trade in this market.See all your collateral.Make a deposit' + ); + cy.getByTestId('deal-ticket-deposit-dialog-button').should('exist'); + }); + }); + + describe('not enough balance warning', () => { + beforeEach(() => { + cy.setVegaWallet(); + cy.mockTradingPage(); + const accounts = accountsQuery(); + amendGeneralAccountBalance(accounts, 'market-0', '100000000'); + cy.mockGQL((req) => { + aliasGQLQuery(req, 'Accounts', accounts); + }); + cy.mockGQL((req) => { + aliasGQLQuery(req, 'EstimateOrder', estimateOrderQuery()); + }); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + it('should display info and button for deposit', () => { + // 7002-SORD-003 + + // warning should show immediately + cy.getByTestId('dealticket-warning-margin').should( + 'contain.text', + 'You may not have enough margin available to open this position' + ); + cy.getByTestId('dealticket-warning-margin').should( + 'contain.text', + 'You may not have enough margin available to open this position. 2,354.72283 tDAI is currently required. You have only 1,000.01 tDAI available.' + ); + cy.getByTestId('deal-ticket-deposit-dialog-button').click(); + cy.getByTestId('dialog-content') + .find('h1') + .eq(0) + .should('have.text', 'Deposit'); + }); + }); + + describe('must submit order', { tags: '@smoke' }, () => { + // 7002-SORD-039 + beforeEach(() => { + cy.setVegaWallet(); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + it('must see a prompt to check connected vega wallet to approve transaction', () => { + // 0003-WTXN-002 + cy.mockVegaWalletTransaction(1000); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_MARKET, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, + size: '100', + }; + createOrder(order); + cy.getByTestId('toast-content').should( + 'contain.text', + 'Please go to your Vega wallet application and approve or reject the transaction.' + ); + }); + + it('must show error returned by wallet ', () => { + // 0003-WTXN-009 + // 0003-WTXN-011 + // 0002-WCON-016 + // 0003-WTXN-008 + + //trigger error from the wallet + cy.intercept('POST', 'http://localhost:1789/api/v2/requests', (req) => { + req.on('response', (res) => { + res.send({ + jsonrpc: '2.0', + id: '1', + }); + }); + }); + + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_MARKET, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, + size: '100', + }; + createOrder(order); + cy.getByTestId('toast-content').should( + 'contain.text', + 'The connection to your Vega Wallet has been lost.' + ); + cy.getByTestId('connect-vega-wallet').click(); + cy.getByTestId('dialog-content').should('be.visible'); + }); + + it('must see that the order was rejected by the connected wallet', () => { + // 0003-WTXN-007 + + //trigger rejection error from the wallet + cy.intercept('POST', 'http://localhost:1789/api/v2/requests', (req) => { + req.alias = 'client.send_transaction'; + req.reply({ + statusCode: 400, + body: { + jsonrpc: '2.0', + error: { + code: 3001, + data: 'the user rejected the wallet connection', + message: 'User error', + }, + id: '0', + }, + }); + }); + + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_MARKET, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, + size: '100', + }; + createOrder(order); + cy.getByTestId('toast-content').should( + 'contain.text', + 'Error occurredthe user rejected the wallet connection' + ); + }); + }); + } +); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-submit-batch-auction.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-batch-auction.cy.ts new file mode 100644 index 000000000..e6366af8c --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-batch-auction.cy.ts @@ -0,0 +1,87 @@ +import * as Schema from '@vegaprotocol/types'; +import { testOrderSubmission } from '../support/order-validation'; +import type { OrderSubmission } from '@vegaprotocol/wallet'; +import { createOrder } from '../support/create-order'; + +const displayTomorrow = () => { + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + return tomorrow.toISOString().substring(0, 16); +}; + +describe( + 'must submit order for market in batch auction', + { tags: '@regression' }, + () => { + before(() => { + cy.setVegaWallet(); + cy.mockTradingPage( + Schema.MarketState.STATE_SUSPENDED, + Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION, + Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET + ); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + beforeEach(() => { + cy.setVegaWallet(); + }); + + it('successfully places limit buy order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + size: '100', + postOnly: false, + reduceOnly: false, + price: '200', + }; + createOrder(order); + testOrderSubmission(order, { price: '20000000' }); + }); + + it('successfully places limit sell order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + size: '100', + postOnly: false, + reduceOnly: false, + price: '50000', + }; + createOrder(order); + testOrderSubmission(order, { price: '5000000000' }); + }); + + it('successfully places GTT limit buy order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, + size: '100', + postOnly: false, + reduceOnly: false, + price: '1.00', + expiresAt: displayTomorrow(), + }; + createOrder(order); + testOrderSubmission(order, { + price: '100000', + postOnly: false, + reduceOnly: false, + expiresAt: + new Date(order.expiresAt as string).getTime().toString() + '000000', + }); + }); + } +); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-submit-monitoring-auction.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-monitoring-auction.cy.ts new file mode 100644 index 000000000..67969a0b2 --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-monitoring-auction.cy.ts @@ -0,0 +1,85 @@ +import * as Schema from '@vegaprotocol/types'; +import { testOrderSubmission } from '../support/order-validation'; +import type { OrderSubmission } from '@vegaprotocol/wallet'; +import { createOrder } from '../support/create-order'; + +const displayTomorrow = () => { + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + return tomorrow.toISOString().substring(0, 16); +}; + +describe( + 'must submit order for market in monitoring auction', + { tags: '@regression' }, + () => { + before(() => { + cy.setVegaWallet(); + cy.mockTradingPage( + Schema.MarketState.STATE_SUSPENDED, + Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, + Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET + ); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + beforeEach(() => { + cy.setVegaWallet(); + }); + + it('successfully places limit buy order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + size: '100', + postOnly: false, + reduceOnly: false, + price: '200', + }; + createOrder(order); + testOrderSubmission(order, { price: '20000000' }); + }); + + it('successfully places limit sell order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + size: '100', + price: '50000', + postOnly: false, + reduceOnly: false, + }; + createOrder(order); + testOrderSubmission(order, { price: '5000000000' }); + }); + + it('successfully places GTT limit buy order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, + size: '100', + price: '1.00', + expiresAt: displayTomorrow(), + postOnly: false, + reduceOnly: false, + }; + createOrder(order); + testOrderSubmission(order, { + price: '100000', + expiresAt: + new Date(order.expiresAt as string).getTime().toString() + '000000', + }); + }); + } +); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-submit-opening-auction.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-opening-auction.cy.ts new file mode 100644 index 000000000..024ffb5e0 --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-opening-auction.cy.ts @@ -0,0 +1,85 @@ +import * as Schema from '@vegaprotocol/types'; +import { testOrderSubmission } from '../support/order-validation'; +import type { OrderSubmission } from '@vegaprotocol/wallet'; +import { createOrder } from '../support/create-order'; + +const displayTomorrow = () => { + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + return tomorrow.toISOString().substring(0, 16); +}; + +describe( + 'must submit order for market in opening auction', + { tags: '@regression' }, + () => { + before(() => { + cy.setVegaWallet(); + cy.mockTradingPage( + Schema.MarketState.STATE_SUSPENDED, + Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION, + Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET + ); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + beforeEach(() => { + cy.setVegaWallet(); + }); + + it('successfully places limit buy order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + size: '100', + postOnly: false, + reduceOnly: false, + price: '200', + }; + createOrder(order); + testOrderSubmission(order, { price: '20000000' }); + }); + + it('successfully places limit sell order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + size: '100', + postOnly: false, + reduceOnly: false, + price: '50000', + }; + createOrder(order); + testOrderSubmission(order, { price: '5000000000' }); + }); + + it('successfully places GTT limit buy order', () => { + cy.mockVegaWalletTransaction(); + const order: OrderSubmission = { + marketId: 'market-0', + type: Schema.OrderType.TYPE_LIMIT, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, + size: '100', + price: '1.00', + expiresAt: displayTomorrow(), + postOnly: false, + reduceOnly: false, + }; + createOrder(order); + testOrderSubmission(order, { + price: '100000', + expiresAt: + new Date(order.expiresAt as string).getTime().toString() + '000000', + }); + }); + } +); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-submit-suspended.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-suspended.cy.ts new file mode 100644 index 000000000..e766410e9 --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-submit-suspended.cy.ts @@ -0,0 +1,68 @@ +import * as Schema from '@vegaprotocol/types'; +import { + TIFlist, + orderPriceField, + orderSizeField, + orderTIFDropDown, + placeOrderBtn, + toggleLimit, + toggleMarket, +} from '../support/deal-ticket'; +import { aliasGQLQuery } from '@vegaprotocol/cypress'; +import { accountsQuery } from '@vegaprotocol/mock'; + +describe('suspended market validation', { tags: '@regression' }, () => { + before(() => { + cy.setVegaWallet(); + cy.mockTradingPage( + Schema.MarketState.STATE_SUSPENDED, + Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, + Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET + ); + const accounts = accountsQuery(); + cy.mockGQL((req) => { + aliasGQLQuery(req, 'Accounts', accounts); + }); + cy.mockSubscription(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + beforeEach(() => { + cy.setVegaWallet(); + }); + + it('should show warning for market order', function () { + cy.getByTestId(toggleMarket).click(); + cy.getByTestId(placeOrderBtn).should('not.be.disabled'); + cy.getByTestId(placeOrderBtn).click(); + cy.getByTestId(placeOrderBtn).should('be.disabled'); + cy.getByTestId('dealticket-error-message-type').should( + 'have.text', + 'This market is in auction until it reaches sufficient liquidity. Only limit orders are permitted when market is in auction' + ); + }); + + it('should show info for allowed TIF', function () { + cy.getByTestId(toggleLimit).click(); + cy.getByTestId(orderPriceField).clear().type('0.1'); + cy.getByTestId(orderSizeField).clear().type('1'); + cy.getByTestId(placeOrderBtn).should('be.enabled'); + cy.getByTestId('dealticket-warning-auction').should( + 'have.text', + 'Any orders placed now will not trade until the auction ends' + ); + }); + + it('should show warning for not allowed TIF', function () { + cy.getByTestId(toggleLimit).click(); + cy.getByTestId(orderTIFDropDown).select( + TIFlist.filter((item) => item.code === 'FOK')[0].value + ); + cy.getByTestId(placeOrderBtn).should('be.disabled'); + cy.getByTestId('dealticket-error-message-tif').should( + 'have.text', + 'This market is in auction until it reaches sufficient liquidity. Until the auction ends, you can only place GFA, GTT, or GTC limit orders' + ); + }); +}); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-submit.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-submit.cy.ts deleted file mode 100644 index 09976c0c7..000000000 --- a/apps/trading-e2e/src/integration/trading-deal-ticket-submit.cy.ts +++ /dev/null @@ -1,580 +0,0 @@ -import * as Schema from '@vegaprotocol/types'; -import { aliasGQLQuery } from '@vegaprotocol/cypress'; -import { testOrderSubmission } from '../support/order-validation'; -import type { OrderSubmission } from '@vegaprotocol/wallet'; -import { - accountsQuery, - estimateOrderQuery, - amendGeneralAccountBalance, -} from '@vegaprotocol/mock'; -import { createOrder } from '../support/create-order'; - -const orderSizeField = 'order-size'; -const orderPriceField = 'order-price'; -const orderTIFDropDown = 'order-tif'; -const placeOrderBtn = 'place-order'; -const toggleLimit = 'order-type-TYPE_LIMIT'; -const toggleMarket = 'order-type-TYPE_MARKET'; - -const TIFlist = Object.values(Schema.OrderTimeInForce).map((value) => { - return { - code: Schema.OrderTimeInForceCode[value], - value, - text: Schema.OrderTimeInForceMapping[value], - }; -}); - -const displayTomorrow = () => { - const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 1); - return tomorrow.toISOString().substring(0, 16); -}; - -describe('must submit order', { tags: '@smoke' }, () => { - // 7002-SORD-039 - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - beforeEach(() => { - cy.setVegaWallet(); - }); - - it('successfully places market buy order', () => { - // 7002-SORD-010 - // 0003-WTXN-012 - // 0003-WTXN-003 - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_MARKET, - side: Schema.Side.SIDE_BUY, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, - postOnly: false, - reduceOnly: false, - size: '100', - }; - createOrder(order); - testOrderSubmission(order); - }); - - it('successfully places market sell order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_MARKET, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_IOC, - size: '100', - postOnly: false, - reduceOnly: false, - }; - createOrder(order); - testOrderSubmission(order); - }); - - it('successfully places limit buy order', () => { - // 7002-SORD-017 - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_BUY, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, - size: '100', - postOnly: false, - reduceOnly: false, - price: '200', - }; - createOrder(order); - testOrderSubmission(order, { price: '20000000' }); - }); - - it('successfully places limit sell order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GFN, - size: '100', - postOnly: false, - reduceOnly: false, - price: '50000', - }; - createOrder(order); - testOrderSubmission(order, { price: '5000000000' }); - }); - - it('successfully places GTT limit buy order', () => { - cy.mockVegaWalletTransaction(); - const expiresAt = new Date(Date.now() + 24 * 60 * 60 * 1000); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, - size: '100', - price: '1.00', - expiresAt: expiresAt.toISOString().substring(0, 16), - postOnly: false, - reduceOnly: false, - }; - - createOrder(order); - testOrderSubmission(order, { - price: '100000', - expiresAt: - new Date(order.expiresAt as string).getTime().toString() + '000000', - postOnly: false, - reduceOnly: false, - }); - }); -}); - -describe( - 'must submit order for market in batch auction', - { tags: '@regression' }, - () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage( - Schema.MarketState.STATE_SUSPENDED, - Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION, - Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET - ); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - beforeEach(() => { - cy.setVegaWallet(); - }); - - it('successfully places limit buy order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_BUY, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, - size: '100', - postOnly: false, - reduceOnly: false, - price: '200', - }; - createOrder(order); - testOrderSubmission(order, { price: '20000000' }); - }); - - it('successfully places limit sell order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, - size: '100', - postOnly: false, - reduceOnly: false, - price: '50000', - }; - createOrder(order); - testOrderSubmission(order, { price: '5000000000' }); - }); - - it('successfully places GTT limit buy order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, - size: '100', - postOnly: false, - reduceOnly: false, - price: '1.00', - expiresAt: displayTomorrow(), - }; - createOrder(order); - testOrderSubmission(order, { - price: '100000', - postOnly: false, - reduceOnly: false, - expiresAt: - new Date(order.expiresAt as string).getTime().toString() + '000000', - }); - }); - } -); - -describe( - 'must submit order for market in opening auction', - { tags: '@regression' }, - () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage( - Schema.MarketState.STATE_SUSPENDED, - Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION, - Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET - ); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - beforeEach(() => { - cy.setVegaWallet(); - }); - - it('successfully places limit buy order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_BUY, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, - size: '100', - postOnly: false, - reduceOnly: false, - price: '200', - }; - createOrder(order); - testOrderSubmission(order, { price: '20000000' }); - }); - - it('successfully places limit sell order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, - size: '100', - postOnly: false, - reduceOnly: false, - price: '50000', - }; - createOrder(order); - testOrderSubmission(order, { price: '5000000000' }); - }); - - it('successfully places GTT limit buy order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, - size: '100', - price: '1.00', - expiresAt: displayTomorrow(), - postOnly: false, - reduceOnly: false, - }; - createOrder(order); - testOrderSubmission(order, { - price: '100000', - expiresAt: - new Date(order.expiresAt as string).getTime().toString() + '000000', - }); - }); - } -); - -describe( - 'must submit order for market in monitoring auction', - { tags: '@regression' }, - () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage( - Schema.MarketState.STATE_SUSPENDED, - Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, - Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET - ); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - beforeEach(() => { - cy.setVegaWallet(); - }); - - it('successfully places limit buy order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_BUY, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, - size: '100', - postOnly: false, - reduceOnly: false, - price: '200', - }; - createOrder(order); - testOrderSubmission(order, { price: '20000000' }); - }); - - it('successfully places limit sell order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, - size: '100', - price: '50000', - postOnly: false, - reduceOnly: false, - }; - createOrder(order); - testOrderSubmission(order, { price: '5000000000' }); - }); - - it('successfully places GTT limit buy order', () => { - cy.mockVegaWalletTransaction(); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_LIMIT, - side: Schema.Side.SIDE_SELL, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, - size: '100', - price: '1.00', - expiresAt: displayTomorrow(), - postOnly: false, - reduceOnly: false, - }; - createOrder(order); - testOrderSubmission(order, { - price: '100000', - expiresAt: - new Date(order.expiresAt as string).getTime().toString() + '000000', - }); - }); - } -); - -describe('suspended market validation', { tags: '@regression' }, () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage( - Schema.MarketState.STATE_SUSPENDED, - Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, - Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET - ); - const accounts = accountsQuery(); - cy.mockGQL((req) => { - aliasGQLQuery(req, 'Accounts', accounts); - }); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - beforeEach(() => { - cy.setVegaWallet(); - }); - - it('should show warning for market order', function () { - cy.getByTestId(toggleMarket).click(); - cy.getByTestId(placeOrderBtn).should('not.be.disabled'); - cy.getByTestId(placeOrderBtn).click(); - cy.getByTestId(placeOrderBtn).should('be.disabled'); - cy.getByTestId('dealticket-error-message-type').should( - 'have.text', - 'This market is in auction until it reaches sufficient liquidity. Only limit orders are permitted when market is in auction' - ); - }); - - it('should show info for allowed TIF', function () { - cy.getByTestId(toggleLimit).click(); - cy.getByTestId(orderPriceField).clear().type('0.1'); - cy.getByTestId(orderSizeField).clear().type('1'); - cy.getByTestId(placeOrderBtn).should('be.enabled'); - cy.getByTestId('dealticket-warning-auction').should( - 'have.text', - 'Any orders placed now will not trade until the auction ends' - ); - }); - - it('should show warning for not allowed TIF', function () { - cy.getByTestId(toggleLimit).click(); - cy.getByTestId(orderTIFDropDown).select( - TIFlist.filter((item) => item.code === 'FOK')[0].value - ); - cy.getByTestId(placeOrderBtn).should('be.disabled'); - cy.getByTestId('dealticket-error-message-tif').should( - 'have.text', - 'This market is in auction until it reaches sufficient liquidity. Until the auction ends, you can only place GFA, GTT, or GTC limit orders' - ); - }); -}); - -describe('account validation', { tags: '@regression' }, () => { - describe('zero balance error', () => { - beforeEach(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - const accounts = accountsQuery(); - amendGeneralAccountBalance(accounts, 'market-0', '0'); - cy.mockGQL((req) => { - aliasGQLQuery(req, 'Accounts', accounts); - }); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - it('should show an error if your balance is zero', () => { - cy.getByTestId('place-order').should('be.disabled'); - // 7002-SORD-003 - cy.getByTestId('dealticket-error-message-zero-balance').should( - 'have.text', - 'You need ' + - 'tDAI' + - ' in your wallet to trade in this market.See all your collateral.Make a deposit' - ); - cy.getByTestId('deal-ticket-deposit-dialog-button').should('exist'); - }); - }); - - describe('not enough balance warning', () => { - beforeEach(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - const accounts = accountsQuery(); - amendGeneralAccountBalance(accounts, 'market-0', '100000000'); - cy.mockGQL((req) => { - aliasGQLQuery(req, 'Accounts', accounts); - }); - cy.mockGQL((req) => { - aliasGQLQuery(req, 'EstimateOrder', estimateOrderQuery()); - }); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - it('should display info and button for deposit', () => { - // 7002-SORD-003 - - // warning should show immediately - cy.getByTestId('dealticket-warning-margin').should( - 'contain.text', - 'You may not have enough margin available to open this position' - ); - cy.getByTestId('dealticket-warning-margin').should( - 'contain.text', - 'You may not have enough margin available to open this position. 2,354.72283 tDAI is currently required. You have only 1,000.01 tDAI available.' - ); - cy.getByTestId('deal-ticket-deposit-dialog-button').click(); - cy.getByTestId('dialog-content') - .find('h1') - .eq(0) - .should('have.text', 'Deposit'); - }); - }); - - describe('must submit order', { tags: '@smoke' }, () => { - // 7002-SORD-039 - beforeEach(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - it('must see a prompt to check connected vega wallet to approve transaction', () => { - // 0003-WTXN-002 - cy.mockVegaWalletTransaction(1000); - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_MARKET, - side: Schema.Side.SIDE_BUY, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, - size: '100', - }; - createOrder(order); - cy.getByTestId('toast-content').should( - 'contain.text', - 'Please go to your Vega wallet application and approve or reject the transaction.' - ); - }); - - it('must show error returned by wallet ', () => { - // 0003-WTXN-009 - // 0003-WTXN-011 - // 0002-WCON-016 - // 0003-WTXN-008 - - //trigger error from the wallet - cy.intercept('POST', 'http://localhost:1789/api/v2/requests', (req) => { - req.on('response', (res) => { - res.send({ - jsonrpc: '2.0', - id: '1', - }); - }); - }); - - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_MARKET, - side: Schema.Side.SIDE_BUY, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, - size: '100', - }; - createOrder(order); - cy.getByTestId('toast-content').should( - 'contain.text', - 'The connection to your Vega Wallet has been lost.' - ); - cy.getByTestId('connect-vega-wallet').click(); - cy.getByTestId('dialog-content').should('be.visible'); - }); - - it('must see that the order was rejected by the connected wallet', () => { - // 0003-WTXN-007 - - //trigger rejection error from the wallet - cy.intercept('POST', 'http://localhost:1789/api/v2/requests', (req) => { - req.alias = 'client.send_transaction'; - req.reply({ - statusCode: 400, - body: { - jsonrpc: '2.0', - error: { - code: 3001, - data: 'the user rejected the wallet connection', - message: 'User error', - }, - id: '0', - }, - }); - }); - - const order: OrderSubmission = { - marketId: 'market-0', - type: Schema.OrderType.TYPE_MARKET, - side: Schema.Side.SIDE_BUY, - timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, - size: '100', - }; - createOrder(order); - cy.getByTestId('toast-content').should( - 'contain.text', - 'Error occurredthe user rejected the wallet connection' - ); - }); - }); -}); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-time-in-force.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-time-in-force.cy.ts new file mode 100644 index 000000000..c7112276d --- /dev/null +++ b/apps/trading-e2e/src/integration/trading-deal-ticket-time-in-force.cy.ts @@ -0,0 +1,157 @@ +import { + TIFlist, + orderTIFDropDown, + toggleLimit, + toggleMarket, +} from '../support/deal-ticket'; + +describe('time in force validation', { tags: '@smoke' }, () => { + before(() => { + cy.setVegaWallet(); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.clearAllLocalStorage(); + cy.visit('/#/markets/market-0'); + cy.wait('@Markets'); + }); + + it('must have market order set up to IOC by default', function () { + // 7002-SORD-030 + cy.getByTestId(toggleMarket).click(); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + TIFlist.filter((item) => item.code === 'IOC')[0].text + ); + }); + + it('must have time in force set to GTC for limit order', function () { + // 7002-SORD-031 + cy.getByTestId(toggleLimit).click(); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + TIFlist.filter((item) => item.code === 'GTC')[0].text + ); + }); + + it('selections should be remembered', () => { + cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_GTT'); + cy.getByTestId(toggleMarket).click(); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + TIFlist.filter((item) => item.code === 'IOC')[0].text + ); + cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_FOK'); + cy.getByTestId(toggleLimit).click(); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + TIFlist.filter((item) => item.code === 'GTT')[0].text + ); + cy.getByTestId(toggleMarket).click(); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + TIFlist.filter((item) => item.code === 'FOK')[0].text + ); + }); + + describe('limit order', () => { + before(() => { + cy.getByTestId(toggleLimit).click(); + }); + const validTIF = TIFlist; + validTIF.forEach((tif) => { + // 7002-SORD-023 + // 7002-SORD-024 + // 7002-SORD-025 + // 7002-SORD-026 + // 7002-SORD-027 + // 7002-SORD-028 + + it(`must be able to select ${tif.code}`, function () { + cy.getByTestId(orderTIFDropDown).select(tif.value); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + tif.text + ); + }); + }); + }); + + describe('market order', () => { + before(() => { + cy.getByTestId(toggleMarket).click(); + }); + + const validTIF = TIFlist.filter((tif) => ['FOK', 'IOC'].includes(tif.code)); + const invalidTIF = TIFlist.filter( + (tif) => !['FOK', 'IOC'].includes(tif.code) + ); + + validTIF.forEach((tif) => { + // 7002-SORD-025 + // 7002-SORD-026 + + it(`must be able to select ${tif.code}`, function () { + cy.getByTestId(orderTIFDropDown).select(tif.value); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + tif.text + ); + }); + }); + + invalidTIF.forEach((tif) => { + // 7002-SORD-023 + // 7002-SORD-024 + // 7002-SORD-027 + // 7002-SORD-028 + it(`must not be able to select ${tif.code}`, function () { + cy.getByTestId(orderTIFDropDown).should('not.contain', tif.text); + }); + }); + }); + + describe('post and reduce - market order', () => { + before(() => { + cy.getByTestId(toggleMarket).click(); + }); + + const validTIF = TIFlist.filter((tif) => ['FOK', 'IOC'].includes(tif.code)); + + validTIF.forEach((tif) => { + // 7002-SORD-025 + // 7002-SORD-026 + + it(`post and reduce order market for ${tif.code}`, function () { + cy.getByTestId(orderTIFDropDown).select(tif.value); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + tif.text + ); + cy.getByTestId('post-only').should('be.disabled'); + cy.getByTestId('reduce-only').should('be.enabled'); + }); + }); + }); + + describe('post and reduce - limit order', () => { + before(() => { + cy.getByTestId(toggleLimit).click(); + }); + + const validTIFLimit = TIFlist.filter((tif) => + ['GFA', 'GFN', 'GTC', 'GTT'].includes(tif.code) + ); + + validTIFLimit.forEach((tif) => { + it(`post and reduce order for limit ${tif.code}`, function () { + cy.getByTestId(orderTIFDropDown).select(tif.value); + cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( + 'have.text', + tif.text + ); + cy.getByTestId('post-only').should('be.enabled'); + cy.getByTestId('reduce-only').should('be.disabled'); + }); + }); + }); +}); diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-validations.cy.ts b/apps/trading-e2e/src/integration/trading-deal-ticket-validations.cy.ts deleted file mode 100644 index b84b2f783..000000000 --- a/apps/trading-e2e/src/integration/trading-deal-ticket-validations.cy.ts +++ /dev/null @@ -1,329 +0,0 @@ -import * as Schema from '@vegaprotocol/types'; -import { mockConnectWallet } from '@vegaprotocol/cypress'; - -const orderSizeField = 'order-size'; -const orderPriceField = 'order-price'; -const orderTIFDropDown = 'order-tif'; -const placeOrderBtn = 'place-order'; -const toggleShort = 'order-side-SIDE_SELL'; -const toggleLong = 'order-side-SIDE_BUY'; -const toggleLimit = 'order-type-TYPE_LIMIT'; -const toggleMarket = 'order-type-TYPE_MARKET'; - -const TIFlist = Object.values(Schema.OrderTimeInForce).map((value) => { - return { - code: Schema.OrderTimeInForceCode[value], - value, - text: Schema.OrderTimeInForceMapping[value], - }; -}); - -describe('time in force default values', () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - it('must have market order set up to IOC by default', function () { - // 7002-SORD-030 - cy.getByTestId(toggleMarket).click(); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - TIFlist.filter((item) => item.code === 'IOC')[0].text - ); - }); - - it('must have time in force set to GTC for limit order', function () { - // 7002-SORD-031 - cy.getByTestId(toggleLimit).click(); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - TIFlist.filter((item) => item.code === 'GTC')[0].text - ); - }); -}); - -describe('deal ticket validation', { tags: '@smoke' }, () => { - beforeEach(() => { - cy.mockTradingPage(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - it('must show place order button and connect wallet if wallet is not connected', () => { - // 0003-WTXN-001 - cy.getByTestId('connect-vega-wallet'); // Not connected - cy.getByTestId('order-connect-wallet').should('exist'); - cy.getByTestId(placeOrderBtn).should('exist'); - cy.getByTestId('deal-ticket-connect-wallet').should('exist'); - }); - - it('must be able to select order direction - long/short', function () { - // 7002-SORD-004 - cy.getByTestId(toggleShort).click().children('input').should('be.checked'); - cy.getByTestId(toggleLong).click().children('input').should('be.checked'); - }); - - it('must be able to select order type - limit/market', function () { - // 7002-SORD-005 - // 7002-SORD-006 - // 7002-SORD-007 - cy.getByTestId(toggleLimit).click().children('input').should('be.checked'); - cy.getByTestId(toggleMarket).click().children('input').should('be.checked'); - }); - - it('order connect vega wallet button should connect', () => { - mockConnectWallet(); - cy.getByTestId(toggleLimit).click(); - cy.getByTestId(orderPriceField).clear().type('101'); - cy.getByTestId('order-connect-wallet').click(); - cy.getByTestId('dialog-content').should('be.visible'); - cy.getByTestId('connectors-list') - .find('[data-testid="connector-jsonRpc"]') - .click(); - cy.wait('@walletReq'); - cy.getByTestId(placeOrderBtn).should('be.visible'); - cy.getByTestId(toggleLimit).children('input').should('be.checked'); - cy.getByTestId(orderPriceField).should('have.value', '101'); - }); -}); - -describe('deal ticket size validation', { tags: '@smoke' }, function () { - beforeEach(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - it('must warn if order size input has too many digits after the decimal place', function () { - // 7002-SORD-016 - cy.getByTestId('order-type-TYPE_MARKET').click(); - cy.getByTestId(orderSizeField).clear().type('1.234'); - cy.getByTestId(placeOrderBtn).should('not.be.disabled'); - cy.getByTestId(placeOrderBtn).click(); - cy.getByTestId(placeOrderBtn).should('be.disabled'); - cy.getByTestId('dealticket-error-message-size-market').should( - 'have.text', - 'Size must be whole numbers for this market' - ); - }); - - it('must warn if order size is set to 0', function () { - cy.getByTestId('order-type-TYPE_MARKET').click(); - cy.getByTestId(orderSizeField).clear().type('0'); - cy.getByTestId(placeOrderBtn).should('not.be.disabled'); - cy.getByTestId(placeOrderBtn).click(); - cy.getByTestId(placeOrderBtn).should('be.disabled'); - cy.getByTestId('dealticket-error-message-size-market').should( - 'have.text', - 'Size cannot be lower than 1' - ); - }); -}); - -describe('limit order validations', { tags: '@smoke' }, () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - cy.getByTestId(toggleLimit).click(); - }); - - beforeEach(() => { - cy.setVegaWallet(); - }); - - it('must see the price unit', function () { - // 7002-SORD-018 - cy.getByTestId(orderPriceField) - .siblings('label') - .should('have.text', 'Price (DAI)'); - }); - - it('must see warning when placing an order with expiry date in past', () => { - const expiresAt = new Date(Date.now() - 24 * 60 * 60 * 1000); - const expiresAtInputValue = expiresAt.toISOString().substring(0, 16); - cy.getByTestId(toggleLimit).click(); - cy.getByTestId(orderPriceField).clear().type('0.1'); - cy.getByTestId(orderSizeField).clear().type('1'); - cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_GTT'); - - cy.log('choosing yesterday'); - cy.getByTestId('date-picker-field').type(expiresAtInputValue); - - cy.getByTestId(placeOrderBtn).click(); - - cy.getByTestId('dealticket-error-message-expiry').should( - 'have.text', - 'The expiry date that you have entered appears to be in the past' - ); - }); - - it('must see warning if price has too many digits after decimal place', function () { - // 7002-SORD-059 - cy.getByTestId(toggleLimit).click(); - cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_GTC'); - cy.getByTestId(orderSizeField).clear().type('1'); - cy.getByTestId(orderPriceField).clear().type('1.123456'); - cy.getByTestId('dealticket-error-message-price-limit').should( - 'have.text', - 'Price accepts up to 5 decimal places' - ); - }); - - describe('time in force validations', function () { - const validTIF = TIFlist; - validTIF.forEach((tif) => { - // 7002-SORD-023 - // 7002-SORD-024 - // 7002-SORD-025 - // 7002-SORD-026 - // 7002-SORD-027 - // 7002-SORD-028 - - it(`must be able to select ${tif.code}`, function () { - cy.getByTestId(orderTIFDropDown).select(tif.value); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - tif.text - ); - }); - }); - - it('selections should be remembered', () => { - cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_GTT'); - cy.getByTestId(toggleMarket).click(); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - TIFlist.filter((item) => item.code === 'IOC')[0].text - ); - cy.getByTestId(orderTIFDropDown).select('TIME_IN_FORCE_FOK'); - cy.getByTestId(toggleLimit).click(); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - TIFlist.filter((item) => item.code === 'GTT')[0].text - ); - cy.getByTestId(toggleMarket).click(); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - TIFlist.filter((item) => item.code === 'FOK')[0].text - ); - }); - }); -}); - -describe('market order validations', { tags: '@smoke' }, () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - cy.getByTestId(toggleMarket).click(); - }); - - beforeEach(() => { - cy.setVegaWallet(); - }); - - it('must not see the price unit', function () { - // 7002-SORD-019 - cy.getByTestId(orderPriceField).should('not.exist'); - }); - - describe('time in force validations', function () { - const validTIF = TIFlist.filter((tif) => ['FOK', 'IOC'].includes(tif.code)); - const invalidTIF = TIFlist.filter( - (tif) => !['FOK', 'IOC'].includes(tif.code) - ); - - validTIF.forEach((tif) => { - // 7002-SORD-025 - // 7002-SORD-026 - - it(`must be able to select ${tif.code}`, function () { - cy.getByTestId(orderTIFDropDown).select(tif.value); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - tif.text - ); - }); - }); - - invalidTIF.forEach((tif) => { - // 7002-SORD-023 - // 7002-SORD-024 - // 7002-SORD-027 - // 7002-SORD-028 - it(`must not be able to select ${tif.code}`, function () { - cy.getByTestId(orderTIFDropDown).should('not.contain', tif.text); - }); - }); - }); -}); - -describe('post and reduce order validations', { tags: '@smoke' }, () => { - before(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - cy.getByTestId(toggleMarket).click(); - }); - - beforeEach(() => { - cy.setVegaWallet(); - }); - - const validTIF = TIFlist.filter((tif) => ['FOK', 'IOC'].includes(tif.code)); - - validTIF.forEach((tif) => { - // 7002-SORD-025 - // 7002-SORD-026 - - it(`post and reduce order market for ${tif.code}`, function () { - cy.getByTestId(orderTIFDropDown).select(tif.value); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - tif.text - ); - cy.getByTestId('post-only').should('be.disabled'); - cy.getByTestId('reduce-only').should('be.enabled'); - }); - }); - - validTIF.forEach((tif) => { - it(`post and reduce order limit for ${tif.code}`, function () { - cy.getByTestId(toggleLimit).click(); - cy.getByTestId(orderTIFDropDown).select(tif.value); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - tif.text - ); - cy.getByTestId('post-only').should('be.disabled'); - cy.getByTestId('reduce-only').should('be.enabled'); - }); - }); - - const validTIFLimit = TIFlist.filter((tif) => - ['GFA', 'GFN', 'GTC', 'GTT'].includes(tif.code) - ); - - validTIFLimit.forEach((tif) => { - it(`post and reduce order for limit ${tif.code}`, function () { - cy.getByTestId(toggleLimit).click(); - cy.getByTestId(orderTIFDropDown).select(tif.value); - cy.get(`[data-testid=${orderTIFDropDown}] option:selected`).should( - 'have.text', - tif.text - ); - cy.getByTestId('post-only').should('be.enabled'); - cy.getByTestId('reduce-only').should('be.disabled'); - }); - }); -}); diff --git a/apps/trading-e2e/src/integration/trading-orders.cy.ts b/apps/trading-e2e/src/integration/trading-orders.cy.ts index d22054c04..f3a459f7a 100644 --- a/apps/trading-e2e/src/integration/trading-orders.cy.ts +++ b/apps/trading-e2e/src/integration/trading-orders.cy.ts @@ -21,7 +21,7 @@ const cancelOrderBtn = 'cancel'; const cancelAllOrdersBtn = 'cancelAll'; const editOrderBtn = 'edit'; -describe('orders list', { tags: '@smoke' }, () => { +describe('orders list', { tags: '@smoke', testIsolation: true }, () => { beforeEach(() => { const subscriptionMocks = getSubscriptionMocks(); cy.spy(subscriptionMocks, 'OrdersUpdate'); @@ -89,15 +89,17 @@ describe('orders list', { tags: '@smoke' }, () => { cy.contains('Partially Filled').click(); cy.getByTestId('Orders').click(); - cy.get(`[row-id="${partiallyFilledId}"]`).within(() => { - cy.get(`[col-id='${orderStatus}']`).should( - 'have.text', - 'Partially Filled' - ); - cy.get(`[col-id='${orderRemaining}']`).should('have.text', '7/10'); - cy.getByTestId(cancelOrderBtn).should('not.exist'); - cy.getByTestId(editOrderBtn).should('not.exist'); - }); + cy.get(`[row-id="${partiallyFilledId}"]`) + .eq(1) + .within(() => { + cy.get(`[col-id='${orderStatus}']`).should( + 'have.text', + 'Partially Filled' + ); + cy.get(`[col-id='${orderRemaining}']`).should('have.text', '7/10'); + cy.getByTestId(cancelOrderBtn).should('not.exist'); + cy.getByTestId(editOrderBtn).should('not.exist'); + }); }); it('orders are sorted by most recent order', () => { @@ -424,7 +426,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => { .find(`[data-testid="cancel"]`) .should('have.text', 'Cancel') .then(($btn) => { - cy.wrap($btn).click(); + cy.wrap($btn).click({ force: true }); const order: OrderCancellation = { orderId: orderId, marketId: 'market-0', @@ -445,7 +447,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => { cy.get(`[data-testid="cancelAll"]`) .should('have.text', 'Cancel all') .then(($btn) => { - cy.wrap($btn).click(); + cy.wrap($btn).click({ force: true }); const order: OrderCancellation = { marketId: 'market-0', }; @@ -464,7 +466,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => { .find('[data-testid="edit"]') .should('have.text', 'Edit') .then(($btn) => { - cy.wrap($btn).click(); + cy.wrap($btn).click({ force: true }); cy.getByTestId('dialog-title').should('have.text', 'Edit order'); cy.get('#limitPrice').focus().clear().type('0.111111'); cy.getByTestId('edit-order').find('[type="submit"]').click(); diff --git a/apps/trading-e2e/src/integration/trading-positions.cy.ts b/apps/trading-e2e/src/integration/trading-positions.cy.ts index 1d4c12b78..64b729bea 100644 --- a/apps/trading-e2e/src/integration/trading-positions.cy.ts +++ b/apps/trading-e2e/src/integration/trading-positions.cy.ts @@ -8,7 +8,7 @@ beforeEach(() => { cy.setVegaWallet(); }); -describe('positions', { tags: '@smoke' }, () => { +describe('positions', { tags: '@smoke', testIsolation: true }, () => { it('renders positions on trading page', () => { cy.visit('/#/markets/market-0'); cy.getByTestId('Positions').click(); @@ -53,13 +53,17 @@ describe('positions', { tags: '@smoke' }, () => { 'currentLeverage', 'averageEntryPrice', ]; - cy.getByTestId('tab-positions').within(() => { - cy.get('[row-id="market-2"]').within(() => { - emptyCells.forEach((cell) => { - cy.get(`[col-id="${cell}"]`).should('contain.text', '-'); - }); + cy.getByTestId('tab-positions') + .first() + .within(() => { + cy.get('[row-id="market-2"]') + .eq(1) + .within(() => { + emptyCells.forEach((cell) => { + cy.get(`[col-id="${cell}"]`).should('contain.text', '-'); + }); + }); }); - }); }); it('error message should be displayed', () => { const errors = [ diff --git a/apps/trading-e2e/src/integration/wallet-eth.cy.ts b/apps/trading-e2e/src/integration/wallet-eth.cy.ts index 8e3947160..f21be5665 100644 --- a/apps/trading-e2e/src/integration/wallet-eth.cy.ts +++ b/apps/trading-e2e/src/integration/wallet-eth.cy.ts @@ -2,7 +2,7 @@ import { connectEthereumWallet } from '../support/ethereum-wallet'; const connectEthWalletBtn = 'connect-eth-wallet-btn'; -describe('ethereum wallet', { tags: '@smoke' }, () => { +describe('ethereum wallet', { tags: '@smoke', testIsolation: true }, () => { beforeEach(() => { cy.mockWeb3Provider(); // Using portfolio withdrawals tab is it requires Ethereum wallet connection diff --git a/apps/trading-e2e/src/integration/wallet-vega.cy.ts b/apps/trading-e2e/src/integration/wallet-vega.cy.ts index 0d25c8892..5842f2e21 100644 --- a/apps/trading-e2e/src/integration/wallet-vega.cy.ts +++ b/apps/trading-e2e/src/integration/wallet-vega.cy.ts @@ -8,103 +8,115 @@ const manageVegaBtn = 'manage-vega-wallet'; const form = 'rest-connector-form'; const dialogContent = 'dialog-content'; -describe('connect hosted wallet', { tags: '@smoke' }, () => { - beforeEach(() => { - // Using portfolio page as it requires vega wallet connection - cy.visit('/#/portfolio'); - cy.mockTradingPage(); - cy.mockSubscription(); - cy.get('main[data-testid="/portfolio"]').should('exist'); - }); - - it('can connect', () => { - // 0002-WCON-002 - // 0002-WCON-003 - // 0002-WCON-039 - // 0002-WCON-017 - // 0002-WCON-018 - // 0002-WCON-019 - - // Mock authentication - cy.intercept('POST', 'https://wallet.testnet.vega.xyz/api/v1/auth/token', { - body: { - token: 'test-token', - }, +describe( + 'connect hosted wallet', + { tags: '@smoke', testIsolation: true }, + () => { + beforeEach(() => { + // Using portfolio page as it requires vega wallet connection + cy.visit('/#/portfolio'); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.get('main[data-testid="/portfolio"]').should('exist'); }); - // Mock getting keys from wallet - cy.intercept('GET', 'https://wallet.testnet.vega.xyz/api/v1/keys', { - body: { - keys: [ - { - algorithm: { - name: 'algo', - version: 1, - }, - index: 0, - meta: [], - pub: 'HOSTED_PUBKEY', - tainted: false, + + it('can connect', () => { + // 0002-WCON-002 + // 0002-WCON-003 + // 0002-WCON-039 + // 0002-WCON-017 + // 0002-WCON-018 + // 0002-WCON-019 + + // Mock authentication + cy.intercept( + 'POST', + 'https://wallet.testnet.vega.xyz/api/v1/auth/token', + { + body: { + token: 'test-token', }, - ], - }, + } + ); + // Mock getting keys from wallet + cy.intercept('GET', 'https://wallet.testnet.vega.xyz/api/v1/keys', { + body: { + keys: [ + { + algorithm: { + name: 'algo', + version: 1, + }, + index: 0, + meta: [], + pub: 'HOSTED_PUBKEY', + tainted: false, + }, + ], + }, + }); + cy.getByTestId(connectVegaBtn).click(); + cy.contains( + 'Choose wallet app to connect, or to change port or server URL enter a custom wallet location first' + ); + cy.contains('Connect Vega wallet'); + cy.contains('Hosted Fairground wallet'); + + cy.getByTestId('connectors-list') + .find('[data-testid="connector-hosted"]') + .click(); + cy.getByTestId(form).find('#wallet').click().type('user'); + cy.getByTestId(form).find('#passphrase').click().type('pass'); + cy.getByTestId('rest-connector-form').find('button[type=submit]').click(); + cy.getByTestId(manageVegaBtn).should('exist'); + cy.getByTestId('manage-vega-wallet').click(); + cy.getByTestId('keypair-list').should('exist'); }); - cy.getByTestId(connectVegaBtn).click(); - cy.contains( - 'Choose wallet app to connect, or to change port or server URL enter a custom wallet location first' - ); - cy.contains('Connect Vega wallet'); - cy.contains('Hosted Fairground wallet'); - cy.getByTestId('connectors-list') - .find('[data-testid="connector-hosted"]') - .click(); - cy.getByTestId(form).find('#wallet').click().type('user'); - cy.getByTestId(form).find('#passphrase').click().type('pass'); - cy.getByTestId('rest-connector-form').find('button[type=submit]').click(); - cy.getByTestId(manageVegaBtn).should('exist'); - cy.getByTestId('manage-vega-wallet').click(); - cy.getByTestId('keypair-list').should('exist'); - }); + it('doesnt connect with invalid credentials', () => { + // 0002-WCON-020 - it('doesnt connect with invalid credentials', () => { - // 0002-WCON-020 - - // Mock incorrect username/password - cy.intercept('POST', 'https://wallet.testnet.vega.xyz/api/v1/auth/token', { - body: { - error: 'No wallet', - }, - statusCode: 403, // 403 forbidden invalid crednetials + // Mock incorrect username/password + cy.intercept( + 'POST', + 'https://wallet.testnet.vega.xyz/api/v1/auth/token', + { + body: { + error: 'No wallet', + }, + statusCode: 403, // 403 forbidden invalid crednetials + } + ); + cy.getByTestId(connectVegaBtn).click(); + cy.getByTestId('connectors-list') + .find('[data-testid="connector-hosted"]') + .click(); + cy.getByTestId(form).find('#wallet').click().type('invalid name'); + cy.getByTestId(form).find('#passphrase').click().type('invalid password'); + cy.getByTestId('rest-connector-form').find('button[type=submit]').click(); + cy.getByTestId('form-error').should('have.text', 'Invalid credentials'); }); - cy.getByTestId(connectVegaBtn).click(); - cy.getByTestId('connectors-list') - .find('[data-testid="connector-hosted"]') - .click(); - cy.getByTestId(form).find('#wallet').click().type('invalid name'); - cy.getByTestId(form).find('#passphrase').click().type('invalid password'); - cy.getByTestId('rest-connector-form').find('button[type=submit]').click(); - cy.getByTestId('form-error').should('have.text', 'Invalid credentials'); - }); - it('doesnt connect with empty fields', () => { - cy.getByTestId(connectVegaBtn).click(); - cy.getByTestId('connectors-list') - .find('[data-testid="connector-hosted"]') - .click(); + it('doesnt connect with empty fields', () => { + cy.getByTestId(connectVegaBtn).click(); + cy.getByTestId('connectors-list') + .find('[data-testid="connector-hosted"]') + .click(); - cy.getByTestId('rest-connector-form').find('button[type=submit]').click(); - cy.getByTestId(form) - .find('#wallet') - .next('[data-testid="input-error-text"]') - .should('have.text', 'Required'); - cy.getByTestId(form) - .find('#passphrase') - .next('[data-testid="input-error-text"]') - .should('have.text', 'Required'); - }); -}); + cy.getByTestId('rest-connector-form').find('button[type=submit]').click(); + cy.getByTestId(form) + .find('#wallet') + .next('[data-testid="input-error-text"]') + .should('have.text', 'Required'); + cy.getByTestId(form) + .find('#passphrase') + .next('[data-testid="input-error-text"]') + .should('have.text', 'Required'); + }); + } +); -describe('connect vega wallet', { tags: '@smoke' }, () => { +describe('connect vega wallet', { tags: '@smoke', testIsolation: true }, () => { beforeEach(() => { // Using portfolio page as it requires vega wallet connection cy.visit('/#/portfolio'); 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 9cad74ffb..4097ef914 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 @@ -88,48 +88,54 @@ describe( } ); -describe('withdraw actions', { tags: '@regression' }, () => { - beforeEach(() => { - cy.mockWeb3Provider(); - cy.mockTradingPage(); - cy.mockSubscription(); - cy.setVegaWallet(); +describe( + 'withdraw actions', + { tags: '@regression', testIsolation: true }, + () => { + beforeEach(() => { + cy.mockWeb3Provider(); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.setVegaWallet(); - cy.visit('/#/portfolio'); - cy.getByTestId(collateralTab).click(); - cy.getByTestId(openTransferDialog).click(); + cy.visit('/#/portfolio'); + cy.getByTestId(collateralTab).click(); + cy.getByTestId(openTransferDialog).click(); - cy.wait('@Accounts'); - cy.wait('@Assets'); - cy.mockVegaWalletTransaction(); - }); + cy.wait('@Accounts'); + cy.wait('@Assets'); + cy.mockVegaWalletTransaction(); + }); - it('key to key transfers by select key', function () { - cy.getByTestId(transferForm).should('be.visible'); - cy.getByTestId(transferForm).find(toAddressField).select(1); - selectAsset(ASSET_SEPOLIA_TBTC); - cy.getByTestId(transferForm).find(amountField).type('1', { delay: 100 }); - cy.getByTestId(transferForm).find(submitTransferBtn).click(); - cy.getByTestId(toastContent).should( - 'contain.text', - 'Awaiting confirmation' - ); - cy.getByTestId(toastCloseBtn).click(); - }); + it('key to key transfers by select key', function () { + cy.getByTestId(transferForm).should('be.visible'); + cy.getByTestId(transferForm).find(toAddressField).select(1); + selectAsset(ASSET_SEPOLIA_TBTC); + cy.getByTestId(transferForm).find(amountField).type('1', { delay: 100 }); + cy.getByTestId(transferForm).find(submitTransferBtn).click(); + cy.getByTestId(toastContent).should( + 'contain.text', + 'Awaiting confirmation' + ); + cy.getByTestId(toastCloseBtn).click(); + }); - it('key to key transfers by enter manual key', function () { - cy.getByTestId(transferForm).should('be.visible'); - cy.contains('Enter manually').click(); - cy.getByTestId(transferForm) - .find(toAddressField) - .type('7f9cf07d3a9905b1a61a1069f7a758855da428bc0f4a97de87f48644bfc25535'); - selectAsset(ASSET_SEPOLIA_TBTC); - cy.getByTestId(transferForm).find(amountField).type('1', { delay: 100 }); - cy.getByTestId(transferForm).find(submitTransferBtn).click(); - cy.getByTestId(toastContent).should( - 'contain.text', - 'Awaiting confirmation' - ); - cy.getByTestId(toastCloseBtn).click(); - }); -}); + it('key to key transfers by enter manual key', function () { + cy.getByTestId(transferForm).should('be.visible'); + cy.contains('Enter manually').click(); + cy.getByTestId(transferForm) + .find(toAddressField) + .type( + '7f9cf07d3a9905b1a61a1069f7a758855da428bc0f4a97de87f48644bfc25535' + ); + selectAsset(ASSET_SEPOLIA_TBTC); + cy.getByTestId(transferForm).find(amountField).type('1', { delay: 100 }); + cy.getByTestId(transferForm).find(submitTransferBtn).click(); + cy.getByTestId(toastContent).should( + 'contain.text', + 'Awaiting confirmation' + ); + cy.getByTestId(toastCloseBtn).click(); + }); + } +); diff --git a/apps/trading-e2e/src/integration/withdraw.cy.ts b/apps/trading-e2e/src/integration/withdraw.cy.ts index 04c416796..35747ae94 100644 --- a/apps/trading-e2e/src/integration/withdraw.cy.ts +++ b/apps/trading-e2e/src/integration/withdraw.cy.ts @@ -70,54 +70,60 @@ describe('withdraw form validation', { tags: '@smoke' }, () => { }); }); -describe('withdraw actions', { tags: '@regression' }, () => { - // this is extremely ugly hack, but setting it properly in contract is too much effort for such simple validation +describe( + 'withdraw actions', + { tags: '@regression', testIsolation: true }, + () => { + // this is extremely ugly hack, but setting it properly in contract is too much effort for such simple validation - // 1002-WITH-018 + // 1002-WITH-018 - const withdrawalThreshold = - Cypress.env('VEGA_ENV') === 'CUSTOM' ? '0.00' : '100.00'; - before(() => { - cy.mockWeb3Provider(); - cy.mockTradingPage(); - cy.mockSubscription(); - cy.setVegaWallet(); + const withdrawalThreshold = + Cypress.env('VEGA_ENV') === 'CUSTOM' ? '0.00' : '100.00'; + before(() => { + cy.mockWeb3Provider(); + cy.mockTradingPage(); + cy.mockSubscription(); + cy.setVegaWallet(); - cy.visit('/#/portfolio'); - cy.getByTestId('Withdrawals').click(); - cy.getByTestId('withdraw-dialog-button').click(); + cy.visit('/#/portfolio'); + cy.getByTestId('Withdrawals').click(); - connectEthereumWallet('MetaMask'); + cy.getByTestId('withdraw-dialog-button').click(); - cy.wait('@Accounts'); - cy.wait('@Assets'); - cy.mockVegaWalletTransaction(); - }); + // It also requires connection Ethereum wallet + connectEthereumWallet('MetaMask'); - it('triggers transaction when submitted', () => { - // 1002-WITH-002 - // 1002-WITH-003 - selectAsset(ASSET_SEPOLIA_TBTC); - cy.getByTestId('BALANCE_AVAILABLE_label').should( - 'contain.text', - 'Balance available' - ); - cy.getByTestId('BALANCE_AVAILABLE_value').should( - 'have.text', - '1,000.00001' - ); - cy.getByTestId('WITHDRAWAL_THRESHOLD_label').should( - 'contain.text', - 'Delayed withdrawal threshold' - ); - cy.getByTestId('WITHDRAWAL_THRESHOLD_value').should( - 'contain.text', - withdrawalThreshold - ); - cy.getByTestId('DELAY_TIME_label').should('contain.text', 'Delay time'); - cy.getByTestId('DELAY_TIME_value').should('have.text', 'None'); - cy.get(amountField).clear().type('10'); - cy.getByTestId(submitWithdrawBtn).click(); - cy.getByTestId('toast').should('contain.text', 'Awaiting confirmation'); - }); -}); + cy.wait('@Accounts'); + cy.wait('@Assets'); + cy.mockVegaWalletTransaction(); + }); + + it('triggers transaction when submitted', () => { + // 1002-WITH-002 + // 1002-WITH-003 + selectAsset(ASSET_SEPOLIA_TBTC); + cy.getByTestId('BALANCE_AVAILABLE_label').should( + 'contain.text', + 'Balance available' + ); + cy.getByTestId('BALANCE_AVAILABLE_value').should( + 'have.text', + '1,000.00001' + ); + cy.getByTestId('WITHDRAWAL_THRESHOLD_label').should( + 'contain.text', + 'Delayed withdrawal threshold' + ); + cy.getByTestId('WITHDRAWAL_THRESHOLD_value').should( + 'contain.text', + withdrawalThreshold + ); + cy.getByTestId('DELAY_TIME_label').should('contain.text', 'Delay time'); + cy.getByTestId('DELAY_TIME_value').should('have.text', 'None'); + cy.get(amountField).clear().type('10'); + cy.getByTestId(submitWithdrawBtn).click(); + cy.getByTestId('toast').should('contain.text', 'Awaiting confirmation'); + }); + } +); diff --git a/apps/trading-e2e/src/support/deal-ticket.ts b/apps/trading-e2e/src/support/deal-ticket.ts new file mode 100644 index 000000000..c1fdcdd32 --- /dev/null +++ b/apps/trading-e2e/src/support/deal-ticket.ts @@ -0,0 +1,18 @@ +import * as Schema from '@vegaprotocol/types'; + +export const orderSizeField = 'order-size'; +export const orderPriceField = 'order-price'; +export const orderTIFDropDown = 'order-tif'; +export const placeOrderBtn = 'place-order'; +export const toggleShort = 'order-side-SIDE_SELL'; +export const toggleLong = 'order-side-SIDE_BUY'; +export const toggleLimit = 'order-type-TYPE_LIMIT'; +export const toggleMarket = 'order-type-TYPE_MARKET'; + +export const TIFlist = Object.values(Schema.OrderTimeInForce).map((value) => { + return { + code: Schema.OrderTimeInForceCode[value], + value, + text: Schema.OrderTimeInForceMapping[value], + }; +}); diff --git a/libs/cypress/src/lib/commands/add-connect-public-key.ts b/libs/cypress/src/lib/commands/add-connect-public-key.ts index b3708b80a..e5816aba0 100644 --- a/libs/cypress/src/lib/commands/add-connect-public-key.ts +++ b/libs/cypress/src/lib/commands/add-connect-public-key.ts @@ -10,14 +10,15 @@ declare global { export const addConnectPublicKey = () => { Cypress.Commands.add('connectPublicKey', (publicKey) => { - cy.getByTestId('connect-vega-wallet').then((connectWallet) => { - if (connectWallet.length) { - cy.get('aside [data-testid="connect-vega-wallet"]').click(); - cy.getByTestId('connector-view').should('be.visible').click(); - cy.getByTestId('address').click(); - cy.getByTestId('address').type(publicKey); - cy.getByTestId('connect').click(); - } - }); + const connectVegaWaletBtn = Cypress.$( + `[data-testid="connect-vega-wallet"]` + ); + if (connectVegaWaletBtn.length > 0) { + cy.get('aside [data-testid="connect-vega-wallet"]').click(); + cy.getByTestId('connector-view').should('be.visible').click(); + cy.getByTestId('address').click(); + cy.getByTestId('address').type(publicKey); + cy.getByTestId('connect').click(); + } }); }; diff --git a/libs/cypress/src/lib/commands/vega-wallet-connect.ts b/libs/cypress/src/lib/commands/vega-wallet-connect.ts index ab04edfb6..75148bb3c 100644 --- a/libs/cypress/src/lib/commands/vega-wallet-connect.ts +++ b/libs/cypress/src/lib/commands/vega-wallet-connect.ts @@ -33,19 +33,27 @@ export function addVegaWalletConnect() { Cypress.Commands.add('connectVegaWallet', (isMobile) => { mockConnectWallet(); cy.highlight(`Connecting Vega Wallet`); - cy.get( - `[data-testid=connect-vega-wallet${isMobile ? '-mobile' : ''}]:visible` - ).click(); - cy.get('[data-testid=connectors-list]') - .find('[data-testid="connector-jsonRpc"]') - .click(); - cy.wait('@walletReq'); - cy.get('[data-testid=dialog-content]').should( - 'contain.text', - 'Successfully connected' - ); - cy.getByTestId('dialog-close').click(); - cy.get('[data-testid=dialog-content]').should('not.exist'); + const connectVegaWalletButton = `[data-testid=connect-vega-wallet${ + isMobile ? '-mobile' : '' + }]:visible`; + + cy.get(connectVegaWalletButton).then((btn) => { + if (btn.length === 0) { + cy.log('could not find the button, perhaps already connected'); + return; + } + cy.wrap(btn).click(); + cy.get('[data-testid=connectors-list]') + .find('[data-testid="connector-jsonRpc"]') + .click(); + cy.wait('@walletReq'); + cy.get('[data-testid=dialog-content]').should( + 'contain.text', + 'Successfully connected' + ); + cy.getByTestId('dialog-close').click(); + cy.get('[data-testid=dialog-content]').should('not.exist'); + }); }); } diff --git a/libs/cypress/tsconfig.json b/libs/cypress/tsconfig.json index 5bd611d96..4f8196443 100644 --- a/libs/cypress/tsconfig.json +++ b/libs/cypress/tsconfig.json @@ -18,6 +18,7 @@ "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": false, "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "sourceMap": false } } diff --git a/libs/datagrid/src/lib/cell-class-rules.ts b/libs/datagrid/src/lib/cell-class-rules.ts index b05a1de66..055cdafdb 100644 --- a/libs/datagrid/src/lib/cell-class-rules.ts +++ b/libs/datagrid/src/lib/cell-class-rules.ts @@ -3,11 +3,13 @@ export const negativeClassNames = 'text-vega-pink dark:text-vega-pink'; const isPositive = ({ value }: { value: string | bigint | number }) => !!value && - ((typeof value === 'string' && !value.startsWith('-')) || value > 0); + ((typeof value === 'string' && !value.startsWith('-')) || + ((typeof value === 'number' || typeof value === 'bigint') && value > 0)); const isNegative = ({ value }: { value: string | bigint | number }) => !!value && - ((typeof value === 'string' && value.startsWith('-')) || value < 0); + ((typeof value === 'string' && value.startsWith('-')) || + ((typeof value === 'number' || typeof value === 'bigint') && value < 0)); export const signedNumberCssClass = (value: string | bigint | number) => { if (isPositive({ value })) { diff --git a/libs/react-helpers/src/hooks/use-fetch.ts b/libs/react-helpers/src/hooks/use-fetch.ts index d3df3e631..d8c1a5f53 100644 --- a/libs/react-helpers/src/hooks/use-fetch.ts +++ b/libs/react-helpers/src/hooks/use-fetch.ts @@ -80,6 +80,7 @@ export const useFetch = ( } data = (await response.json()) as T; + // @ts-ignore - 'error' in data if (data && 'error' in data) { // @ts-ignore - data.error throw new Error(data.error); diff --git a/package.json b/package.json index acef1a5ab..07a4afaa8 100644 --- a/package.json +++ b/package.json @@ -149,8 +149,8 @@ "autoprefixer": "10.4.8", "babel-jest": "27.5.1", "babel-loader": "8.1.0", - "cypress": "^11.2.0", - "cypress-real-events": "^1.7.1", + "cypress": "^12.9.0", + "cypress-real-events": "^1.7.6", "dotenv": "^16.0.1", "eslint": "8.15.0", "eslint-config-next": "12.2.3", @@ -190,7 +190,7 @@ "ts-node": "10.9.1", "tslib": "^2.0.0", "type-fest": "^2.12.2", - "typescript": "4.7.4", + "typescript": "^5.0.4", "url-loader": "^3.0.0" }, "lint-staged": { diff --git a/yarn.lock b/yarn.lock index 5c7e63dba..f7361019c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11008,15 +11008,15 @@ cyclist@^1.0.1: resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9" integrity sha512-NJGVKPS81XejHcLhaLJS7plab0fK3slPh11mESeeDq2W4ZI5kUKK/LRRdVDvjJseojbPB7ZwjnyOybg3Igea/A== -cypress-real-events@^1.7.1: - version "1.7.1" - resolved "https://registry.yarnpkg.com/cypress-real-events/-/cypress-real-events-1.7.1.tgz#8f430d67c29ea4f05b9c5b0311780120cbc9b935" - integrity sha512-/Bg15RgJ0SYsuXc6lPqH08x19z6j2vmhWN4wXfJqm3z8BTAFiK2MvipZPzxT8Z0jJP0q7kuniWrLIvz/i/8lCQ== +cypress-real-events@^1.7.6: + version "1.7.6" + resolved "https://registry.yarnpkg.com/cypress-real-events/-/cypress-real-events-1.7.6.tgz#6f17e0b2ceea1d6dc60f6737d8f84cc517bbbb4c" + integrity sha512-yP6GnRrbm6HK5q4DH6Nnupz37nOfZu/xn1xFYqsE2o4G73giPWQOdu6375QYpwfU1cvHNCgyD2bQ2hPH9D7NMw== -cypress@^11.2.0: - version "11.2.0" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-11.2.0.tgz#63edef8c387b687066c5493f6f0ad7b9ced4b2b7" - integrity sha512-u61UGwtu7lpsNWLUma/FKNOsrjcI6wleNmda/TyKHe0dOBcVjbCPlp1N6uwFZ0doXev7f/91YDpU9bqDCFeBLA== +cypress@^12.9.0: + version "12.9.0" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.9.0.tgz#e6ab43cf329fd7c821ef7645517649d72ccf0a12" + integrity sha512-Ofe09LbHKgSqX89Iy1xen2WvpgbvNxDzsWx3mgU1mfILouELeXYGwIib3ItCwoRrRifoQwcBFmY54Vs0zw7QCg== dependencies: "@cypress/request" "^2.88.10" "@cypress/xvfb" "^1.2.4" @@ -11035,7 +11035,7 @@ cypress@^11.2.0: commander "^5.1.0" common-tags "^1.8.0" dayjs "^1.10.4" - debug "^4.3.2" + debug "^4.3.4" enquirer "^2.3.6" eventemitter2 "6.4.7" execa "4.1.0" @@ -22304,16 +22304,16 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== -typescript@4.7.4: - version "4.7.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" - integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== - typescript@^4.4.3: version "4.8.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== +typescript@^5.0.4: + version "5.0.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" + integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== + ua-parser-js@^0.7.30: version "0.7.31" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6"