test(trading): increase coverage for 0004-ewal (#3210)
This commit is contained in:
parent
56732d1503
commit
0f7e76ae01
58
apps/trading-e2e/src/integration/wallet-eth.cy.ts
Normal file
58
apps/trading-e2e/src/integration/wallet-eth.cy.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import { connectEthereumWallet } from '../support/ethereum-wallet';
|
||||||
|
|
||||||
|
const connectEthWalletBtn = 'connect-eth-wallet-btn';
|
||||||
|
|
||||||
|
describe('ethereum wallet', { tags: '@smoke' }, () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.mockWeb3Provider();
|
||||||
|
// Using portfolio withdrawals tab is it requires Ethereum wallet connection
|
||||||
|
cy.mockTradingPage();
|
||||||
|
cy.mockSubscription();
|
||||||
|
cy.setVegaWallet();
|
||||||
|
cy.visit('/#/portfolio');
|
||||||
|
cy.get('main[data-testid="/portfolio"]').should('exist');
|
||||||
|
cy.getByTestId('Withdrawals').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can connect', () => {
|
||||||
|
// 0004-EWAL-001
|
||||||
|
|
||||||
|
cy.wait('@NetworkParams');
|
||||||
|
cy.getByTestId('Deposits').click();
|
||||||
|
cy.getByTestId('deposit-button').click();
|
||||||
|
cy.getByTestId('connect-eth-wallet-btn').click();
|
||||||
|
cy.getByTestId('web3-connector-list').should('exist');
|
||||||
|
cy.getByTestId('web3-connector-MetaMask').click();
|
||||||
|
cy.getByTestId('web3-connector-list').should('not.exist');
|
||||||
|
cy.getByTestId('tab-deposits').should('not.be.empty');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should see an option to cancel the attempted connection', () => {
|
||||||
|
// 0004-EWAL-003
|
||||||
|
|
||||||
|
cy.wait('@NetworkParams');
|
||||||
|
cy.getByTestId('Deposits').click();
|
||||||
|
cy.getByTestId('deposit-button').click();
|
||||||
|
cy.getByTestId('connect-eth-wallet-btn').click();
|
||||||
|
cy.getByTestId('web3-connector-list').should('exist');
|
||||||
|
cy.getByTestId('web3-connector-WalletConnect').click();
|
||||||
|
cy.get('#walletconnect-qrcode-text').should('exist');
|
||||||
|
cy.get('#walletconnect-qrcode-close').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('able to disconnect eth wallet', () => {
|
||||||
|
// 0004-EWAL-004
|
||||||
|
// 0004-EWAL-005
|
||||||
|
// 0004-EWAL-006
|
||||||
|
|
||||||
|
const ethWalletAddress = Cypress.env('ETHEREUM_WALLET_ADDRESS');
|
||||||
|
cy.getByTestId('Deposits').click();
|
||||||
|
cy.getByTestId('deposit-button').click();
|
||||||
|
connectEthereumWallet('MetaMask');
|
||||||
|
cy.getByTestId('ethereum-address').should('have.text', ethWalletAddress);
|
||||||
|
cy.getByTestId('disconnect-ethereum-wallet')
|
||||||
|
.should('have.text', 'Disconnect')
|
||||||
|
.click();
|
||||||
|
cy.getByTestId(connectEthWalletBtn).should('exist');
|
||||||
|
});
|
||||||
|
});
|
@ -1,7 +1,8 @@
|
|||||||
import { mockConnectWallet } from '@vegaprotocol/cypress';
|
import {
|
||||||
import { connectEthereumWallet } from '../support/ethereum-wallet';
|
mockConnectWallet,
|
||||||
|
mockConnectWalletWithUserError,
|
||||||
|
} from '@vegaprotocol/cypress';
|
||||||
|
|
||||||
const connectEthWalletBtn = 'connect-eth-wallet-btn';
|
|
||||||
const connectVegaBtn = 'connect-vega-wallet';
|
const connectVegaBtn = 'connect-vega-wallet';
|
||||||
const manageVegaBtn = 'manage-vega-wallet';
|
const manageVegaBtn = 'manage-vega-wallet';
|
||||||
const form = 'rest-connector-form';
|
const form = 'rest-connector-form';
|
||||||
@ -127,6 +128,21 @@ describe('connect vega wallet', { tags: '@smoke' }, () => {
|
|||||||
cy.getByTestId(manageVegaBtn).should('exist');
|
cy.getByTestId(manageVegaBtn).should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can not connect', () => {
|
||||||
|
// 0002-WCON-002
|
||||||
|
// 0002-WCON-005
|
||||||
|
// 0002-WCON-007
|
||||||
|
|
||||||
|
mockConnectWalletWithUserError();
|
||||||
|
cy.getByTestId(connectVegaBtn).click();
|
||||||
|
cy.getByTestId('connectors-list')
|
||||||
|
.find('[data-testid="connector-jsonRpc"]')
|
||||||
|
.click();
|
||||||
|
cy.getByTestId('dialog-content')
|
||||||
|
.should('contain.text', 'User error')
|
||||||
|
.and('contain.text', 'the user rejected the wallet connection');
|
||||||
|
});
|
||||||
|
|
||||||
it('can change selected public key and disconnect', () => {
|
it('can change selected public key and disconnect', () => {
|
||||||
// 0002-WCON-022
|
// 0002-WCON-022
|
||||||
// 0002-WCON-023
|
// 0002-WCON-023
|
||||||
@ -164,39 +180,3 @@ describe('connect vega wallet', { tags: '@smoke' }, () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ethereum wallet', { tags: '@smoke' }, () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.mockWeb3Provider();
|
|
||||||
// Using portfolio withdrawals tab is it requires Ethereum wallet connection
|
|
||||||
cy.mockTradingPage();
|
|
||||||
cy.mockSubscription();
|
|
||||||
cy.setVegaWallet();
|
|
||||||
cy.visit('/#/portfolio');
|
|
||||||
cy.get('main[data-testid="/portfolio"]').should('exist');
|
|
||||||
cy.getByTestId('Withdrawals').click();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can connect', () => {
|
|
||||||
cy.wait('@NetworkParams');
|
|
||||||
cy.getByTestId('Deposits').click();
|
|
||||||
cy.getByTestId('deposit-button').click();
|
|
||||||
cy.getByTestId('connect-eth-wallet-btn').click();
|
|
||||||
cy.getByTestId('web3-connector-list').should('exist');
|
|
||||||
cy.getByTestId('web3-connector-MetaMask').click();
|
|
||||||
cy.getByTestId('web3-connector-list').should('not.exist');
|
|
||||||
cy.getByTestId('tab-deposits').should('not.be.empty');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('able to disconnect eth wallet', () => {
|
|
||||||
const ethWalletAddress = Cypress.env('ETHEREUM_WALLET_ADDRESS');
|
|
||||||
cy.getByTestId('Deposits').click();
|
|
||||||
cy.getByTestId('deposit-button').click();
|
|
||||||
connectEthereumWallet('MetaMask');
|
|
||||||
cy.getByTestId('ethereum-address').should('have.text', ethWalletAddress);
|
|
||||||
cy.getByTestId('disconnect-ethereum-wallet')
|
|
||||||
.should('have.text', 'Disconnect')
|
|
||||||
.click();
|
|
||||||
cy.getByTestId(connectEthWalletBtn).should('exist');
|
|
||||||
});
|
|
||||||
});
|
|
@ -46,7 +46,10 @@ addVegaWalletSubmitProposal();
|
|||||||
addVegaWalletSubmitLiquidityProvision();
|
addVegaWalletSubmitLiquidityProvision();
|
||||||
addImportNodeWallets();
|
addImportNodeWallets();
|
||||||
|
|
||||||
export { mockConnectWallet } from './lib/commands/vega-wallet-connect';
|
export {
|
||||||
|
mockConnectWallet,
|
||||||
|
mockConnectWalletWithUserError,
|
||||||
|
} from './lib/commands/vega-wallet-connect';
|
||||||
export type { onMessage } from './lib/mock-ws';
|
export type { onMessage } from './lib/mock-ws';
|
||||||
export { aliasGQLQuery } from './lib/mock-gql';
|
export { aliasGQLQuery } from './lib/mock-gql';
|
||||||
export { aliasWalletQuery } from './lib/mock-rest';
|
export { aliasWalletQuery } from './lib/mock-rest';
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { aliasWalletConnectQuery } from '../mock-rest';
|
import {
|
||||||
|
aliasWalletConnectQuery,
|
||||||
|
aliasWalletConnectWithUserError,
|
||||||
|
} from '../mock-rest';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
@ -20,6 +23,12 @@ export const mockConnectWallet = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const mockConnectWalletWithUserError = () => {
|
||||||
|
cy.mockWallet((req) => {
|
||||||
|
aliasWalletConnectWithUserError(req);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export function addVegaWalletConnect() {
|
export function addVegaWalletConnect() {
|
||||||
Cypress.Commands.add('connectVegaWallet', (isMobile) => {
|
Cypress.Commands.add('connectVegaWallet', (isMobile) => {
|
||||||
mockConnectWallet();
|
mockConnectWallet();
|
||||||
|
@ -63,3 +63,23 @@ export const aliasWalletConnectQuery = (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const aliasWalletConnectWithUserError = (
|
||||||
|
req: CyHttpMessages.IncomingHttpRequest
|
||||||
|
) => {
|
||||||
|
if (hasMethod(req, 'client.connect_wallet')) {
|
||||||
|
req.alias = 'client.connect_wallet';
|
||||||
|
req.reply({
|
||||||
|
statusCode: 400,
|
||||||
|
body: {
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
error: {
|
||||||
|
code: 3001,
|
||||||
|
data: 'the user rejected the wallet connection',
|
||||||
|
message: 'User error',
|
||||||
|
},
|
||||||
|
id: '0',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user