vega-frontend-monorepo/apps/token-e2e/src/support/wallet-eth.functions.js
Radosław Szpiech f9a91938fb
test(token): eth wallet widget validations with wallet connected (#731)
* test(token): eth wallet widget validations with wallet connected

* test(token): change currency tests to be more readable

Co-authored-by: Rado <rado@vegaprotocol.io>
2022-07-11 15:32:32 +02:00

60 lines
1.9 KiB
JavaScript

import ethWallet from '../locators/wallet-eth.locators';
cy.ethereum_wallet_connect = () => {
cy.highlight('Connecting Eth Wallet');
cy.get(ethWallet.connectToEthButton).within(() => {
cy.contains('Connect Ethereum wallet to associate $VEGA')
.should('be.visible')
.click();
});
cy.get(ethWallet.connectorCapsule).click();
cy.get(ethWallet.connectorCapsule, { timeout: 60000 }).should('not.exist');
cy.get(ethWallet.walletContainer).within(() => {
// this check is required since it ensures the wallet is fully (not partially) loaded
cy.contains('Locked', { timeout: 15000 }).should('be.visible');
});
};
cy.ethereum_wallet_check_associated_value_is = (expectedVal) => {
cy.highlight(`Checking Eth Wallet - Associated Value is ${expectedVal}`);
cy.get(ethWallet.walletContainer).within(() => {
cy.contains('Associated', { timeout: 20000 })
.parent()
.siblings()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
};
cy.ethereum_wallet_check_associated_vega_key_value_is = (
vegaShortPublicKey,
expectedVal
) => {
cy.highlight(
`Checking Eth Wallet - Vega Key Associated Value is ${expectedVal} for key ${vegaShortPublicKey}`
);
cy.get(ethWallet.walletContainer).within(() => {
cy.contains(vegaShortPublicKey, { timeout: 20000 })
.parent()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
};
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing = (
vegaShortPublicKey
) => {
cy.highlight('Checking Eth Wallet - Vega Key Associated is not showing');
cy.get(ethWallet.walletContainer).within(() => {
cy.contains(vegaShortPublicKey, { timeout: 20000 }).should('not.exist');
});
};
Cypress.Commands.add(
'convertTokenValueToNumber',
{ prevSubject: true },
(subject) => {
return parseFloat(subject.replace(/,/g, ''));
}
);