Test/faucet fake assets into vegawallet - then check displayed correctly in TFE (#1485)
* test: initial * test: update * test: lint * test: faucet asset checks * test: lint * test: tweaks * test: tweaks * test: lint * test: tweaks * test: lint * test: re-arrange into views * test: lint
This commit is contained in:
parent
6af189150b
commit
4d69dceaa7
@ -23,6 +23,9 @@ const manageLink = '[data-testid="manage-vega-wallet"]';
|
||||
const dialogVegaKey = '[data-testid="vega-public-key-full"]';
|
||||
const dialogDisconnectBtn = '[data-testid="disconnect"]';
|
||||
const copyPublicKeyBtn = '[data-testid="copy-vega-public-key"]';
|
||||
const vegaWalletCurrencyTitle = '[data-testid="currency-title"]';
|
||||
const vegaWalletPublicKey = Cypress.env('vegaWalletPublicKey');
|
||||
const txTimeout = Cypress.env('txTimeout');
|
||||
|
||||
context(
|
||||
'Vega Wallet - verify elements on widget',
|
||||
@ -282,5 +285,136 @@ context(
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when assets exist in vegawallet', function () {
|
||||
before('send-faucet assets to connected vega wallet', function () {
|
||||
cy.vega_wallet_receive_fauceted_asset(
|
||||
'USDC (fake)',
|
||||
'10',
|
||||
vegaWalletPublicKey
|
||||
);
|
||||
cy.vega_wallet_receive_fauceted_asset(
|
||||
'BTC (fake)',
|
||||
'6',
|
||||
vegaWalletPublicKey
|
||||
);
|
||||
cy.vega_wallet_receive_fauceted_asset(
|
||||
'EURO (fake)',
|
||||
'8',
|
||||
vegaWalletPublicKey
|
||||
);
|
||||
cy.vega_wallet_receive_fauceted_asset(
|
||||
'DAI (fake)',
|
||||
'2',
|
||||
vegaWalletPublicKey
|
||||
);
|
||||
// cy.vega_wallet_connect(); - to be changed when dialog state is fixed - https://github.com/vegaprotocol/frontend-monorepo/issues/838
|
||||
// then code below can be removed
|
||||
cy.get(walletContainer).within(() => {
|
||||
cy.get('button')
|
||||
.contains('Connect Vega wallet to use associated $VEGA')
|
||||
.should('be.enabled')
|
||||
.and('be.visible')
|
||||
.click({ force: true });
|
||||
});
|
||||
cy.get(restConnectorForm).within(() => {
|
||||
cy.get('#wallet').click().type(Cypress.env('vegaWalletName'));
|
||||
cy.get('#passphrase')
|
||||
.click()
|
||||
.type(Cypress.env('vegaWalletPassphrase'));
|
||||
cy.get('button').contains('Connect').click();
|
||||
});
|
||||
cy.ethereum_wallet_connect();
|
||||
});
|
||||
|
||||
it('should see fUSDC assets - within vega wallet', function () {
|
||||
let currency = { id: 'fUSDC', name: 'USDC (fake)' };
|
||||
cy.get(walletContainer).within(() => {
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id, txTimeout)
|
||||
.should('be.visible');
|
||||
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id)
|
||||
.parent()
|
||||
.siblings()
|
||||
.within(() => cy.contains_exactly('10.00000').should('be.visible'));
|
||||
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id)
|
||||
.parent()
|
||||
.contains(currency.name);
|
||||
});
|
||||
});
|
||||
|
||||
it('should see fBTC assets - within vega wallet', function () {
|
||||
let currency = { id: 'fBTC', name: 'BTC (fake)' };
|
||||
cy.get(walletContainer).within(() => {
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id, txTimeout)
|
||||
.should('be.visible');
|
||||
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id)
|
||||
.parent()
|
||||
.siblings()
|
||||
.within(() => cy.contains_exactly('6.00000').should('be.visible'));
|
||||
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id)
|
||||
.parent()
|
||||
.contains(currency.name);
|
||||
});
|
||||
});
|
||||
|
||||
it('should see fEURO assets - within vega wallet', function () {
|
||||
let currency = { id: 'fEURO', name: 'EURO (fake)' };
|
||||
cy.get(walletContainer).within(() => {
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id, txTimeout)
|
||||
.should('be.visible');
|
||||
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id)
|
||||
.parent()
|
||||
.siblings()
|
||||
.within(() => cy.contains_exactly('8.00000').should('be.visible'));
|
||||
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id)
|
||||
.parent()
|
||||
.contains(currency.name);
|
||||
});
|
||||
});
|
||||
|
||||
it('should see fDAI assets - within vega wallet', function () {
|
||||
let currency = { id: 'fDAI', name: 'DAI (fake)' };
|
||||
cy.get(walletContainer).within(() => {
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id, txTimeout)
|
||||
.should('be.visible');
|
||||
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id)
|
||||
.parent()
|
||||
.siblings()
|
||||
.within(() => cy.contains_exactly('2.00000').should('be.visible'));
|
||||
|
||||
cy.get(vegaWalletCurrencyTitle)
|
||||
.contains(currency.id)
|
||||
.parent()
|
||||
.contains(currency.name);
|
||||
});
|
||||
});
|
||||
|
||||
after(
|
||||
'teardown environment to prevent test data bleeding into other tests',
|
||||
function () {
|
||||
if (Cypress.env('CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS')) {
|
||||
cy.restartVegacapsuleNetwork();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -17,6 +17,10 @@ const navigation = {
|
||||
pageSpinner: '[data-testid="splash-loader"]',
|
||||
};
|
||||
|
||||
Cypress.Commands.add('contains_exactly', (expected_result) => {
|
||||
return cy.contains(new RegExp('^' + expected_result + '$', 'g'));
|
||||
});
|
||||
|
||||
Cypress.Commands.add('navigate_to', (page) => {
|
||||
return cy.get(navigation.section, { timeout: 10000 }).within(() => {
|
||||
cy.get(navigation[page]).click({ force: true });
|
||||
|
@ -15,12 +15,6 @@ Cypress.Commands.add('vega_wallet_import', () => {
|
||||
cy.exec(
|
||||
`vega wallet service run --network DV --automatic-consent --home ${vegaWalletLocation}`
|
||||
);
|
||||
|
||||
cy.exec(`vega wallet version`)
|
||||
.its('stdout')
|
||||
.then((output) => {
|
||||
cy.log(output);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('vega_wallet_connect', () => {
|
||||
|
@ -7,6 +7,8 @@ import { addMockVegaWalletCommands } from './lib/commands/mock-vega-wallet';
|
||||
import { addMockWeb3ProviderCommand } from './lib/commands/mock-web3-provider';
|
||||
import { addSlackCommand } from './lib/commands/slack';
|
||||
import { addHighlightLog } from './lib/commands/highlight-log';
|
||||
import { addGetAssetInformation } from './lib/commands/get-asset-information';
|
||||
import { addVegaWalletReceiveFaucetedAsset } from './lib/commands/vega-wallet-receive-fauceted-asset';
|
||||
|
||||
addGetTestIdcommand();
|
||||
addSlackCommand();
|
||||
@ -15,6 +17,8 @@ addMockGQLSubscriptionCommand();
|
||||
addMockVegaWalletCommands();
|
||||
addMockWeb3ProviderCommand();
|
||||
addHighlightLog();
|
||||
addVegaWalletReceiveFaucetedAsset();
|
||||
addGetAssetInformation();
|
||||
|
||||
export * from './lib/graphql-test-utils';
|
||||
export type { onMessage } from './lib/commands/mock-gql';
|
||||
|
39
libs/cypress/src/lib/commands/get-asset-information.ts
Normal file
39
libs/cypress/src/lib/commands/get-asset-information.ts
Normal file
@ -0,0 +1,39 @@
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
get_asset_information(): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function addGetAssetInformation() {
|
||||
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
|
||||
Cypress.Commands.add('get_asset_information', () => {
|
||||
const mutation =
|
||||
'{ assets {name id decimals globalRewardPoolAccount {balance}}}';
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `http://localhost:3028/query`,
|
||||
body: {
|
||||
query: mutation,
|
||||
},
|
||||
headers: { 'content-type': 'application/json' },
|
||||
})
|
||||
.its(`body.data.assets`)
|
||||
.then(function (response) {
|
||||
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
|
||||
const object = response.reduce(function (assets, entry) {
|
||||
assets[entry.name] = {
|
||||
rewardPoolBalance: entry.globalRewardPoolAccount.balance,
|
||||
id: entry.id,
|
||||
decimals: entry.decimals,
|
||||
};
|
||||
return assets;
|
||||
}, {});
|
||||
|
||||
return object;
|
||||
});
|
||||
});
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
vega_wallet_receive_fauceted_asset(
|
||||
assetName: string,
|
||||
amount: string,
|
||||
vegaWalletPublicKey: string
|
||||
): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function addVegaWalletReceiveFaucetedAsset() {
|
||||
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
|
||||
Cypress.Commands.add(
|
||||
'vega_wallet_receive_fauceted_asset',
|
||||
function (assetName, amount, vegaWalletPublicKey) {
|
||||
cy.highlight(
|
||||
`Topping up vega wallet with ${assetName}, amount: ${amount}`
|
||||
);
|
||||
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
|
||||
cy.get_asset_information().then((assets) => {
|
||||
const asset = assets[assetName];
|
||||
for (let i = 0; i < asset.decimals; i++) amount += '0';
|
||||
cy.exec(
|
||||
`curl -X POST -d '{"amount": "${amount}", "asset": "${asset.id}", "party": "${vegaWalletPublicKey}"}' -u "hedgehogandvega:hiccup" http://localhost:1790/api/v1/mint`
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user