test(trading): 0003-WTXN submit vega transaction e2e tests (#3246)
This commit is contained in:
parent
f649d78565
commit
a060f94146
@ -143,6 +143,7 @@ describe('capsule - without MultiSign', { tags: '@slow' }, () => {
|
|||||||
it('can not withdrawal because of no MultiSign', function () {
|
it('can not withdrawal because of no MultiSign', function () {
|
||||||
// 1002-WITH-022
|
// 1002-WITH-022
|
||||||
// 1002-WITH-023
|
// 1002-WITH-023
|
||||||
|
// 0003-WTXN-011
|
||||||
|
|
||||||
cy.getByTestId('Withdrawals').click();
|
cy.getByTestId('Withdrawals').click();
|
||||||
cy.getByTestId('withdraw-dialog-button').click();
|
cy.getByTestId('withdraw-dialog-button').click();
|
||||||
|
@ -76,6 +76,8 @@ describe('must submit order', { tags: '@smoke' }, () => {
|
|||||||
|
|
||||||
it('successfully places market buy order', () => {
|
it('successfully places market buy order', () => {
|
||||||
// 7002-SORD-010
|
// 7002-SORD-010
|
||||||
|
// 0003-WTXN-012
|
||||||
|
// 0003-WTXN-003
|
||||||
cy.mockVegaWalletTransaction();
|
cy.mockVegaWalletTransaction();
|
||||||
const order: OrderSubmission = {
|
const order: OrderSubmission = {
|
||||||
marketId: 'market-0',
|
marketId: 'market-0',
|
||||||
@ -367,6 +369,7 @@ describe('deal ticket validation', { tags: '@smoke' }, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('must show place order button and connect wallet if wallet is not connected', () => {
|
it('must show place order button and connect wallet if wallet is not connected', () => {
|
||||||
|
// 0003-WTXN-001
|
||||||
cy.getByTestId('connect-vega-wallet'); // Not connected
|
cy.getByTestId('connect-vega-wallet'); // Not connected
|
||||||
cy.getByTestId('order-connect-wallet').should('exist');
|
cy.getByTestId('order-connect-wallet').should('exist');
|
||||||
cy.getByTestId(placeOrderBtn).should('exist');
|
cy.getByTestId(placeOrderBtn).should('exist');
|
||||||
@ -682,6 +685,7 @@ describe('account validation', { tags: '@regression' }, () => {
|
|||||||
|
|
||||||
it('should display info and button for deposit', () => {
|
it('should display info and button for deposit', () => {
|
||||||
// 7002-SORD-003
|
// 7002-SORD-003
|
||||||
|
|
||||||
// warning should show immediately
|
// warning should show immediately
|
||||||
cy.getByTestId('dealticket-warning-margin').should(
|
cy.getByTestId('dealticket-warning-margin').should(
|
||||||
'contain.text',
|
'contain.text',
|
||||||
@ -698,4 +702,94 @@ describe('account validation', { tags: '@regression' }, () => {
|
|||||||
.should('have.text', 'Deposit');
|
.should('have.text', 'Deposit');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('must submit order', { tags: '@smoke' }, () => {
|
||||||
|
// 7002-SORD-039
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.setVegaWallet();
|
||||||
|
cy.mockTradingPage();
|
||||||
|
cy.mockSubscription();
|
||||||
|
cy.visit('/#/markets/market-0');
|
||||||
|
cy.wait('@Markets');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('must see a prompt to check connected vega wallet to approve transaction', () => {
|
||||||
|
// 0003-WTXN-002
|
||||||
|
cy.mockVegaWalletTransaction(1000);
|
||||||
|
const order: OrderSubmission = {
|
||||||
|
marketId: 'market-0',
|
||||||
|
type: Schema.OrderType.TYPE_MARKET,
|
||||||
|
side: Schema.Side.SIDE_BUY,
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK,
|
||||||
|
size: '100',
|
||||||
|
};
|
||||||
|
createOrder(order);
|
||||||
|
cy.getByTestId('toast-content').should(
|
||||||
|
'contain.text',
|
||||||
|
'Please go to your Vega wallet application and approve or reject the transaction.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('must show error returned by wallet ', () => {
|
||||||
|
// 0003-WTXN-009
|
||||||
|
// 0003-WTXN-011
|
||||||
|
|
||||||
|
//trigger error from the wallet
|
||||||
|
cy.intercept('POST', 'http://localhost:1789/api/v2/requests', (req) => {
|
||||||
|
req.on('response', (res) => {
|
||||||
|
res.send({
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
id: '1',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const order: OrderSubmission = {
|
||||||
|
marketId: 'market-0',
|
||||||
|
type: Schema.OrderType.TYPE_MARKET,
|
||||||
|
side: Schema.Side.SIDE_BUY,
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK,
|
||||||
|
size: '100',
|
||||||
|
};
|
||||||
|
createOrder(order);
|
||||||
|
cy.getByTestId('toast-content').should(
|
||||||
|
'contain.text',
|
||||||
|
'The connection to your Vega Wallet has been lost.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('must see that the order was rejected by the connected wallet', () => {
|
||||||
|
// 0003-WTXN-007
|
||||||
|
|
||||||
|
//trigger rejection error from the wallet
|
||||||
|
cy.intercept('POST', 'http://localhost:1789/api/v2/requests', (req) => {
|
||||||
|
req.alias = 'client.send_transaction';
|
||||||
|
req.reply({
|
||||||
|
statusCode: 400,
|
||||||
|
body: {
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
error: {
|
||||||
|
code: 3001,
|
||||||
|
data: 'the user rejected the wallet connection',
|
||||||
|
message: 'User error',
|
||||||
|
},
|
||||||
|
id: '0',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const order: OrderSubmission = {
|
||||||
|
marketId: 'market-0',
|
||||||
|
type: Schema.OrderType.TYPE_MARKET,
|
||||||
|
side: Schema.Side.SIDE_BUY,
|
||||||
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK,
|
||||||
|
size: '100',
|
||||||
|
};
|
||||||
|
createOrder(order);
|
||||||
|
cy.getByTestId('toast-content').should(
|
||||||
|
'contain.text',
|
||||||
|
'Error occurredthe user rejected the wallet connection'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -156,6 +156,7 @@ describe('connect vega wallet', { tags: '@smoke' }, () => {
|
|||||||
// 0002-WCON-035
|
// 0002-WCON-035
|
||||||
// 0002-WCON-014
|
// 0002-WCON-014
|
||||||
// 0002-WCON-010
|
// 0002-WCON-010
|
||||||
|
// 0003-WTXN-004
|
||||||
|
|
||||||
mockConnectWallet();
|
mockConnectWallet();
|
||||||
const key2 = Cypress.env('VEGA_PUBLIC_KEY2');
|
const key2 = Cypress.env('VEGA_PUBLIC_KEY2');
|
||||||
|
@ -8,6 +8,7 @@ declare global {
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
interface Chainable<Subject> {
|
interface Chainable<Subject> {
|
||||||
mockVegaWalletTransaction(
|
mockVegaWalletTransaction(
|
||||||
|
delayValue?: number,
|
||||||
override?: PartialDeep<TransactionResponse>
|
override?: PartialDeep<TransactionResponse>
|
||||||
): void;
|
): void;
|
||||||
}
|
}
|
||||||
@ -17,7 +18,7 @@ declare global {
|
|||||||
export function addMockTransactionResponse() {
|
export function addMockTransactionResponse() {
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
'mockVegaWalletTransaction',
|
'mockVegaWalletTransaction',
|
||||||
(override?: PartialDeep<TransactionResponse>) => {
|
(delayValue?: number, override?: PartialDeep<TransactionResponse>) => {
|
||||||
const defaultTransactionResponse = {
|
const defaultTransactionResponse = {
|
||||||
transactionHash: 'test-tx-hash',
|
transactionHash: 'test-tx-hash',
|
||||||
sentAt: new Date().toISOString(),
|
sentAt: new Date().toISOString(),
|
||||||
@ -43,12 +44,16 @@ export function addMockTransactionResponse() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
cy.intercept('POST', 'http://localhost:1789/api/v2/requests', {
|
cy.intercept('POST', 'http://localhost:1789/api/v2/requests', (req) => {
|
||||||
body: {
|
req.on('response', (res) => {
|
||||||
|
res.setDelay(delayValue ?? 0);
|
||||||
|
res.statusCode = 400;
|
||||||
|
res.send({
|
||||||
jsonrpc: '2.0',
|
jsonrpc: '2.0',
|
||||||
result: merge(defaultTransactionResponse, override),
|
result: merge(defaultTransactionResponse, override),
|
||||||
id: '1',
|
id: '1',
|
||||||
},
|
});
|
||||||
|
});
|
||||||
}).as('VegaWalletTransaction');
|
}).as('VegaWalletTransaction');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user