vega-frontend-monorepo/libs/cypress/src/lib/commands/get-asset-information.ts
AndyWhiteVega 4d69dceaa7
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
2022-09-27 11:22:44 +01:00

40 lines
1.2 KiB
TypeScript

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;
});
});
}