chore(ci): bump typescript (#3444)

Co-authored-by: Mikołaj Młodzikowski <mikolaj.mlodzikowski@gmail.com>
This commit is contained in:
Art 2023-04-20 13:56:33 +02:00 committed by GitHub
parent c15051d457
commit e4a51061a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 1534 additions and 1447 deletions

View File

@ -26,7 +26,7 @@ jobs:
with: with:
path: node_modules path: node_modules
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }} 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: | restore-keys: |
${{ runner.os }}-cache-node-modules- ${{ runner.os }}-cache-node-modules-
@ -50,7 +50,7 @@ jobs:
secrets: inherit secrets: inherit
lint-test-build: lint-test-build:
timeout-minutes: 60 timeout-minutes: 35
needs: node-modules needs: node-modules
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
name: '(CI) lint + unit test + build' name: '(CI) lint + unit test + build'

View File

@ -20,7 +20,7 @@ jobs:
project: ${{ fromJSON(inputs.projects) }} project: ${{ fromJSON(inputs.projects) }}
name: ${{ matrix.project }} name: ${{ matrix.project }}
runs-on: self-hosted-runner runs-on: self-hosted-runner
timeout-minutes: 30 timeout-minutes: 40
steps: steps:
# Checks if skip cache was requested # Checks if skip cache was requested
- name: Set skip-nx-cache flag - name: Set skip-nx-cache flag

View File

@ -15,7 +15,7 @@ jobs:
app: ${{ fromJSON(inputs.projects) }} app: ${{ fromJSON(inputs.projects) }}
name: ${{ matrix.app }} name: ${{ matrix.app }}
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
timeout-minutes: 20 timeout-minutes: 25
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v3 uses: actions/checkout@v3

View File

