fix(trading): fix tests due to new wallet connection method (#5903)

This commit is contained in:
daro-maj 2024-03-04 15:58:33 +01:00 committed by GitHub
parent 00dbb7dd60
commit e6b3ff456d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 32 additions and 20 deletions

View File

@ -7,6 +7,7 @@ import {
navigateTo, navigateTo,
navigation, navigation,
turnTelemetryOff, turnTelemetryOff,
setRiskAccepted,
} from '../../support/common.functions'; } from '../../support/common.functions';
import { import {
clickOnValidatorFromList, clickOnValidatorFromList,
@ -57,6 +58,7 @@ context(
// 1002-STKE-002, 1002-STKE-032 // 1002-STKE-002, 1002-STKE-032
before('visit staking tab and connect vega wallet', function () { before('visit staking tab and connect vega wallet', function () {
cy.visit('/'); cy.visit('/');
setRiskAccepted();
ethereumWalletConnect(); ethereumWalletConnect();
cy.connectVegaWallet(); cy.connectVegaWallet();
vegaWalletSetSpecifiedApprovalAmount('1000'); vegaWalletSetSpecifiedApprovalAmount('1000');

View File

@ -5,6 +5,7 @@ import {
navigateTo, navigateTo,
navigation, navigation,
turnTelemetryOff, turnTelemetryOff,
setRiskAccepted,
} from '../../support/common.functions'; } from '../../support/common.functions';
import { import {
stakingPageAssociateTokens, stakingPageAssociateTokens,
@ -57,6 +58,7 @@ context(
function () { function () {
cy.clearLocalStorage(); cy.clearLocalStorage();
turnTelemetryOff(); turnTelemetryOff();
setRiskAccepted();
cy.mockChainId(); cy.mockChainId();
cy.reload(); cy.reload();
waitForSpinner(); waitForSpinner();

View File

@ -82,20 +82,20 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
it('should have information on active nodes', function () { it('should have information on active nodes', function () {
cy.getByTestId('node-information') cy.getByTestId('node-information')
.first() .first()
.should('contain.text', '1') .should('contain.text', '2')
.and('contain.text', 'active nodes'); .and('contain.text', 'active nodes');
}); });
it('should have information on consensus nodes', function () { it('should have information on consensus nodes', function () {
cy.getByTestId('node-information') cy.getByTestId('node-information')
.last() .last()
.should('contain.text', '1') .should('contain.text', '2')
.and('contain.text', 'consensus nodes'); .and('contain.text', 'consensus nodes');
}); });
it('should contain link to specific validators', function () { it('should contain link to specific validators', function () {
cy.getByTestId('validators') cy.getByTestId('validators')
.should('have.length', '1') .should('have.length', '2')
.each(($validator) => { .each(($validator) => {
cy.wrap($validator).find('a').should('have.attr', 'href'); cy.wrap($validator).find('a').should('have.attr', 'href');
}); });

View File

@ -3,6 +3,7 @@
import { aliasGQLQuery } from '@vegaprotocol/cypress'; import { aliasGQLQuery } from '@vegaprotocol/cypress';
import { import {
navigation, navigation,
setRiskAccepted,
verifyPageHeader, verifyPageHeader,
verifyTabHighlighted, verifyTabHighlighted,
} from '../../support/common.functions'; } from '../../support/common.functions';
@ -187,6 +188,7 @@ context('Validators Page - verify elements on page', function () {
before('connect wallets and click on validator', function () { before('connect wallets and click on validator', function () {
cy.mockChainId(); cy.mockChainId();
cy.visit('/validators'); cy.visit('/validators');
setRiskAccepted();
cy.connectVegaWallet(); cy.connectVegaWallet();
clickOnValidatorFromList(0); clickOnValidatorFromList(0);
}); });

View File

@ -1,5 +1,8 @@
import { truncateByChars } from '@vegaprotocol/utils'; import { truncateByChars } from '@vegaprotocol/utils';
import { waitForSpinner } from '../../support/common.functions'; import {
setRiskAccepted,
waitForSpinner,
} from '../../support/common.functions';
import { import {
vegaWalletFaucetAssetsWithoutCheck, vegaWalletFaucetAssetsWithoutCheck,
vegaWalletTeardown, vegaWalletTeardown,
@ -11,7 +14,6 @@ const connectButton = 'connect-vega-wallet';
const getVegaLink = 'link'; const getVegaLink = 'link';
const dialog = '[role="dialog"]:visible'; const dialog = '[role="dialog"]:visible';
const dialogHeader = 'dialog-title'; const dialogHeader = 'dialog-title';
const walletDialogHeader = 'wallet-dialog-title';
const connectorsList = 'connectors-list'; const connectorsList = 'connectors-list';
const dialogCloseBtn = 'dialog-close'; const dialogCloseBtn = 'dialog-close';
const accountNo = 'vega-account-truncated'; const accountNo = 'vega-account-truncated';
@ -34,6 +36,7 @@ context(
() => { () => {
before('visit token home page', () => { before('visit token home page', () => {
cy.visit('/'); cy.visit('/');
setRiskAccepted();
cy.get(walletContainer, { timeout: 60000 }).should('be.visible'); cy.get(walletContainer, { timeout: 60000 }).should('be.visible');
}); });
@ -63,17 +66,12 @@ context(
it('should have Connect Vega header visible', () => { it('should have Connect Vega header visible', () => {
cy.get(dialog).within(() => { cy.get(dialog).within(() => {
cy.getByTestId(walletDialogHeader) cy.getByTestId(connectorsList)
.should('be.visible') .should('be.visible')
.and('have.text', 'Get a Vega wallet'); .and(
}); 'have.text',
}); 'Get the Vega WalletGet MetaMask>_Command Line WalletView as public key'
);
it('should have jsonRpc and hosted connection options visible on list', function () {
cy.getByTestId(connectorsList).within(() => {
cy.getByTestId('connector-jsonRpc')
.should('be.visible')
.and('have.text', 'Use the Desktop App/CLI');
}); });
}); });
@ -88,7 +86,6 @@ context(
before('connect vega wallet', function () { before('connect vega wallet', function () {
cy.mockChainId(); cy.mockChainId();
cy.visit('/'); cy.visit('/');
cy.wait('@ChainId');
cy.connectVegaWallet(); cy.connectVegaWallet();
vegaWalletTeardown(); vegaWalletTeardown();
}); });

View File

@ -102,6 +102,12 @@ export function turnTelemetryOff() {
); );
} }
export function setRiskAccepted() {
cy.window().then((win) =>
win.localStorage.setItem('vega_wallet_risk_accepted', 'true')
);
}
export function dissociateFromSecondWalletKey() { export function dissociateFromSecondWalletKey() {
const secondWalletKey = Cypress.env('vegaWalletPublicKey2Short'); const secondWalletKey = Cypress.env('vegaWalletPublicKey2Short');
cy.getByTestId('vega-in-wallet') cy.getByTestId('vega-in-wallet')

View File

@ -12,7 +12,7 @@ declare global {
} }
} }
const chainId = 'test-id'; const chainId = 'vega-stagnet1-202307191148';
export function addMockChainId() { export function addMockChainId() {
Cypress.Commands.add('mockChainId', () => { Cypress.Commands.add('mockChainId', () => {

View File

@ -37,10 +37,12 @@ export function addVegaWalletConnect() {
Cypress.Commands.add('connectVegaWallet', (isMobile) => { Cypress.Commands.add('connectVegaWallet', (isMobile) => {
mockConnectWallet(); mockConnectWallet();
cy.highlight(`Connecting Vega Wallet`); cy.highlight(`Connecting Vega Wallet`);
cy.get('[data-testid="splash-loader"]', { timeout: 20000 }).should(
'not.exist'
);
const connectVegaWalletButton = `[data-testid=connect-vega-wallet${ const connectVegaWalletButton = `[data-testid=connect-vega-wallet${
isMobile ? '-mobile' : '' isMobile ? '-mobile' : ''
}]:visible`; }]:visible`;
cy.get(connectVegaWalletButton).then((btn) => { cy.get(connectVegaWalletButton).then((btn) => {
if (btn.length === 0) { if (btn.length === 0) {
cy.log('could not find the button, perhaps already connected'); cy.log('could not find the button, perhaps already connected');

View File

@ -13,7 +13,8 @@ declare global {
const hasMethod = (req: CyHttpMessages.IncomingHttpRequest, method: string) => { const hasMethod = (req: CyHttpMessages.IncomingHttpRequest, method: string) => {
const { body } = req; const { body } = req;
return 'method' in body && body.method === method; const b = JSON.parse(body);
return 'method' in b && b.method === method;
}; };
export function addMockWalletCommand() { export function addMockWalletCommand() {
@ -72,7 +73,7 @@ export const aliasWalletConnectQuery = (
body: { body: {
jsonrpc: '2.0', jsonrpc: '2.0',
result: { result: {
chainID: 'test-id', chainID: 'vega-fairground-202305051805',
}, },
id: '1', id: '1',
}, },