2022-06-10 19:00:02 +00:00
|
|
|
import { connectVegaWallet } from '../support/vega-wallet';
|
|
|
|
|
|
|
|
describe('vega wallet', () => {
|
|
|
|
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-09-02 14:31:30 +00:00
|
|
|
cy.visit('/portfolio');
|
2022-06-30 07:52:25 +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();
|
|
|
|
cy.contains('Connects using REST to a running Vega wallet service');
|
|
|
|
cy.getByTestId('connectors-list').find('button').click();
|
|
|
|
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();
|
|
|
|
cy.getByTestId('connectors-list').find('button').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();
|
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();
|
|
|
|
cy.getByTestId('connectors-list').find('button').click();
|
|
|
|
cy.getByTestId('rest-connector-form').find('button[type=submit]').click();
|
|
|
|
cy.getByTestId(form)
|
|
|
|
.find('#wallet')
|
|
|
|
.next('[data-testid="input-error-text"]')
|
|
|
|
.should('have.text', 'Required');
|
|
|
|
cy.getByTestId(form)
|
|
|
|
.find('#passphrase')
|
|
|
|
.next('[data-testid="input-error-text"]')
|
|
|
|
.should('have.text', 'Required');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('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-08-31 04:35:46 +00:00
|
|
|
cy.getByTestId(`key-${key2}`).click();
|
|
|
|
cy.getByTestId('manage-vega-wallet').contains(truncatedKey2);
|
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');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('ethereum wallet', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.mockWeb3Provider();
|
2022-06-30 07:52:25 +00:00
|
|
|
// Using portfolio withdrawals tab is it requires Ethereum wallet connection
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.visit('/portfolio');
|
2022-06-30 07:52:25 +00:00
|
|
|
cy.get('main[data-testid="portfolio"]').should('exist');
|
|
|
|
cy.getByTestId('Withdrawals').click();
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can connect', () => {
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|