@ -21,6 +21,7 @@ module.exports = defineConfig({
chromeWebSecurity: false, chromeWebSecurity: false,
viewportWidth: 1440, viewportWidth: 1440,
viewportHeight: 900, viewportHeight: 900,
testIsolation: false,
}, },
env: { env: {
environment: 'CUSTOM', environment: 'CUSTOM',

View File

@ -25,6 +25,7 @@ module.exports = defineConfig({
viewportWidth: 1440, viewportWidth: 1440,
viewportHeight: 900, viewportHeight: 900,
numTestsKeptInMemory: 5, numTestsKeptInMemory: 5,
testIsolation: false,
}, },
env: { env: {
ethProviderUrl: 'http://localhost:8545/', ethProviderUrl: 'http://localhost:8545/',

View File

@ -40,18 +40,22 @@ const stakeAddStakeRadioButton = 'add-stake-radio';
const stakeMaximumTokens = 'token-amount-use-maximum'; const stakeMaximumTokens = 'token-amount-use-maximum';
const vegaWalletAssociatedBalance = 'currency-value'; const vegaWalletAssociatedBalance = 'currency-value';
const vegaWalletStakedBalances = 'vega-wallet-balance-staked-validators'; const vegaWalletStakedBalances = 'vega-wallet-balance-staked-validators';
const ethWalletContainer = 'ethereum-wallet'; const ethWallet = 'ethereum-wallet';
const vegaWallet = 'vega-wallet'; const vegaWallet = 'vega-wallet';
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
const txTimeout = Cypress.env('txTimeout'); const txTimeout = Cypress.env('txTimeout');
const epochTimeout = Cypress.env('epochTimeout'); const epochTimeout = Cypress.env('epochTimeout');
const getEthereumWallet = () => cy.get(`[data-testid="${ethWallet}"]:visible`);
const getVegaWallet = () => cy.get(`[data-testid="${vegaWallet}"]:visible`);
context( context(
'Staking Tab - with eth and vega wallets connected', 'Staking Tab - with eth and vega wallets connected',
{ tags: '@slow' }, { tags: '@slow' },
function () { function () {
// 2001-STKE-002, 2001-STKE-032 // 2001-STKE-002, 2001-STKE-032
before('visit staking tab and connect vega wallet', function () { before('visit staking tab and connect vega wallet', function () {
cy.clearAllLocalStorage();
cy.visit('/'); cy.visit('/');
ethereumWalletConnect(); ethereumWalletConnect();
// this is a workaround for #2422 which can be removed once issue is resolved // this is a workaround for #2422 which can be removed once issue is resolved
@ -187,31 +191,35 @@ context(
.should('contain', 1.0, txTimeout); .should('contain', 1.0, txTimeout);
closeStakingDialog(); closeStakingDialog();
navigateTo(navigation.validators); navigateTo(navigation.validators);
cy.get(`[row-id="${0}"]`).within(() => { cy.get(`[row-id="${0}"]`)
cy.getByTestId(stakeValidatorListTotalStake) .eq(1)
.should('have.text', '2.00') .within(() => {
.and('be.visible'); cy.getByTestId(stakeValidatorListTotalStake)
cy.getByTestId(stakeValidatorListTotalShare) .should('have.text', '2.00')
.should('have.text', '66.67%') .and('be.visible');
.and('be.visible'); cy.getByTestId(stakeValidatorListTotalShare)
cy.getByTestId(stakeValidatorListTotalStake) .should('have.text', '66.67%')
.scrollIntoView() .and('be.visible');
.should('have.text', '2.00') cy.getByTestId(stakeValidatorListTotalStake)
.and('be.visible'); .scrollIntoView()
}); .should('have.text', '2.00')
cy.get(`[row-id="${1}"]`).within(() => { .and('be.visible');
cy.getByTestId(stakeValidatorListTotalStake) });
.scrollIntoView() cy.get(`[row-id="${1}"]`)
.should('have.text', '1.00') .eq(1)
.and('be.visible'); .within(() => {
cy.getByTestId(stakeValidatorListTotalShare) cy.getByTestId(stakeValidatorListTotalStake)
.should('have.text', '33.33%') .scrollIntoView()
.and('be.visible'); .should('have.text', '1.00')
cy.getByTestId(stakeValidatorListTotalStake) .and('be.visible');
.scrollIntoView() cy.getByTestId(stakeValidatorListTotalShare)
.should('have.text', '1.00') .should('have.text', '33.33%')
.and('be.visible'); .and('be.visible');
}); cy.getByTestId(stakeValidatorListTotalStake)
.scrollIntoView()
.should('have.text', '1.00')
.and('be.visible');
});
}); });
// 2001-STKE-041 // 2001-STKE-041
@ -329,11 +337,11 @@ context(
verifyStakedBalance(2.0); verifyStakedBalance(2.0);
closeStakingDialog(); closeStakingDialog();
stakingPageDisassociateAllTokens(); stakingPageDisassociateAllTokens();
cy.getByTestId(ethWalletContainer).within(() => { getEthereumWallet().within(() => {
cy.contains(vegaWalletPublicKeyShort, txTimeout).should('not.exist'); cy.contains(vegaWalletPublicKeyShort, txTimeout).should('not.exist');
}); });
verifyEthWalletTotalAssociatedBalance('0.0'); verifyEthWalletTotalAssociatedBalance('0.0');
cy.getByTestId(vegaWallet).within(() => { getVegaWallet().within(() => {
cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should( cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'0.00' '0.00'
@ -357,11 +365,11 @@ context(
verifyStakedBalance(2.0); verifyStakedBalance(2.0);
closeStakingDialog(); closeStakingDialog();
stakingPageDisassociateAllTokens('contract'); stakingPageDisassociateAllTokens('contract');
cy.getByTestId(ethWalletContainer).within(() => { getEthereumWallet().within(() => {
cy.contains(vegaWalletPublicKeyShort, txTimeout).should('not.exist'); cy.contains(vegaWalletPublicKeyShort, txTimeout).should('not.exist');
}); });
verifyEthWalletTotalAssociatedBalance('0.0'); verifyEthWalletTotalAssociatedBalance('0.0');
cy.getByTestId(vegaWallet).within(() => { getVegaWallet().within(() => {
cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should( cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'0.00' '0.00'
@ -386,7 +394,7 @@ context(
closeStakingDialog(); closeStakingDialog();
stakingPageDisassociateTokens('1'); stakingPageDisassociateTokens('1');
verifyEthWalletTotalAssociatedBalance('2.0'); verifyEthWalletTotalAssociatedBalance('2.0');
cy.getByTestId(vegaWallet).within(() => { getVegaWallet().within(() => {
cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should( cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'2.00' '2.00'
@ -453,7 +461,7 @@ context(
verifyUnstakedBalance(0.0); verifyUnstakedBalance(0.0);
closeStakingDialog(); closeStakingDialog();
stakingPageAssociateTokens('6'); stakingPageAssociateTokens('6');
cy.getByTestId(vegaWallet).within(() => { getVegaWallet().within(() => {
cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should( cy.getByTestId(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'12.00' '12.00'

View File

@ -45,10 +45,12 @@ context('View functionality with public key', { tags: '@smoke' }, function () {
navigateTo(navigation.proposals); navigateTo(navigation.proposals);
goToMakeNewProposal('Freeform'); goToMakeNewProposal('Freeform');
enterUniqueFreeFormProposalBody('50', 'pub key proposal test'); enterUniqueFreeFormProposalBody('50', 'pub key proposal test');
cy.getByTestId('dialog-content').within(() => { cy.getByTestId('dialog-content')
cy.get('h1').should('have.text', 'Transaction failed'); .first()
cy.getByTestId('Error').should('have.text', expectedErrorTxt); .within(() => {
}); cy.get('h1').should('have.text', 'Transaction failed');
cy.getByTestId('Error').should('have.text', expectedErrorTxt);
});
}); });
it('Able to disconnect via banner', function () { it('Able to disconnect via banner', function () {

View File

@ -1,7 +1,6 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
import { import {
navigateTo,
navigation, navigation,
verifyPageHeader, verifyPageHeader,
verifyTabHighlighted, verifyTabHighlighted,
@ -34,8 +33,8 @@ const stakeNumberRegex = /^\d*\.?\d*$/;
context('Validators Page - verify elements on page', function () { context('Validators Page - verify elements on page', function () {
before('navigate to validators page', function () { before('navigate to validators page', function () {
cy.visit('/'); cy.clearAllLocalStorage();
navigateTo(navigation.validators); cy.visit('/validators');
}); });
describe('with wallets disconnected', { tags: '@smoke' }, function () { describe('with wallets disconnected', { tags: '@smoke' }, function () {

View File

@ -43,23 +43,25 @@ context(
// 1005-VEST-020 1005-VEST-021 // 1005-VEST-020 1005-VEST-021
it('Tokens in vesting contract for eth wallet is displayed on wallet window', function () { it('Tokens in vesting contract for eth wallet is displayed on wallet window', function () {
cy.getByTestId('vega-in-vesting-contract').within(() => { cy.get('[data-testid="vega-in-vesting-contract"]:visible').within(
cy.getByTestId('currency-title') () => {
.should('contain.text', 'VEGA') cy.getByTestId('currency-title')
.and('contain.text', 'In vesting contract'); .should('contain.text', 'VEGA')
cy.get('[data-testid="currency-value"]:visible').should( .and('contain.text', 'In vesting contract');
'have.text', cy.get('[data-testid="currency-value"]:visible').should(
lockedTokensInVestingContract 'have.text',
); lockedTokensInVestingContract
cy.get('[data-testid="currency-locked"]:visible').should( );
'have.text', cy.get('[data-testid="currency-locked"]:visible').should(
lockedTokensInVestingContract 'have.text',
); lockedTokensInVestingContract
cy.get('[data-testid="currency-unlocked"]:visible').should( );
'have.text', cy.get('[data-testid="currency-unlocked"]:visible').should(
'0.00' 'have.text',
); '0.00'
}); );
}
);
}); });
// 1005-VEST-022 1005-VEST-023 // 1005-VEST-022 1005-VEST-023
it('Tokens amount displayed in vesting page', function () { it('Tokens amount displayed in vesting page', function () {

View File

@ -17,7 +17,7 @@ const vegaInWallet = '[data-testid="vega-in-wallet"]:visible';
const progressBar = '[data-testid="progress-bar"]:visible'; const progressBar = '[data-testid="progress-bar"]:visible';
const currencyLocked = '[data-testid="currency-locked"]:visible'; const currencyLocked = '[data-testid="currency-locked"]:visible';
const currencyUnlocked = '[data-testid="currency-unlocked"]:visible'; const currencyUnlocked = '[data-testid="currency-unlocked"]:visible';
const dialog = '[role="dialog"]'; const dialog = '[role="dialog"]:visible';
const dialogHeader = '[data-testid="dialog-title"]'; const dialogHeader = '[data-testid="dialog-title"]';
const dialogCloseBtn = '[data-testid="dialog-close"]'; const dialogCloseBtn = '[data-testid="dialog-close"]';

View File

@ -7,7 +7,7 @@ const walletContainer = 'aside [data-testid="vega-wallet"]';
const walletHeader = '[data-testid="wallet-header"] h1'; const walletHeader = '[data-testid="wallet-header"] h1';
const connectButton = '[data-testid="connect-vega-wallet"]'; const connectButton = '[data-testid="connect-vega-wallet"]';
const getVegaLink = '[data-testid="link"]'; const getVegaLink = '[data-testid="link"]';
const dialog = '[role="dialog"]'; const dialog = '[role="dialog"]:visible';
const dialogHeader = '[data-testid="dialog-title"]'; const dialogHeader = '[data-testid="dialog-title"]';
const walletDialogHeader = '[data-testid="wallet-dialog-title"]'; const walletDialogHeader = '[data-testid="wallet-dialog-title"]';
const connectorsList = '[data-testid="connectors-list"]'; const connectorsList = '[data-testid="connectors-list"]';
@ -35,6 +35,7 @@ context(
{ tags: '@regression' }, { tags: '@regression' },
() => { () => {
before('visit token home page', () => { before('visit token home page', () => {
cy.clearAllLocalStorage();
cy.visit('/'); cy.visit('/');
cy.get(walletContainer, { timeout: 60000 }).should('be.visible'); cy.get(walletContainer, { timeout: 60000 }).should('be.visible');
}); });

View File

@ -26,9 +26,11 @@ const topLevelRoutes = [
export function navigateTo(page: navigation) { export function navigateTo(page: navigation) {
if (!topLevelRoutes.includes(page)) { if (!topLevelRoutes.includes(page)) {
cy.getByTestId(tokenDropDown, { timeout: 10000 }).eq(0).click(); cy.getByTestId(tokenDropDown, { timeout: 10000 }).eq(0).click();
cy.getByTestId('token-dropdown').within(() => { cy.getByTestId('token-dropdown')
cy.get(page).eq(0).click(); .first()
}); .within(() => {
cy.get(page).eq(0).click();
});
} else { } else {
return cy.get(navigation.section, { timeout: 10000 }).within(() => { return cy.get(navigation.section, { timeout: 10000 }).within(() => {
cy.get(page).eq(0).click(); cy.get(page).eq(0).click();

View File

@ -184,16 +184,18 @@ export function validateValidatorListTotalStakeAndShare(
) { ) {
cy.contains('Loading...', epochTimeout).should('not.exist'); cy.contains('Loading...', epochTimeout).should('not.exist');
waitForBeginningOfEpoch(); waitForBeginningOfEpoch();
cy.get(`[row-id="${positionOnList}"]`).within(() => { cy.get(`[row-id="${positionOnList}"]:visible`)
cy.getByTestId(stakeValidatorListTotalStake, epochTimeout).should( .eq(1)
'have.text', .within(() => {
expectedTotalStake cy.getByTestId(stakeValidatorListTotalStake, epochTimeout).should(
); 'have.text',
cy.getByTestId(stakeValidatorListTotalShare, epochTimeout).should( expectedTotalStake
'have.text', );
expectedTotalShare cy.getByTestId(stakeValidatorListTotalShare, epochTimeout).should(
); 'have.text',
}); expectedTotalShare
);
});
} }
export function ensureSpecifiedUnstakedTokensAreAssociated( export function ensureSpecifiedUnstakedTokensAreAssociated(
@ -218,13 +220,15 @@ export function ensureSpecifiedUnstakedTokensAreAssociated(
} }
export function closeStakingDialog() { export function closeStakingDialog() {
cy.getByTestId('dialog-title').should( cy.get('[data-testid="dialog-title"]:visible').should(
'contain.text', 'contain.text',
'At the beginning of the next epoch' 'At the beginning of the next epoch'
); );
cy.getByTestId('dialog-content').within(() => { cy.get('[data-testid="dialog-content"]:visible')
cy.get('a').should('have.text', 'Back to Staking').click(); .first()
}); .within(() => {
cy.get('a').should('have.text', 'Back to Staking').click();
});
} }
export function validateWalletCurrency( export function validateWalletCurrency(

View File

@ -9,7 +9,7 @@ import {
import { ethers, Wallet } from 'ethers'; import { ethers, Wallet } from 'ethers';
const associatedAmountInWallet = '[data-testid="associated-amount"]:visible'; 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 vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic');
const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey'); const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey');
const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress'); const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress');

View File

@ -23,6 +23,7 @@ module.exports = defineConfig({
responseTimeout: 50000, responseTimeout: 50000,
requestTimeout: 20000, requestTimeout: 20000,
retries: 2, retries: 2,
testIsolation: false,
}, },
env: { env: {
ETHERSCAN_URL: 'https://sepolia.etherscan.io', ETHERSCAN_URL: 'https://sepolia.etherscan.io',

View File

@ -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`
);
});
});
});
});

View File

@ -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');
});
});

View File

@ -1,5 +1,3 @@
import { aliasGQLQuery } from '@vegaprotocol/cypress';
import { proposalListQuery, marketUpdateProposal } from '@vegaprotocol/mock';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
const marketSummaryBlock = 'header-summary'; const marketSummaryBlock = 'header-summary';
@ -15,50 +13,9 @@ const priceChangeValue = 'price-change';
const itemHeader = 'item-header'; const itemHeader = 'item-header';
const itemValue = 'item-value'; 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', () => { describe('Market trading page', () => {
before(() => { before(() => {
cy.clearAllLocalStorage();
cy.mockTradingPage( cy.mockTradingPage(
Schema.MarketState.STATE_ACTIVE, Schema.MarketState.STATE_ACTIVE,
Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
@ -165,6 +122,7 @@ describe('Market trading page', () => {
}); });
}); });
cy.getByTestId('expiry-tooltip') cy.getByTestId('expiry-tooltip')
.eq(0)
.should( .should(
'contain.text', 'contain.text',
'This market expires when triggered by its oracle, not on a set date.' 'This market expires when triggered by its oracle, not on a set date.'
@ -202,6 +160,7 @@ describe('Market trading page', () => {
'contain.text', 'contain.text',
'This market is in auction until it reaches sufficient liquidity.' 'This market is in auction until it reaches sufficient liquidity.'
) )
.eq(0)
.within(() => { .within(() => {
cy.getByTestId('external-link') cy.getByTestId('external-link')
.should('have.attr', 'href') .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');
});
});
});
}); });

View File

@ -1,27 +1,32 @@
import { mockConnectWallet } from '@vegaprotocol/cypress'; import { mockConnectWallet } from '@vegaprotocol/cypress';
beforeEach(() => { describe('Navbar', { tags: '@smoke' }, () => {
cy.mockTradingPage(); before(() => {
cy.mockSubscription(); cy.clearAllLocalStorage();
cy.visit('/'); cy.mockTradingPage();
cy.wait('@Markets'); cy.mockSubscription();
cy.wait('@MarketsData'); cy.visit('/');
cy.wait('@MarketsCandles'); cy.wait('@Markets');
cy.getByTestId('dialog-close').click(); cy.wait('@MarketsData');
}); cy.wait('@MarketsCandles');
// close welcome dialog
cy.getByTestId('dialog-close').click();
});
describe('Desktop view', { tags: '@smoke' }, () => { const pages = [
describe('Navbar', () => { { name: 'Markets', link: '#/markets/all' },
const links = ['Markets', 'Trading', 'Portfolio']; { name: 'Trading', link: '#/markets' },
const hashes = ['#/markets/all', '#/markets/market-1', '#/portfolio']; { name: 'Portfolio', link: '#/portfolio' },
];
links.forEach((link, index) => { describe('desktop view', () => {
it(`${link} should be correctly rendered`, () => { pages.forEach(({ name, link }) => {
it(`${name} should be correctly rendered`, () => {
cy.get('nav') cy.get('nav')
.find(`a[data-testid=${link}]:visible`) .find(`a[data-testid=${name}]:visible`)
.then((element) => { .then((element) => {
cy.wrap(element).click(); 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' }, () => { describe('mobile view', () => {
const viewportHeight = Cypress.config('viewportHeight'); const viewportHeight = Cypress.config('viewportHeight');
const viewportWidth = Cypress.config('viewportWidth'); const viewportWidth = Cypress.config('viewportWidth');
before(() => { before(() => {
// a little hack to keep the viewport size between tests (cypress bug) // a little hack to keep the viewport size between tests (cypress bug)
Cypress.config({ Cypress.config({
viewportWidth: 560, viewportWidth: 560,
viewportHeight: 890, viewportHeight: 890,
});
cy.viewport(560, 890);
}); });
cy.viewport(560, 890);
});
describe('wallet drawer', () => { describe('wallet drawer', () => {
it('wallet drawer should be correctly rendered', () => { it('wallet drawer should be correctly rendered', () => {
mockConnectWallet(); mockConnectWallet();
cy.connectVegaWallet(true); cy.connectVegaWallet(true);
cy.getByTestId('connect-vega-wallet-mobile').click(); cy.getByTestId('connect-vega-wallet-mobile').click();
cy.getByTestId('wallets-drawer').should('be.visible'); cy.getByTestId('wallets-drawer').should('be.visible');
cy.getByTestId('wallets-drawer').within((el) => { cy.getByTestId('wallets-drawer').within((el) => {
cy.wrap(el).get('button').contains('Disconnect').click(); cy.wrap(el).get('button').contains('Disconnect').click();
}); });
cy.getByTestId('wallets-drawer').should('not.be.visible'); 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');
}); });
}); });
it('Menu drawer should not be visible until opened', () => { describe('menu drawer', () => {
cy.getByTestId('menu-drawer').should('not.be.visible'); pages.forEach(({ name, link }) => {
cy.getByTestId('button-menu-drawer').click(); it(`${name} should be correctly rendered`, () => {
cy.getByTestId('menu-drawer').should('be.visible'); cy.getByTestId('button-menu-drawer').click();
cy.getByTestId('menu-drawer') cy.getByTestId('menu-drawer').should('be.visible');
.find('[data-testid="theme-switcher"]') cy.getByTestId('menu-drawer').within((el) => {
.should('be.visible'); cy.wrap(el).getByTestId(name).click();
cy.getByTestId('button-menu-drawer').click(); cy.location('hash').should('contain', link);
cy.getByTestId('menu-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');
});
}); });
}); after(() => {
after(() => { // a little hack to keep the viewport size between tests (cypress bug)
// a little hack to keep the viewport size between tests (cypress bug) Cypress.config({
Cypress.config({ viewportWidth,
viewportWidth, viewportHeight,
viewportHeight, });
}); });
}); });
}); });

View File

@ -1,14 +1,16 @@
import { checkSorting } from '@vegaprotocol/cypress'; import { checkSorting } from '@vegaprotocol/cypress';
beforeEach(() => {
cy.mockTradingPage();
cy.mockWeb3Provider();
cy.mockSubscription();
cy.setVegaWallet();
cy.visit('/#/markets/market-0');
});
describe('accounts', { tags: '@smoke' }, () => { 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', () => { it('renders accounts', () => {
const tradingAccountRowId = '[row-id="t-0"]'; const tradingAccountRowId = '[row-id="t-0"]';
cy.getByTestId('Collateral').click(); cy.getByTestId('Collateral').click();
@ -41,13 +43,21 @@ describe('accounts', { tags: '@smoke' }, () => {
.should('have.text', '100,001.01'); .should('have.text', '100,001.01');
}); });
it('asset detail should be properly rendered', () => { it('should open asset details dialog when clicked on symbol', () => {
cy.getByTestId('Collateral').click();
cy.getByTestId('asset').contains('tEURO').click(); 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', () => { 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', () => { it('sorting by asset', () => {
cy.getByTestId('Collateral').click(); cy.getByTestId('Collateral').click();
const marketsSortedDefault = ['tBTC', 'tEURO', 'tDAI', 'tBTC']; const marketsSortedDefault = ['tBTC', 'tEURO', 'tDAI', 'tBTC'];

View File

@ -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,
});
});
});

View File

@ -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');
});
});
});
}
);

View File

@ -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'
);
});
});
});

View File

@ -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'
);
});
});
}
);

View File

@ -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',
});
});
}
);

View File

@ -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',
});
});
}
);

View File

@ -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',
});
});
}
);

View File

@ -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'
);
});
});

View File

@ -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'
);
});
});
});

View File

@ -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');
});
});
});
});

View File

@ -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');
});
});
});

View File

@ -21,7 +21,7 @@ const cancelOrderBtn = 'cancel';
const cancelAllOrdersBtn = 'cancelAll'; const cancelAllOrdersBtn = 'cancelAll';
const editOrderBtn = 'edit'; const editOrderBtn = 'edit';
describe('orders list', { tags: '@smoke' }, () => { describe('orders list', { tags: '@smoke', testIsolation: true }, () => {
beforeEach(() => { beforeEach(() => {
const subscriptionMocks = getSubscriptionMocks(); const subscriptionMocks = getSubscriptionMocks();
cy.spy(subscriptionMocks, 'OrdersUpdate'); cy.spy(subscriptionMocks, 'OrdersUpdate');
@ -89,15 +89,17 @@ describe('orders list', { tags: '@smoke' }, () => {
cy.contains('Partially Filled').click(); cy.contains('Partially Filled').click();
cy.getByTestId('Orders').click(); cy.getByTestId('Orders').click();
cy.get(`[row-id="${partiallyFilledId}"]`).within(() => { cy.get(`[row-id="${partiallyFilledId}"]`)
cy.get(`[col-id='${orderStatus}']`).should( .eq(1)
'have.text', .within(() => {
'Partially Filled' cy.get(`[col-id='${orderStatus}']`).should(
); 'have.text',
cy.get(`[col-id='${orderRemaining}']`).should('have.text', '7/10'); 'Partially Filled'
cy.getByTestId(cancelOrderBtn).should('not.exist'); );
cy.getByTestId(editOrderBtn).should('not.exist'); 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', () => { it('orders are sorted by most recent order', () => {
@ -424,7 +426,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => {
.find(`[data-testid="cancel"]`) .find(`[data-testid="cancel"]`)
.should('have.text', 'Cancel') .should('have.text', 'Cancel')
.then(($btn) => { .then(($btn) => {
cy.wrap($btn).click(); cy.wrap($btn).click({ force: true });
const order: OrderCancellation = { const order: OrderCancellation = {
orderId: orderId, orderId: orderId,
marketId: 'market-0', marketId: 'market-0',
@ -445,7 +447,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => {
cy.get(`[data-testid="cancelAll"]`) cy.get(`[data-testid="cancelAll"]`)
.should('have.text', 'Cancel all') .should('have.text', 'Cancel all')
.then(($btn) => { .then(($btn) => {
cy.wrap($btn).click(); cy.wrap($btn).click({ force: true });
const order: OrderCancellation = { const order: OrderCancellation = {
marketId: 'market-0', marketId: 'market-0',
}; };
@ -464,7 +466,7 @@ describe('amend and cancel order', { tags: '@smoke' }, () => {
.find('[data-testid="edit"]') .find('[data-testid="edit"]')
.should('have.text', 'Edit') .should('have.text', 'Edit')
.then(($btn) => { .then(($btn) => {
cy.wrap($btn).click(); cy.wrap($btn).click({ force: true });
cy.getByTestId('dialog-title').should('have.text', 'Edit order'); cy.getByTestId('dialog-title').should('have.text', 'Edit order');
cy.get('#limitPrice').focus().clear().type('0.111111'); cy.get('#limitPrice').focus().clear().type('0.111111');
cy.getByTestId('edit-order').find('[type="submit"]').click(); cy.getByTestId('edit-order').find('[type="submit"]').click();

View File

@ -8,7 +8,7 @@ beforeEach(() => {
cy.setVegaWallet(); cy.setVegaWallet();
}); });
describe('positions', { tags: '@smoke' }, () => { describe('positions', { tags: '@smoke', testIsolation: true }, () => {
it('renders positions on trading page', () => { it('renders positions on trading page', () => {
cy.visit('/#/markets/market-0'); cy.visit('/#/markets/market-0');
cy.getByTestId('Positions').click(); cy.getByTestId('Positions').click();
@ -53,13 +53,17 @@ describe('positions', { tags: '@smoke' }, () => {
'currentLeverage', 'currentLeverage',
'averageEntryPrice', 'averageEntryPrice',
]; ];
cy.getByTestId('tab-positions').within(() => { cy.getByTestId('tab-positions')
cy.get('[row-id="market-2"]').within(() => { .first()
emptyCells.forEach((cell) => { .within(() => {
cy.get(`[col-id="${cell}"]`).should('contain.text', '-'); 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', () => { it('error message should be displayed', () => {
const errors = [ const errors = [

View File

@ -2,7 +2,7 @@ import { connectEthereumWallet } from '../support/ethereum-wallet';
const connectEthWalletBtn = 'connect-eth-wallet-btn'; const connectEthWalletBtn = 'connect-eth-wallet-btn';
describe('ethereum wallet', { tags: '@smoke' }, () => { describe('ethereum wallet', { tags: '@smoke', testIsolation: true }, () => {
beforeEach(() => { beforeEach(() => {
cy.mockWeb3Provider(); cy.mockWeb3Provider();
// Using portfolio withdrawals tab is it requires Ethereum wallet connection // Using portfolio withdrawals tab is it requires Ethereum wallet connection

View File

@ -8,103 +8,115 @@ const manageVegaBtn = 'manage-vega-wallet';
const form = 'rest-connector-form'; const form = 'rest-connector-form';
const dialogContent = 'dialog-content'; const dialogContent = 'dialog-content';
describe('connect hosted wallet', { tags: '@smoke' }, () => { describe(
beforeEach(() => { 'connect hosted wallet',
// Using portfolio page as it requires vega wallet connection { tags: '@smoke', testIsolation: true },
cy.visit('/#/portfolio'); () => {
cy.mockTradingPage(); beforeEach(() => {
cy.mockSubscription(); // Using portfolio page as it requires vega wallet connection
cy.get('main[data-testid="/portfolio"]').should('exist'); cy.visit('/#/portfolio');
}); cy.mockTradingPage();
cy.mockSubscription();
it('can connect', () => { cy.get('main[data-testid="/portfolio"]').should('exist');
// 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', { it('can connect', () => {
body: { // 0002-WCON-002
keys: [ // 0002-WCON-003
{ // 0002-WCON-039
algorithm: { // 0002-WCON-017
name: 'algo', // 0002-WCON-018
version: 1, // 0002-WCON-019
},
index: 0, // Mock authentication
meta: [], cy.intercept(
pub: 'HOSTED_PUBKEY', 'POST',
tainted: false, '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') it('doesnt connect with invalid credentials', () => {
.find('[data-testid="connector-hosted"]') // 0002-WCON-020
.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', () => { // Mock incorrect username/password
// 0002-WCON-020 cy.intercept(
'POST',
// Mock incorrect username/password 'https://wallet.testnet.vega.xyz/api/v1/auth/token',
cy.intercept('POST', 'https://wallet.testnet.vega.xyz/api/v1/auth/token', { {
body: { body: {
error: 'No wallet', error: 'No wallet',
}, },
statusCode: 403, // 403 forbidden invalid crednetials 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', () => { it('doesnt connect with empty fields', () => {
cy.getByTestId(connectVegaBtn).click(); cy.getByTestId(connectVegaBtn).click();
cy.getByTestId('connectors-list') cy.getByTestId('connectors-list')
.find('[data-testid="connector-hosted"]') .find('[data-testid="connector-hosted"]')
.click(); .click();
cy.getByTestId('rest-connector-form').find('button[type=submit]').click(); cy.getByTestId('rest-connector-form').find('button[type=submit]').click();
cy.getByTestId(form) cy.getByTestId(form)
.find('#wallet') .find('#wallet')
.next('[data-testid="input-error-text"]') .next('[data-testid="input-error-text"]')
.should('have.text', 'Required'); .should('have.text', 'Required');
cy.getByTestId(form) cy.getByTestId(form)
.find('#passphrase') .find('#passphrase')
.next('[data-testid="input-error-text"]') .next('[data-testid="input-error-text"]')
.should('have.text', 'Required'); .should('have.text', 'Required');
}); });
}); }
);
describe('connect vega wallet', { tags: '@smoke' }, () => { describe('connect vega wallet', { tags: '@smoke', testIsolation: true }, () => {
beforeEach(() => { beforeEach(() => {
// Using portfolio page as it requires vega wallet connection // Using portfolio page as it requires vega wallet connection
cy.visit('/#/portfolio'); cy.visit('/#/portfolio');

View File

@ -88,48 +88,54 @@ describe(
} }
); );
describe('withdraw actions', { tags: '@regression' }, () => { describe(
beforeEach(() => { 'withdraw actions',
cy.mockWeb3Provider(); { tags: '@regression', testIsolation: true },
cy.mockTradingPage(); () => {
cy.mockSubscription(); beforeEach(() => {
cy.setVegaWallet(); cy.mockWeb3Provider();
cy.mockTradingPage();
cy.mockSubscription();
cy.setVegaWallet();
cy.visit('/#/portfolio'); cy.visit('/#/portfolio');
cy.getByTestId(collateralTab).click(); cy.getByTestId(collateralTab).click();
cy.getByTestId(openTransferDialog).click(); cy.getByTestId(openTransferDialog).click();
cy.wait('@Accounts'); cy.wait('@Accounts');
cy.wait('@Assets'); cy.wait('@Assets');
cy.mockVegaWalletTransaction(); cy.mockVegaWalletTransaction();
}); });
it('key to key transfers by select key', function () { it('key to key transfers by select key', function () {
cy.getByTestId(transferForm).should('be.visible'); cy.getByTestId(transferForm).should('be.visible');
cy.getByTestId(transferForm).find(toAddressField).select(1); cy.getByTestId(transferForm).find(toAddressField).select(1);
selectAsset(ASSET_SEPOLIA_TBTC); selectAsset(ASSET_SEPOLIA_TBTC);
cy.getByTestId(transferForm).find(amountField).type('1', { delay: 100 }); cy.getByTestId(transferForm).find(amountField).type('1', { delay: 100 });
cy.getByTestId(transferForm).find(submitTransferBtn).click(); cy.getByTestId(transferForm).find(submitTransferBtn).click();
cy.getByTestId(toastContent).should( cy.getByTestId(toastContent).should(
'contain.text', 'contain.text',
'Awaiting confirmation' 'Awaiting confirmation'
); );
cy.getByTestId(toastCloseBtn).click(); cy.getByTestId(toastCloseBtn).click();
}); });
it('key to key transfers by enter manual key', function () { it('key to key transfers by enter manual key', function () {
cy.getByTestId(transferForm).should('be.visible'); cy.getByTestId(transferForm).should('be.visible');
cy.contains('Enter manually').click(); cy.contains('Enter manually').click();
cy.getByTestId(transferForm) cy.getByTestId(transferForm)
.find(toAddressField) .find(toAddressField)
.type('7f9cf07d3a9905b1a61a1069f7a758855da428bc0f4a97de87f48644bfc25535'); .type(
selectAsset(ASSET_SEPOLIA_TBTC); '7f9cf07d3a9905b1a61a1069f7a758855da428bc0f4a97de87f48644bfc25535'
cy.getByTestId(transferForm).find(amountField).type('1', { delay: 100 }); );
cy.getByTestId(transferForm).find(submitTransferBtn).click(); selectAsset(ASSET_SEPOLIA_TBTC);
cy.getByTestId(toastContent).should( cy.getByTestId(transferForm).find(amountField).type('1', { delay: 100 });
'contain.text', cy.getByTestId(transferForm).find(submitTransferBtn).click();
'Awaiting confirmation' cy.getByTestId(toastContent).should(
); 'contain.text',
cy.getByTestId(toastCloseBtn).click(); 'Awaiting confirmation'
}); );
}); cy.getByTestId(toastCloseBtn).click();
});
}
);

View File

@ -70,54 +70,60 @@ describe('withdraw form validation', { tags: '@smoke' }, () => {
}); });
}); });
describe('withdraw actions', { tags: '@regression' }, () => { describe(
// this is extremely ugly hack, but setting it properly in contract is too much effort for such simple validation '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 = const withdrawalThreshold =
Cypress.env('VEGA_ENV') === 'CUSTOM' ? '0.00' : '100.00'; Cypress.env('VEGA_ENV') === 'CUSTOM' ? '0.00' : '100.00';
before(() => { before(() => {
cy.mockWeb3Provider(); cy.mockWeb3Provider();
cy.mockTradingPage(); cy.mockTradingPage();
cy.mockSubscription(); cy.mockSubscription();
cy.setVegaWallet(); cy.setVegaWallet();
cy.visit('/#/portfolio'); cy.visit('/#/portfolio');
cy.getByTestId('Withdrawals').click(); cy.getByTestId('Withdrawals').click();
cy.getByTestId('withdraw-dialog-button').click();
connectEthereumWallet('MetaMask'); cy.getByTestId('withdraw-dialog-button').click();
cy.wait('@Accounts'); // It also requires connection Ethereum wallet
cy.wait('@Assets'); connectEthereumWallet('MetaMask');
cy.mockVegaWalletTransaction();
});
it('triggers transaction when submitted', () => { cy.wait('@Accounts');
// 1002-WITH-002 cy.wait('@Assets');
// 1002-WITH-003 cy.mockVegaWalletTransaction();
selectAsset(ASSET_SEPOLIA_TBTC); });
cy.getByTestId('BALANCE_AVAILABLE_label').should(
'contain.text', it('triggers transaction when submitted', () => {
'Balance available' // 1002-WITH-002
); // 1002-WITH-003
cy.getByTestId('BALANCE_AVAILABLE_value').should( selectAsset(ASSET_SEPOLIA_TBTC);
'have.text', cy.getByTestId('BALANCE_AVAILABLE_label').should(
'1,000.00001' 'contain.text',
); 'Balance available'
cy.getByTestId('WITHDRAWAL_THRESHOLD_label').should( );
'contain.text', cy.getByTestId('BALANCE_AVAILABLE_value').should(
'Delayed withdrawal threshold' 'have.text',
); '1,000.00001'
cy.getByTestId('WITHDRAWAL_THRESHOLD_value').should( );
'contain.text', cy.getByTestId('WITHDRAWAL_THRESHOLD_label').should(
withdrawalThreshold 'contain.text',
); 'Delayed withdrawal threshold'
cy.getByTestId('DELAY_TIME_label').should('contain.text', 'Delay time'); );
cy.getByTestId('DELAY_TIME_value').should('have.text', 'None'); cy.getByTestId('WITHDRAWAL_THRESHOLD_value').should(
cy.get(amountField).clear().type('10'); 'contain.text',
cy.getByTestId(submitWithdrawBtn).click(); withdrawalThreshold
cy.getByTestId('toast').should('contain.text', 'Awaiting confirmation'); );
}); 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');
});
}
);

View File

@ -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],
};
});

View File

@ -10,14 +10,15 @@ declare global {
export const addConnectPublicKey = () => { export const addConnectPublicKey = () => {
Cypress.Commands.add('connectPublicKey', (publicKey) => { Cypress.Commands.add('connectPublicKey', (publicKey) => {
cy.getByTestId('connect-vega-wallet').then((connectWallet) => { const connectVegaWaletBtn = Cypress.$(
if (connectWallet.length) { `[data-testid="connect-vega-wallet"]`
cy.get('aside [data-testid="connect-vega-wallet"]').click(); );
cy.getByTestId('connector-view').should('be.visible').click(); if (connectVegaWaletBtn.length > 0) {
cy.getByTestId('address').click(); cy.get('aside [data-testid="connect-vega-wallet"]').click();
cy.getByTestId('address').type(publicKey); cy.getByTestId('connector-view').should('be.visible').click();
cy.getByTestId('connect').click(); cy.getByTestId('address').click();
} cy.getByTestId('address').type(publicKey);
}); cy.getByTestId('connect').click();
}
}); });
}; };

View File

@ -33,19 +33,27 @@ export function addVegaWalletConnect() {
Cypress.Commands.add('connectVegaWallet', (isMobile) => { Cypress.Commands.add('connectVegaWallet', (isMobile) => {
mockConnectWallet(); mockConnectWallet();
cy.highlight(`Connecting Vega Wallet`); cy.highlight(`Connecting Vega Wallet`);
cy.get( const connectVegaWalletButton = `[data-testid=connect-vega-wallet${
`[data-testid=connect-vega-wallet${isMobile ? '-mobile' : ''}]:visible` isMobile ? '-mobile' : ''
).click(); }]:visible`;
cy.get('[data-testid=connectors-list]')
.find('[data-testid="connector-jsonRpc"]') cy.get(connectVegaWalletButton).then((btn) => {
.click(); if (btn.length === 0) {
cy.wait('@walletReq'); cy.log('could not find the button, perhaps already connected');
cy.get('[data-testid=dialog-content]').should( return;
'contain.text', }
'Successfully connected' cy.wrap(btn).click();
); cy.get('[data-testid=connectors-list]')
cy.getByTestId('dialog-close').click(); .find('[data-testid="connector-jsonRpc"]')
cy.get('[data-testid=dialog-content]').should('not.exist'); .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');
});
}); });
} }

View File

@ -18,6 +18,7 @@
"noImplicitOverride": true, "noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": false, "noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true, "noImplicitReturns": true,
"noFallthroughCasesInSwitch": true "noFallthroughCasesInSwitch": true,
"sourceMap": false
} }
} }

View File

@ -3,11 +3,13 @@ export const negativeClassNames = 'text-vega-pink dark:text-vega-pink';
const isPositive = ({ value }: { value: string | bigint | number }) => const isPositive = ({ value }: { value: string | bigint | number }) =>
!!value && !!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 }) => const isNegative = ({ value }: { value: string | bigint | number }) =>
!!value && !!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) => { export const signedNumberCssClass = (value: string | bigint | number) => {
if (isPositive({ value })) { if (isPositive({ value })) {

View File

@ -80,6 +80,7 @@ export const useFetch = <T>(
} }
data = (await response.json()) as T; data = (await response.json()) as T;
// @ts-ignore - 'error' in data
if (data && 'error' in data) { if (data && 'error' in data) {
// @ts-ignore - data.error // @ts-ignore - data.error
throw new Error(data.error); throw new Error(data.error);

View File

@ -149,8 +149,8 @@
"autoprefixer": "10.4.8", "autoprefixer": "10.4.8",
"babel-jest": "27.5.1", "babel-jest": "27.5.1",
"babel-loader": "8.1.0", "babel-loader": "8.1.0",
"cypress": "^11.2.0", "cypress": "^12.9.0",
"cypress-real-events": "^1.7.1", "cypress-real-events": "^1.7.6",
"dotenv": "^16.0.1", "dotenv": "^16.0.1",
"eslint": "8.15.0", "eslint": "8.15.0",
"eslint-config-next": "12.2.3", "eslint-config-next": "12.2.3",
@ -190,7 +190,7 @@
"ts-node": "10.9.1", "ts-node": "10.9.1",
"tslib": "^2.0.0", "tslib": "^2.0.0",
"type-fest": "^2.12.2", "type-fest": "^2.12.2",
"typescript": "4.7.4", "typescript": "^5.0.4",
"url-loader": "^3.0.0" "url-loader": "^3.0.0"
}, },
"lint-staged": { "lint-staged": {

View File

@ -11008,15 +11008,15 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9" resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha512-NJGVKPS81XejHcLhaLJS7plab0fK3slPh11mESeeDq2W4ZI5kUKK/LRRdVDvjJseojbPB7ZwjnyOybg3Igea/A== integrity sha512-NJGVKPS81XejHcLhaLJS7plab0fK3slPh11mESeeDq2W4ZI5kUKK/LRRdVDvjJseojbPB7ZwjnyOybg3Igea/A==
cypress-real-events@^1.7.1: cypress-real-events@^1.7.6:
version "1.7.1" version "1.7.6"
resolved "https://registry.yarnpkg.com/cypress-real-events/-/cypress-real-events-1.7.1.tgz#8f430d67c29ea4f05b9c5b0311780120cbc9b935" resolved "https://registry.yarnpkg.com/cypress-real-events/-/cypress-real-events-1.7.6.tgz#6f17e0b2ceea1d6dc60f6737d8f84cc517bbbb4c"
integrity sha512-/Bg15RgJ0SYsuXc6lPqH08x19z6j2vmhWN4wXfJqm3z8BTAFiK2MvipZPzxT8Z0jJP0q7kuniWrLIvz/i/8lCQ== integrity sha512-yP6GnRrbm6HK5q4DH6Nnupz37nOfZu/xn1xFYqsE2o4G73giPWQOdu6375QYpwfU1cvHNCgyD2bQ2hPH9D7NMw==
cypress@^11.2.0: cypress@^12.9.0:
version "11.2.0" version "12.9.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-11.2.0.tgz#63edef8c387b687066c5493f6f0ad7b9ced4b2b7" resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.9.0.tgz#e6ab43cf329fd7c821ef7645517649d72ccf0a12"
integrity sha512-u61UGwtu7lpsNWLUma/FKNOsrjcI6wleNmda/TyKHe0dOBcVjbCPlp1N6uwFZ0doXev7f/91YDpU9bqDCFeBLA== integrity sha512-Ofe09LbHKgSqX89Iy1xen2WvpgbvNxDzsWx3mgU1mfILouELeXYGwIib3ItCwoRrRifoQwcBFmY54Vs0zw7QCg==
dependencies: dependencies:
"@cypress/request" "^2.88.10" "@cypress/request" "^2.88.10"
"@cypress/xvfb" "^1.2.4" "@cypress/xvfb" "^1.2.4"
@ -11035,7 +11035,7 @@ cypress@^11.2.0:
commander "^5.1.0" commander "^5.1.0"
common-tags "^1.8.0" common-tags "^1.8.0"
dayjs "^1.10.4" dayjs "^1.10.4"
debug "^4.3.2" debug "^4.3.4"
enquirer "^2.3.6" enquirer "^2.3.6"
eventemitter2 "6.4.7" eventemitter2 "6.4.7"
execa "4.1.0" execa "4.1.0"
@ -22304,16 +22304,16 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== 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: typescript@^4.4.3:
version "4.8.4" version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== 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: ua-parser-js@^0.7.30:
version "0.7.31" version "0.7.31"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6"