From a0844d41bfbb8513c3cbcccea7e8ee2510742d22 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 17 Oct 2023 10:56:21 +0100 Subject: [PATCH] chore(trading): move transfer test to jest (#5058) --- .../withdraw-key-to-key-validation.cy.ts | 91 ------------------- libs/accounts/src/lib/transfer-form.spec.tsx | 8 ++ 2 files changed, 8 insertions(+), 91 deletions(-) delete mode 100644 apps/trading-e2e/src/integration/withdraw-key-to-key-validation.cy.ts diff --git a/apps/trading-e2e/src/integration/withdraw-key-to-key-validation.cy.ts b/apps/trading-e2e/src/integration/withdraw-key-to-key-validation.cy.ts deleted file mode 100644 index b9bdf9dcb..000000000 --- a/apps/trading-e2e/src/integration/withdraw-key-to-key-validation.cy.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { selectAsset } from '../support/helpers'; - -const amountField = 'input[name="amount"]'; -const transferText = 'transfer-intro-text'; -const errorText = 'input-error-text'; -const formFieldError = 'input-error-text'; -const keyID = `[data-testid="${transferText}"] > .rounded-md`; -const manageVegaWallet = 'manage-vega-wallet'; -const submitTransferBtn = '[type="submit"]'; -const toAddressField = '[name="toAddress"]'; -const transferForm = 'transfer-form'; -const walletTransfer = 'wallet-transfer'; - -const ASSET_EURO = 1; -const ASSET_SEPOLIA_TBTC = 2; - -describe( - 'transfer form validation', - { tags: '@regression', testIsolation: true }, - () => { - beforeEach(() => { - cy.mockWeb3Provider(); - cy.mockTradingPage(); - cy.mockSubscription(); - cy.setVegaWallet(); - - cy.visit('/#/portfolio'); - cy.getByTestId(manageVegaWallet).click(); - cy.getByTestId(walletTransfer).click(); - - cy.wait('@Accounts'); - cy.wait('@Assets'); - - cy.mockVegaWalletTransaction(); - }); - - it('transfer Text', () => { - // 1003-TRAN-003 - cy.getByTestId(transferText) - .should('exist') - .get(keyID) - .invoke('text') - .should('match', /[\w.]{6}…[\w.]{6}/); - }); - - it('invalid vega key validation', () => { - //1003-TRAN-013 - //1003-TRAN-004 - cy.getByTestId(transferForm).should('be.visible'); - cy.contains('Enter manually').click(); - cy.getByTestId(transferForm).find(toAddressField).type('asd'); - cy.getByTestId(transferForm).find(submitTransferBtn).click(); - cy.getByTestId(formFieldError).should('contain.text', 'Invalid Vega key'); - cy.contains('label', 'Vega key').should('be.visible'); - cy.contains('label', 'Asset').should('be.visible'); - cy.contains('label', 'Amount').should('be.visible'); - }); - - it('empty fields', () => { - // 1003-TRAN-012 - cy.getByTestId(transferForm).find(submitTransferBtn).click(); - cy.getByTestId(formFieldError).should('contain.text', 'Required'); - cy.getByTestId(formFieldError).should('have.length', 3); - }); - - it('min amount', () => { - // 1002-WITH-010 - // 1003-TRAN-014 - selectAsset(ASSET_SEPOLIA_TBTC); - cy.get(amountField).clear().type('0'); - cy.getByTestId(transferForm).find(submitTransferBtn).click(); - cy.getByTestId(errorText).should( - 'contain.text', - 'Value is below minimum' - ); - }); - - it('max amount', () => { - // 1003-TRAN-002 - // 1003-TRAN-011 - // 1003-TRAN-002 - selectAsset(ASSET_EURO); // Will be above maximum because the vega wallet doesn't have any collateral - cy.get(amountField).clear().type('1001', { delay: 100 }); - cy.getByTestId(transferForm).find(submitTransferBtn).click(); - cy.getByTestId(errorText).should( - 'contain.text', - 'You cannot transfer more than your available collateral' - ); - }); - } -); diff --git a/libs/accounts/src/lib/transfer-form.spec.tsx b/libs/accounts/src/lib/transfer-form.spec.tsx index b93bb4713..2e9bfafcf 100644 --- a/libs/accounts/src/lib/transfer-form.spec.tsx +++ b/libs/accounts/src/lib/transfer-form.spec.tsx @@ -88,6 +88,9 @@ describe('TransferForm', () => { }); it('validates a manually entered address', async () => { + // 1003-TRAN-012 + // 1003-TRAN-013 + // 1003-TRAN-004 render(); submit(); expect(await screen.findAllByText('Required')).toHaveLength(3); @@ -116,6 +119,11 @@ describe('TransferForm', () => { }); it('validates fields and submits', async () => { + // 1003-TRAN-002 + // 1003-TRAN-003 + // 1002-WITH-010 + // 1003-TRAN-011 + // 1003-TRAN-014 render(); // check current pubkey not shown