* feat: make a single button to connect to either wallet gui or cli * chore: update token to use jsonrpc connector * chore: update stray connector-cli entry * chore: update mock queries to return matching chain id, change tests to connecting using jsonRpc * chore: add type map for TIF short code * chore: update data testid as cli and gui are combined into jsonRpc * chore: remove unused env vars and update readme
This commit is contained in:
parent
88263df9c2
commit
02f56dd0ec
10
README.md
10
README.md
@ -88,12 +88,12 @@ Run `nx test my-app` to execute the unit tests with [Jest](https://jestjs.io), o
|
||||
|
||||
### Using wallet
|
||||
|
||||
To run tests locally using your own wallets you can add the following environment variables to `cypress.json`
|
||||
To run tests locally using your own wallets make sure you have generated at least two public keys and update the following environment variables in `cypress.config.js` to match your wallet. You should also use [vegawallet-dummy](https://github.com/vegaprotocol/vegawallet-dummy) to avoid being prompted in CLI during test execution.
|
||||
|
||||
1. Change `TRADING_TEST_VEGA_WALLET_NAME` to your Vega wallet name
|
||||
2. Add `TRADING_TEST_VEGA_WALLET_PASSPHRASE` as your wallet passphrase
|
||||
3. Add `ETH_WALLET_MNEMONIC` as your Ethereum wallet mnemonic
|
||||
4. Use [vegawallet-dummy](https://github.com/vegaprotocol/vegawallet-dummy) to avoid being prompted in CLI during test execution.
|
||||
1. Set `VEGA_PUBLIC_KEY` and `TRUNCATED_VEGA_PUBLIC_KEY` to your first public key.
|
||||
2. Set `VEGA_PUBLIC_KEY2` and `TRUNCATED_VEGA_PUBLIC_KEY2` to your second public key.
|
||||
3. Set `TRADING_TEST_VEGA_WALLET_PASSPHRASE` as your wallet passphrase
|
||||
4. Add `ETH_WALLET_MNEMONIC` as your Ethereum wallet mnemonic
|
||||
|
||||
### Formatting
|
||||
|
||||
|
@ -23,7 +23,6 @@ module.exports = defineConfig({
|
||||
viewportHeight: 900,
|
||||
},
|
||||
env: {
|
||||
TRADING_TEST_VEGA_WALLET_NAME: 'UI_Trading_Test',
|
||||
ETHEREUM_PROVIDER_URL:
|
||||
'https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8',
|
||||
VEGA_PUBLIC_KEY:
|
||||
|
@ -6,8 +6,6 @@ const vegaWalletStakedBalances =
|
||||
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
|
||||
const vegaWalletNameElement = '[data-testid="wallet-name"]';
|
||||
const vegaWallet = '[data-testid="vega-wallet"]';
|
||||
const vegaWalletName = Cypress.env('vegaWalletName');
|
||||
const vegaWalletPassphrase = Cypress.env('vegaWalletPassphrase');
|
||||
const connectToVegaWalletButton = '[data-testid="connect-to-vega-wallet-btn"]';
|
||||
const newProposalSubmitButton = '[data-testid="proposal-submit"]';
|
||||
const dialogCloseButton = '[data-testid="dialog-close"]';
|
||||
@ -33,7 +31,6 @@ const voteTwoMinExtraNote = '[data-testid="voting-2-mins-extra"]';
|
||||
const voteStatus = '[data-testid="vote-status"]';
|
||||
const rejectProposalsLink = '[href="/governance/rejected"]';
|
||||
const feedbackError = '[data-testid="Error"]';
|
||||
const restConnectorForm = '[data-testid="rest-connector-form"]';
|
||||
const noOpenProposals = '[data-testid="no-open-proposals"]';
|
||||
const noClosedProposals = '[data-testid="no-closed-proposals"]';
|
||||
const txTimeout = Cypress.env('txTimeout');
|
||||
@ -794,12 +791,7 @@ context(
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Connect Vega wallet')
|
||||
.click();
|
||||
cy.getByTestId('connector-gui').click();
|
||||
cy.get(restConnectorForm).within(() => {
|
||||
cy.get('#wallet').click().type(vegaWalletName);
|
||||
cy.get('#passphrase').click().type(vegaWalletPassphrase);
|
||||
cy.get('button').contains('Connect').click();
|
||||
});
|
||||
cy.getByTestId('connector-jsonRpc').click();
|
||||
cy.get(vegaWalletNameElement).should('be.visible');
|
||||
cy.get(connectToVegaWalletButton).should('not.exist');
|
||||
// 3001-VOTE-100
|
||||
|
@ -89,14 +89,11 @@ context(
|
||||
});
|
||||
});
|
||||
|
||||
it('should have gui, cli and hosted connection options visible on list', function () {
|
||||
it('should have jsonRpc and hosted connection options visible on list', function () {
|
||||
cy.get(connectorsList).within(() => {
|
||||
cy.getByTestId('connector-gui')
|
||||
cy.getByTestId('connector-jsonRpc')
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Desktop wallet app');
|
||||
cy.getByTestId('connector-cli')
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Command line wallet app');
|
||||
.and('have.text', 'Connect Vega wallet');
|
||||
cy.getByTestId('connector-hosted')
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Hosted Fairground wallet');
|
||||
@ -113,9 +110,9 @@ context(
|
||||
describe('when rest connector form opened', function () {
|
||||
// Note using desktop wallet app link temporarily whilst its still on v1,
|
||||
// tests will need to be updated to handle v2
|
||||
before('click desktop wallet app link', function () {
|
||||
before('click hosted wallet app button', function () {
|
||||
cy.get(connectorsList).within(() => {
|
||||
cy.getByTestId('connector-gui').click();
|
||||
cy.getByTestId('connector-hosted').click();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -10,9 +10,7 @@ Cypress.Commands.add('vega_wallet_connect', () => {
|
||||
.and('be.visible')
|
||||
.click({ force: true });
|
||||
});
|
||||
// Connect with gui as its the v1 service and tests should still pass. This will need
|
||||
// to be update to use v2
|
||||
cy.getByTestId('connector-cli').click();
|
||||
cy.getByTestId('connector-jsonRpc').click();
|
||||
cy.get(vegaWalletNameElement).should('be.visible');
|
||||
});
|
||||
|
||||
|
@ -37,7 +37,6 @@ module.exports = defineConfig({
|
||||
requestTimeout: 20000,
|
||||
},
|
||||
env: {
|
||||
TRADING_TEST_VEGA_WALLET_NAME: 'UI_Trading_Test',
|
||||
ETHEREUM_PROVIDER_URL:
|
||||
'https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8',
|
||||
VEGA_PUBLIC_KEY:
|
||||
|
@ -6,8 +6,6 @@ const connectVegaBtn = 'connect-vega-wallet';
|
||||
const manageVegaBtn = 'manage-vega-wallet';
|
||||
const form = 'rest-connector-form';
|
||||
const dialogContent = 'dialog-content';
|
||||
const walletName = Cypress.env('TRADING_TEST_VEGA_WALLET_NAME');
|
||||
const walletPassphrase = Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE');
|
||||
|
||||
describe('vega wallet v1', { tags: '@smoke' }, () => {
|
||||
beforeEach(() => {
|
||||
@ -20,23 +18,19 @@ describe('vega wallet v1', { tags: '@smoke' }, () => {
|
||||
|
||||
it('can connect', () => {
|
||||
cy.getByTestId(connectVegaBtn).click();
|
||||
cy.contains('Desktop wallet app');
|
||||
cy.contains('Command line wallet app');
|
||||
cy.contains('Connect Vega wallet');
|
||||
cy.contains('Hosted Fairground wallet');
|
||||
|
||||
cy.getByTestId('connectors-list')
|
||||
.find('[data-testid="connector-gui"]')
|
||||
.find('[data-testid="connector-jsonRpc"]')
|
||||
.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('[data-testid="connector-gui"]')
|
||||
.find('[data-testid="connector-hosted"]')
|
||||
.click();
|
||||
cy.getByTestId(form).find('#wallet').click().type('invalid name');
|
||||
cy.getByTestId(form).find('#passphrase').click().type('invalid password');
|
||||
@ -47,7 +41,7 @@ describe('vega wallet v1', { tags: '@smoke' }, () => {
|
||||
it('doesnt connect with invalid fields', () => {
|
||||
cy.getByTestId(connectVegaBtn).click();
|
||||
cy.getByTestId('connectors-list')
|
||||
.find('[data-testid="connector-gui"]')
|
||||
.find('[data-testid="connector-hosted"]')
|
||||
.click();
|
||||
|
||||
cy.getByTestId('rest-connector-form').find('button[type=submit]').click();
|
||||
@ -74,7 +68,7 @@ describe('vega wallet v2', { tags: '@smoke' }, () => {
|
||||
it('can connect', () => {
|
||||
cy.getByTestId(connectVegaBtn).click();
|
||||
cy.getByTestId('connectors-list')
|
||||
.find('[data-testid="connector-cli"]')
|
||||
.find('[data-testid="connector-jsonRpc"]')
|
||||
.click();
|
||||
cy.getByTestId(dialogContent).should('not.exist');
|
||||
cy.getByTestId(manageVegaBtn).should('exist');
|
||||
|
@ -1,4 +1,8 @@
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
import {
|
||||
OrderTimeInForceCode,
|
||||
OrderTimeInForceMapping,
|
||||
Schema,
|
||||
} from '@vegaprotocol/types';
|
||||
import { generateEstimateOrder } from '../support/mocks/generate-fees';
|
||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||
import { testOrder } from '../support/deal-ticket-transaction';
|
||||
@ -14,38 +18,13 @@ const toggleLimit = 'order-type-TYPE_LIMIT';
|
||||
const toggleMarket = 'order-type-TYPE_MARKET';
|
||||
const errorMessage = 'dealticket-error-message';
|
||||
|
||||
const TIFlist = [
|
||||
{
|
||||
code: 'GTT',
|
||||
value: 'TIME_IN_FORCE_GTT',
|
||||
text: `Good 'til Time (GTT)`,
|
||||
},
|
||||
{
|
||||
code: 'GTC',
|
||||
value: 'TIME_IN_FORCE_GTC',
|
||||
text: `Good 'til Cancelled (GTC)`,
|
||||
},
|
||||
{
|
||||
code: 'IOC',
|
||||
value: 'TIME_IN_FORCE_IOC',
|
||||
text: `Immediate or Cancel (IOC)`,
|
||||
},
|
||||
{
|
||||
code: 'FOK',
|
||||
value: 'TIME_IN_FORCE_FOK',
|
||||
text: `Fill or Kill (FOK)`,
|
||||
},
|
||||
{
|
||||
code: 'GFN',
|
||||
value: 'TIME_IN_FORCE_GFN',
|
||||
text: `Good for Normal (GFN)`,
|
||||
},
|
||||
{
|
||||
code: 'GFA',
|
||||
value: 'TIME_IN_FORCE_GFA',
|
||||
text: `Good for Auction (GFA)`,
|
||||
},
|
||||
];
|
||||
const TIFlist = Object.values(Schema.OrderTimeInForce).map((value) => {
|
||||
return {
|
||||
code: OrderTimeInForceCode[value],
|
||||
value,
|
||||
text: OrderTimeInForceMapping[value],
|
||||
};
|
||||
});
|
||||
|
||||
const displayTomorrow = () => {
|
||||
const tomorrow = new Date();
|
||||
@ -419,14 +398,8 @@ describe('deal ticket validation', { tags: '@smoke' }, () => {
|
||||
cy.getByTestId('order-connect-wallet').click();
|
||||
cy.getByTestId('dialog-content').should('be.visible');
|
||||
cy.getByTestId('connectors-list')
|
||||
.find('[data-testid="connector-gui"]')
|
||||
.find('[data-testid="connector-jsonRpc"]')
|
||||
.click();
|
||||
const form = 'rest-connector-form';
|
||||
const walletName = Cypress.env('TRADING_TEST_VEGA_WALLET_NAME');
|
||||
const walletPassphrase = Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE');
|
||||
cy.getByTestId(form).find('#wallet').click().type(walletName);
|
||||
cy.getByTestId(form).find('#passphrase').click().type(walletPassphrase);
|
||||
cy.getByTestId(form).find('button[type=submit]').click();
|
||||
cy.getByTestId(placeOrderBtn).should('be.visible');
|
||||
cy.getByTestId(toggleLimit).children('input').should('be.checked');
|
||||
cy.getByTestId(orderPriceField).should('have.value', '101');
|
||||
|
@ -8,7 +8,8 @@ export const generateChainId = (
|
||||
const defaultResult = {
|
||||
statistics: {
|
||||
__typename: 'Statistics',
|
||||
chainId: 'test-chain-id',
|
||||
// this needs to match the network set up for vegawallet-dummy in .github/actions/setup-vegawallet/action.yml
|
||||
chainId: 'stagnet3',
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,8 @@ export const generateStatistics = (
|
||||
const defaultResult = {
|
||||
statistics: {
|
||||
__typename: 'Statistics',
|
||||
chainId: 'test-chain-id',
|
||||
// this needs to match the network set up for vegawallet-dummy in .github/actions/setup-vegawallet/action.yml
|
||||
chainId: 'stagnet3',
|
||||
blockHeight: '11',
|
||||
},
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ export function addVegaWalletConnect() {
|
||||
cy.highlight(`Connecting Vega Wallet`);
|
||||
cy.get('[data-testid=connect-vega-wallet]').click();
|
||||
cy.get('[data-testid=connectors-list]')
|
||||
.find('[data-testid="connector-cli"]')
|
||||
.find('[data-testid="connector-jsonRpc"]')
|
||||
.click();
|
||||
cy.get('[data-testid=dialog-content]').should(
|
||||
'contain.text',
|
||||
|
@ -223,9 +223,10 @@ export const OrderStatusMapping: {
|
||||
/**
|
||||
* Valid order types, these determine what happens when an order is added to the book
|
||||
*/
|
||||
export const OrderTimeInForceMapping: {
|
||||
type OrderTimeInForceMap = {
|
||||
[T in OrderTimeInForce]: string;
|
||||
} = {
|
||||
};
|
||||
export const OrderTimeInForceMapping: OrderTimeInForceMap = {
|
||||
TIME_IN_FORCE_FOK: 'Fill or Kill (FOK)',
|
||||
TIME_IN_FORCE_GFA: 'Good for Auction (GFA)',
|
||||
TIME_IN_FORCE_GFN: 'Good for Normal (GFN)',
|
||||
@ -234,6 +235,15 @@ export const OrderTimeInForceMapping: {
|
||||
TIME_IN_FORCE_IOC: 'Immediate or Cancel (IOC)',
|
||||
};
|
||||
|
||||
export const OrderTimeInForceCode: OrderTimeInForceMap = {
|
||||
TIME_IN_FORCE_FOK: 'FOK',
|
||||
TIME_IN_FORCE_GFA: 'GFA',
|
||||
TIME_IN_FORCE_GFN: 'GFN',
|
||||
TIME_IN_FORCE_GTC: 'GTC',
|
||||
TIME_IN_FORCE_GTT: 'GTT',
|
||||
TIME_IN_FORCE_IOC: 'IOC',
|
||||
};
|
||||
|
||||
export const OrderTypeMapping: {
|
||||
[T in OrderType]: string;
|
||||
} = {
|
||||
|
@ -89,12 +89,9 @@ describe('VegaConnectDialog', () => {
|
||||
rerender(generateJSX());
|
||||
const list = await screen.findByTestId('connectors-list');
|
||||
expect(list).toBeInTheDocument();
|
||||
expect(list.children).toHaveLength(3);
|
||||
expect(screen.getByTestId('connector-gui')).toHaveTextContent(
|
||||
'Desktop wallet app'
|
||||
);
|
||||
expect(screen.getByTestId('connector-cli')).toHaveTextContent(
|
||||
'Command line wallet app'
|
||||
expect(list.children).toHaveLength(2);
|
||||
expect(screen.getByTestId('connector-jsonRpc')).toHaveTextContent(
|
||||
'Connect Vega wallet'
|
||||
);
|
||||
expect(screen.getByTestId('connector-hosted')).toHaveTextContent(
|
||||
'Hosted Fairground wallet'
|
||||
@ -379,7 +376,7 @@ describe('VegaConnectDialog', () => {
|
||||
|
||||
async function selectJsonRpc() {
|
||||
expect(await screen.findByRole('dialog')).toBeInTheDocument();
|
||||
fireEvent.click(await screen.findByTestId('connector-cli'));
|
||||
fireEvent.click(await screen.findByTestId('connector-jsonRpc'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ import { useJsonRpcConnect } from '../use-json-rpc-connect';
|
||||
|
||||
export const CLOSE_DELAY = 1700;
|
||||
type Connectors = { [key: string]: VegaConnector };
|
||||
type WalletType = 'gui' | 'cli' | 'hosted';
|
||||
type WalletType = 'jsonRpc' | 'hosted';
|
||||
|
||||
export interface VegaConnectDialogProps {
|
||||
connectors: Connectors;
|
||||
@ -146,16 +146,23 @@ const ConnectDialogContainer = ({
|
||||
|
||||
const { connect, ...jsonRpcState } = useJsonRpcConnect(delayedOnConnect);
|
||||
|
||||
const handleSelect = (type: WalletType) => {
|
||||
// Only cli is currently uses JsonRpc, this will need to be updated
|
||||
// when gui does too
|
||||
const connector =
|
||||
type === 'cli' ? connectors['jsonRpc'] : connectors['rest'];
|
||||
const handleSelect = (type: WalletType, isHosted = false) => {
|
||||
let connector;
|
||||
|
||||
if (isHosted) {
|
||||
// If the user has selected hosted wallet ensure that we are connecting to https://vega-hosted-wallet.on.fleek.co/
|
||||
// otherwise use the default walletUrl or what has been put in the input
|
||||
connector.url =
|
||||
type === 'hosted' && HOSTED_WALLET_URL ? HOSTED_WALLET_URL : walletUrl;
|
||||
connector = connectors['rest'];
|
||||
connector.url = HOSTED_WALLET_URL || walletUrl;
|
||||
} else {
|
||||
connector = connectors[type];
|
||||
connector.url = walletUrl;
|
||||
}
|
||||
|
||||
if (!connector) {
|
||||
throw new Error(`Connector type: ${type} not configured`);
|
||||
}
|
||||
|
||||
setSelectedConnector(connector);
|
||||
setWalletType(type);
|
||||
|
||||
@ -191,7 +198,7 @@ const ConnectorList = ({
|
||||
setWalletUrl,
|
||||
isMainnet,
|
||||
}: {
|
||||
onSelect: (type: WalletType) => void;
|
||||
onSelect: (type: WalletType, isHosted?: boolean) => void;
|
||||
walletUrl: string;
|
||||
setWalletUrl: (value: string) => void;
|
||||
isMainnet: boolean;
|
||||
@ -202,18 +209,11 @@ const ConnectorList = ({
|
||||
<ConnectDialogTitle>{t('Connect')}</ConnectDialogTitle>
|
||||
<CustomUrlInput walletUrl={walletUrl} setWalletUrl={setWalletUrl} />
|
||||
<ul data-testid="connectors-list" className="mb-6">
|
||||
<li className="mb-4">
|
||||
<ConnectionOption
|
||||
type="gui"
|
||||
text={t('Desktop wallet app')}
|
||||
onClick={() => onSelect('gui')}
|
||||
/>
|
||||
</li>
|
||||
<li className="mb-4 last:mb-0">
|
||||
<ConnectionOption
|
||||
type="cli"
|
||||
text={t('Command line wallet app')}
|
||||
onClick={() => onSelect('cli')}
|
||||
type="jsonRpc"
|
||||
text={t('Connect Vega wallet')}
|
||||
onClick={() => onSelect('jsonRpc')}
|
||||
/>
|
||||
</li>
|
||||
{!isMainnet && (
|
||||
@ -221,7 +221,7 @@ const ConnectorList = ({
|
||||
<ConnectionOption
|
||||
type="hosted"
|
||||
text={t('Hosted Fairground wallet')}
|
||||
onClick={() => onSelect('hosted')}
|
||||
onClick={() => onSelect('hosted', true)}
|
||||
/>
|
||||
</li>
|
||||
)}
|
||||
|
@ -89,7 +89,6 @@ export class RestConnector implements VegaConnector {
|
||||
method: 'post',
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
console.log(res);
|
||||
|
||||
if (res.status === 403) {
|
||||
return { success: false, error: t('Invalid credentials') };
|
||||
|
Loading…
Reference in New Issue
Block a user