2022-09-23 13:14:52 +00:00
|
|
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
2022-10-03 18:12:34 +00:00
|
|
|
import { connectVegaWallet } from '../support/vega-wallet';
|
2022-09-23 13:14:52 +00:00
|
|
|
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
|
2022-06-10 19:00:02 +00:00
|
|
|
|
2022-09-22 17:40:11 +00:00
|
|
|
describe('vega wallet', { tags: '@smoke' }, () => {
|
2022-06-10 19:00:02 +00:00
|
|
|
const connectVegaBtn = 'connect-vega-wallet';
|
|
|
|
const manageVegaBtn = 'manage-vega-wallet';
|
|
|
|
const form = 'rest-connector-form';
|
|
|
|
const walletName = Cypress.env('TRADING_TEST_VEGA_WALLET_NAME');
|
|
|
|
const walletPassphrase = Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE');
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
// Using portfolio page as it requires vega wallet connection
|
2022-11-08 07:23:38 +00:00
|
|
|
cy.visit('/#/portfolio');
|
2022-10-19 11:14:52 +00:00
|
|
|
cy.mockTradingPage();
|
2022-09-22 09:15:20 +00:00
|
|
|
cy.mockGQLSubscription();
|
2022-11-08 07:23:38 +00:00
|
|
|
cy.get('main[data-testid="/portfolio"]').should('exist');
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can connect', () => {
|
|
|
|
cy.getByTestId(connectVegaBtn).click();
|
2022-10-03 18:12:34 +00:00
|
|
|
cy.contains('Desktop wallet app');
|
|
|
|
cy.contains('Command line wallet app');
|
|
|
|
cy.contains('Hosted Fairground wallet');
|
|
|
|
|
|
|
|
cy.getByTestId('connectors-list')
|
|
|
|
.find('[data-testid="connector-gui"]')
|
|
|
|
.click();
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.getByTestId(form).find('#wallet').click().type(walletName);
|
|
|
|
cy.getByTestId(form).find('#passphrase').click().type(walletPassphrase);
|
|
|
|
cy.getByTestId('rest-connector-form').find('button[type=submit]').click();
|
|
|
|
cy.getByTestId(manageVegaBtn).should('exist');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('doesnt connect with invalid credentials', () => {
|
|
|
|
cy.getByTestId(connectVegaBtn).click();
|
2022-10-03 18:12:34 +00:00
|
|
|
cy.getByTestId('connectors-list')
|
|
|
|
.find('[data-testid="connector-gui"]')
|
|
|
|
.click();
|
2022-06-10 19:00:02 +00:00
|
|
|
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();
|
2022-08-02 06:37:46 +00:00
|
|
|
cy.getByTestId('form-error').should('have.text', 'Invalid credentials');
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('doesnt connect with invalid fields', () => {
|
|
|
|
cy.getByTestId(connectVegaBtn).click();
|
2022-10-03 18:12:34 +00:00
|
|
|
cy.getByTestId('connectors-list')
|
|
|
|
.find('[data-testid="connector-gui"]')
|
|
|
|
.click();
|
|
|
|
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.getByTestId('rest-connector-form').find('button[type=submit]').click();
|
|
|
|
cy.getByTestId(form)
|
|
|
|
.find('#wallet')
|
|
|
|
.next('[data-testid="input-error-text"]')
|
|
|
|
.should('have.text', 'Required');
|
|
|
|
cy.getByTestId(form)
|
|
|
|
.find('#passphrase')
|
|
|
|
.next('[data-testid="input-error-text"]')
|
|
|
|
.should('have.text', 'Required');
|
|
|
|
});
|
|
|
|
|
2022-09-28 16:56:45 +00:00
|
|
|
// skipped as it was blocking CI jobs
|
|
|
|
it.skip('can change selected public key and disconnect', () => {
|
2022-08-31 04:35:46 +00:00
|
|
|
const key2 = Cypress.env('VEGA_PUBLIC_KEY2');
|
|
|
|
const truncatedKey2 = Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY2');
|
2022-06-10 19:00:02 +00:00
|
|
|
connectVegaWallet();
|
|
|
|
cy.getByTestId('manage-vega-wallet').click();
|
|
|
|
cy.getByTestId('keypair-list').should('exist');
|
2022-09-26 11:07:11 +00:00
|
|
|
cy.getByTestId(`key-${key2}`).should('contain.text', truncatedKey2);
|
2022-08-31 04:35:46 +00:00
|
|
|
cy.getByTestId(`key-${key2}`).click();
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.getByTestId('disconnect').click();
|
|
|
|
cy.getByTestId('connect-vega-wallet').should('exist');
|
|
|
|
cy.getByTestId('manage-vega-wallet').should('not.exist');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-09-22 17:40:11 +00:00
|
|
|
describe('ethereum wallet', { tags: '@smoke' }, () => {
|
2022-06-10 19:00:02 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.mockWeb3Provider();
|
2022-06-30 07:52:25 +00:00
|
|
|
// Using portfolio withdrawals tab is it requires Ethereum wallet connection
|
2022-11-08 07:23:38 +00:00
|
|
|
cy.visit('/#/portfolio');
|
2022-09-23 13:14:52 +00:00
|
|
|
cy.mockGQL((req) => {
|
2022-11-07 14:57:35 +00:00
|
|
|
aliasQuery(req, 'NetworkParams', generateNetworkParameters());
|
2022-09-23 13:14:52 +00:00
|
|
|
});
|
|
|
|
cy.mockGQLSubscription();
|
2022-11-08 07:23:38 +00:00
|
|
|
cy.get('main[data-testid="/portfolio"]').should('exist');
|
2022-06-30 07:52:25 +00:00
|
|
|
cy.getByTestId('Withdrawals').click();
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can connect', () => {
|
2022-11-07 14:57:35 +00:00
|
|
|
cy.wait('@NetworkParams');
|
2022-06-10 19:00:02 +00:00
|
|
|
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');
|
2022-06-30 07:52:25 +00:00
|
|
|
cy.getByTestId('tab-withdrawals').should('not.be.empty');
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|
|
|
|
});
|