|
|
@@ -21,15 +21,21 @@ const orderUpdatedAt = 'updatedAt';
|
|
|
|
const assetSelectField = 'select[name="asset"]';
|
|
|
|
const assetSelectField = 'select[name="asset"]';
|
|
|
|
const amountField = 'input[name="amount"]';
|
|
|
|
const amountField = 'input[name="amount"]';
|
|
|
|
const txTimeout = Cypress.env('txTimeout');
|
|
|
|
const txTimeout = Cypress.env('txTimeout');
|
|
|
|
const btcName = 'BTC (local)';
|
|
|
|
const sepoliaUrl = Cypress.env('ETHERSCAN_URL');
|
|
|
|
|
|
|
|
const btcName =
|
|
|
|
|
|
|
|
'BTC (local)5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c - tBTC';
|
|
|
|
const btcSymbol = 'tBTC';
|
|
|
|
const btcSymbol = 'tBTC';
|
|
|
|
const usdcSymbol = 'fUSDC';
|
|
|
|
const usdcSymbol = 'fUSDC';
|
|
|
|
const toastContent = 'toast-content';
|
|
|
|
const toastContent = 'toast-content';
|
|
|
|
const ordersTab = 'Orders';
|
|
|
|
const ordersTab = 'Orders';
|
|
|
|
const depositsTab = 'Deposits';
|
|
|
|
const depositsTab = 'Deposits';
|
|
|
|
const toastCloseBtn = 'toast-close';
|
|
|
|
const toastCloseBtn = 'toast-close';
|
|
|
|
|
|
|
|
const price = '390';
|
|
|
|
|
|
|
|
const size = '0.0005';
|
|
|
|
|
|
|
|
const newPrice = '200';
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: ensure this test runs only if capsule is running via workflow
|
|
|
|
// TODO: ensure this test runs only if capsule is running via workflow
|
|
|
|
|
|
|
|
// Because the tests are run on a live network to optimize time, the tests are interdependent and must be run in the given order.
|
|
|
|
describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
before(() => {
|
|
|
|
before(() => {
|
|
|
|
cy.createMarket();
|
|
|
|
cy.createMarket();
|
|
|
@@ -50,8 +56,8 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
marketId: market.id,
|
|
|
|
marketId: market.id,
|
|
|
|
type: Schema.OrderType.TYPE_LIMIT,
|
|
|
|
type: Schema.OrderType.TYPE_LIMIT,
|
|
|
|
side: Schema.Side.SIDE_BUY,
|
|
|
|
side: Schema.Side.SIDE_BUY,
|
|
|
|
size: '0.0005',
|
|
|
|
size: size,
|
|
|
|
price: '390',
|
|
|
|
price: price,
|
|
|
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
|
|
|
|
timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const rawPrice = removeDecimal(order.price, market.decimalPlaces);
|
|
|
|
const rawPrice = removeDecimal(order.price, market.decimalPlaces);
|
|
|
@@ -64,7 +70,8 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
|
|
|
|
|
|
|
|
cy.getByTestId(toastContent).should(
|
|
|
|
cy.getByTestId(toastContent).should(
|
|
|
|
'contain.text',
|
|
|
|
'contain.text',
|
|
|
|
`ConfirmedYour transaction has been confirmed View in block explorerSubmit order - activeTEST.24h+0.0005 @ 390.00 ${usdcSymbol}`
|
|
|
|
`ConfirmedYour transaction has been confirmed View in block explorerSubmit order - activeTEST.24h+${order.size} @ ${order.price}.00 ${usdcSymbol}`,
|
|
|
|
|
|
|
|
{ matchCase: false }
|
|
|
|
);
|
|
|
|
);
|
|
|
|
cy.getByTestId(toastCloseBtn).click();
|
|
|
|
cy.getByTestId(toastCloseBtn).click();
|
|
|
|
// orderbook cells are keyed by price level
|
|
|
|
// orderbook cells are keyed by price level
|
|
|
@@ -75,7 +82,7 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
.should('contain.text', rawSize);
|
|
|
|
.should('contain.text', rawSize);
|
|
|
|
|
|
|
|
|
|
|
|
cy.getByTestId(ordersTab).click();
|
|
|
|
cy.getByTestId(ordersTab).click();
|
|
|
|
cy.getByTestId('edit').should('contain.text', 'Edit');
|
|
|
|
cy.getByTestId('edit', txTimeout).should('contain.text', 'Edit');
|
|
|
|
cy.getByTestId('tab-orders').within(() => {
|
|
|
|
cy.getByTestId('tab-orders').within(() => {
|
|
|
|
cy.get('.ag-center-cols-container')
|
|
|
|
cy.get('.ag-center-cols-container')
|
|
|
|
.children()
|
|
|
|
.children()
|
|
|
@@ -113,35 +120,41 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
checkIfDataAndTimeOfCreationAndUpdateIsEqual(orderCreatedAt);
|
|
|
|
checkIfDataAndTimeOfCreationAndUpdateIsEqual(orderCreatedAt);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//edit order
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('can edit order', function () {
|
|
|
|
cy.getByTestId(ordersTab).click();
|
|
|
|
cy.getByTestId(ordersTab).click();
|
|
|
|
cy.getByTestId('edit').first().should('be.visible').click();
|
|
|
|
cy.getByTestId('edit').first().should('be.visible').click();
|
|
|
|
cy.getByTestId('dialog-title').should('contain.text', 'Edit order');
|
|
|
|
cy.getByTestId('dialog-title').should('contain.text', 'Edit order');
|
|
|
|
cy.get('#limitPrice').focus().clear().type('200');
|
|
|
|
cy.get('#limitPrice').focus().clear().type(newPrice);
|
|
|
|
cy.getByTestId('edit-order').find('[type="submit"]').click();
|
|
|
|
cy.getByTestId('edit-order').find('[type="submit"]').click();
|
|
|
|
cy.getByTestId(toastContent).should(
|
|
|
|
cy.getByTestId(toastContent).should(
|
|
|
|
'contain.text',
|
|
|
|
'contain.text',
|
|
|
|
`ConfirmedYour transaction has been confirmed View in block explorerEdit order - activeTEST.24h+0.0005 @ 200.00 ${usdcSymbol}+0.0005 @ 200.00 ${usdcSymbol}`
|
|
|
|
`ConfirmedYour transaction has been confirmed View in block explorerEdit order - activeTEST.24h+${size} @ ${price}.00 ${usdcSymbol}+${size} @ ${newPrice}.00 ${usdcSymbol}`,
|
|
|
|
|
|
|
|
{ matchCase: false }
|
|
|
|
);
|
|
|
|
);
|
|
|
|
cy.getByTestId(ordersTab).click();
|
|
|
|
cy.getByTestId(ordersTab).click();
|
|
|
|
cy.getByTestId(toastCloseBtn).click();
|
|
|
|
cy.getByTestId(toastCloseBtn).click({ multiple: true });
|
|
|
|
cy.get('.ag-center-cols-container')
|
|
|
|
cy.get('.ag-center-cols-container')
|
|
|
|
.children()
|
|
|
|
.children()
|
|
|
|
.first()
|
|
|
|
.first()
|
|
|
|
.within(() => {
|
|
|
|
.within(() => {
|
|
|
|
cy.get(`[col-id='${orderPrice}']`).then(($price) => {
|
|
|
|
cy.get(`[col-id='${orderPrice}']`).then(($price) => {
|
|
|
|
expect(parseFloat($price.text())).to.equal(parseFloat('200'));
|
|
|
|
expect(parseFloat($price.text())).to.equal(parseFloat(newPrice));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
checkIfDataAndTimeOfCreationAndUpdateIsEqual(orderUpdatedAt);
|
|
|
|
checkIfDataAndTimeOfCreationAndUpdateIsEqual(orderUpdatedAt);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//cancel order
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('can cancel order', function () {
|
|
|
|
cy.getByTestId(ordersTab).click();
|
|
|
|
cy.getByTestId(ordersTab).click();
|
|
|
|
cy.getByTestId('cancel').first().click();
|
|
|
|
cy.getByTestId('cancel').first().click();
|
|
|
|
cy.getByTestId(toastContent).should(
|
|
|
|
cy.getByTestId(toastContent).should(
|
|
|
|
'contain.text',
|
|
|
|
'contain.text',
|
|
|
|
`ConfirmedYour transaction has been confirmed View in block explorerCancel order - cancelledTEST.24h+0.0005 @ 200.00 ${usdcSymbol}`
|
|
|
|
`ConfirmedYour transaction has been confirmed View in block explorerCancel order - cancelledTEST.24h+${size} @ ${newPrice}.00 ${usdcSymbol}`,
|
|
|
|
|
|
|
|
{ matchCase: false }
|
|
|
|
);
|
|
|
|
);
|
|
|
|
cy.getByTestId(toastCloseBtn).click();
|
|
|
|
cy.getByTestId(toastCloseBtn).click({ multiple: true });
|
|
|
|
|
|
|
|
|
|
|
|
cy.getByTestId('tab-orders')
|
|
|
|
cy.getByTestId('tab-orders')
|
|
|
|
.get('.ag-center-cols-container')
|
|
|
|
.get('.ag-center-cols-container')
|
|
|
@@ -151,7 +164,10 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
.should('contain.text', OrderStatusMapping.STATUS_CANCELLED);
|
|
|
|
.should('contain.text', OrderStatusMapping.STATUS_CANCELLED);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('can deposit and withdrawal', function () {
|
|
|
|
it('can deposit', function () {
|
|
|
|
|
|
|
|
cy.visit('/#/portfolio');
|
|
|
|
|
|
|
|
cy.get('main[data-testid="/portfolio"]').should('exist');
|
|
|
|
|
|
|
|
|
|
|
|
// 1001-DEPO-001
|
|
|
|
// 1001-DEPO-001
|
|
|
|
// 1001-DEPO-002
|
|
|
|
// 1001-DEPO-002
|
|
|
|
// 1001-DEPO-003
|
|
|
|
// 1001-DEPO-003
|
|
|
@@ -160,27 +176,12 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
// 1001-DEPO-007
|
|
|
|
// 1001-DEPO-007
|
|
|
|
// 1001-DEPO-008
|
|
|
|
// 1001-DEPO-008
|
|
|
|
// 1001-DEPO-009
|
|
|
|
// 1001-DEPO-009
|
|
|
|
// 1002-WITH-001
|
|
|
|
// 1001-DEPO-010
|
|
|
|
// 1002-WITH-006
|
|
|
|
|
|
|
|
// 1002-WITH-009
|
|
|
|
|
|
|
|
// 002-WITH-011
|
|
|
|
|
|
|
|
// 1002-WITH-024
|
|
|
|
|
|
|
|
// 1002-WITH-012
|
|
|
|
|
|
|
|
// 1002-WITH-013
|
|
|
|
|
|
|
|
// 1002-WITH-014
|
|
|
|
|
|
|
|
// 1002-WITH-015
|
|
|
|
|
|
|
|
// 1002-WITH-016
|
|
|
|
|
|
|
|
// 1002-WITH-019
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cy.visit('/#/portfolio');
|
|
|
|
|
|
|
|
cy.get('main[data-testid="/portfolio"]').should('exist');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cy.highlight('creating deposit');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cy.getByTestId(depositsTab).click();
|
|
|
|
cy.getByTestId(depositsTab).click();
|
|
|
|
cy.getByTestId('deposit-button').click();
|
|
|
|
cy.getByTestId('deposit-button').click();
|
|
|
|
connectEthereumWallet('Unknown');
|
|
|
|
connectEthereumWallet('Unknown');
|
|
|
|
cy.get(assetSelectField, txTimeout).select(btcName);
|
|
|
|
cy.get(assetSelectField, txTimeout).select(btcName, { force: true });
|
|
|
|
cy.getByTestId('deposit-approve-submit').click();
|
|
|
|
cy.getByTestId('deposit-approve-submit').click();
|
|
|
|
cy.getByTestId('dialog-title').should('contain.text', 'Approve complete');
|
|
|
|
cy.getByTestId('dialog-title').should('contain.text', 'Approve complete');
|
|
|
|
cy.get('[data-testid="Return to deposit"]').click();
|
|
|
|
cy.get('[data-testid="Return to deposit"]').click();
|
|
|
@@ -188,7 +189,8 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
cy.getByTestId('deposit-submit').click();
|
|
|
|
cy.getByTestId('deposit-submit').click();
|
|
|
|
cy.getByTestId(toastContent, txTimeout).should(
|
|
|
|
cy.getByTestId(toastContent, txTimeout).should(
|
|
|
|
'contain.text',
|
|
|
|
'contain.text',
|
|
|
|
`Transaction completedYour transaction has been completedView on EtherscanDeposit 1.00 ${btcSymbol}`
|
|
|
|
`Transaction confirmedYour transaction has been confirmed.View on EtherscanDeposit 1.00 ${btcSymbol}`,
|
|
|
|
|
|
|
|
{ matchCase: false }
|
|
|
|
);
|
|
|
|
);
|
|
|
|
cy.getByTestId(toastCloseBtn).click();
|
|
|
|
cy.getByTestId(toastCloseBtn).click();
|
|
|
|
cy.getByTestId('Collateral').click();
|
|
|
|
cy.getByTestId('Collateral').click();
|
|
|
@@ -196,8 +198,6 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
cy.highlight('deposit verification');
|
|
|
|
cy.highlight('deposit verification');
|
|
|
|
|
|
|
|
|
|
|
|
cy.getByTestId('asset', txTimeout).should('contain.text', btcSymbol);
|
|
|
|
cy.getByTestId('asset', txTimeout).should('contain.text', btcSymbol);
|
|
|
|
// need to reload page to see deposit history complete
|
|
|
|
|
|
|
|
cy.reload();
|
|
|
|
|
|
|
|
cy.getByTestId(depositsTab).click();
|
|
|
|
cy.getByTestId(depositsTab).click();
|
|
|
|
cy.get('.ag-cell-value', txTimeout).should('contain.text', btcSymbol);
|
|
|
|
cy.get('.ag-cell-value', txTimeout).should('contain.text', btcSymbol);
|
|
|
|
cy.get('[col-id="status"]').should('not.have.text', 'Open', txTimeout);
|
|
|
|
cy.get('[col-id="status"]').should('not.have.text', 'Open', txTimeout);
|
|
|
@@ -214,15 +214,29 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
cy.get('[col-id="txHash"]')
|
|
|
|
cy.get('[col-id="txHash"]')
|
|
|
|
.find('a')
|
|
|
|
.find('a')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.and('contain', 'https://sepolia.etherscan.io/tx');
|
|
|
|
.and('contain', `${sepoliaUrl}/tx/0x`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
cy.highlight('creating withdrawals');
|
|
|
|
it('can withdrawal', function () {
|
|
|
|
|
|
|
|
// 1002-WITH-001
|
|
|
|
|
|
|
|
// 1002-WITH-006
|
|
|
|
|
|
|
|
// 1002-WITH-009
|
|
|
|
|
|
|
|
// 1002-WITH-011
|
|
|
|
|
|
|
|
// 1002-WITH-024
|
|
|
|
|
|
|
|
// 1002-WITH-012
|
|
|
|
|
|
|
|
// 1002-WITH-013
|
|
|
|
|
|
|
|
// 1002-WITH-014
|
|
|
|
|
|
|
|
// 1002-WITH-015
|
|
|
|
|
|
|
|
// 1002-WITH-016
|
|
|
|
|
|
|
|
// 1002-WITH-019
|
|
|
|
|
|
|
|
|
|
|
|
cy.getByTestId('Withdrawals').click();
|
|
|
|
cy.getByTestId('Withdrawals').click();
|
|
|
|
cy.getByTestId('withdraw-dialog-button').click();
|
|
|
|
cy.getByTestId('withdraw-dialog-button').click();
|
|
|
|
connectEthereumWallet('Unknown');
|
|
|
|
cy.get(assetSelectField, txTimeout).select(
|
|
|
|
cy.get(assetSelectField).select(btcName);
|
|
|
|
'BTC (local)5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c - tBTC',
|
|
|
|
|
|
|
|
{ force: true }
|
|
|
|
|
|
|
|
);
|
|
|
|
cy.get(amountField).clear().type('1');
|
|
|
|
cy.get(amountField).clear().type('1');
|
|
|
|
cy.getByTestId('submit-withdrawal').click();
|
|
|
|
cy.getByTestId('submit-withdrawal').click();
|
|
|
|
cy.getByTestId(toastContent, txTimeout).should(
|
|
|
|
cy.getByTestId(toastContent, txTimeout).should(
|
|
|
@@ -243,7 +257,7 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
cy.getByTestId('toast-complete-withdrawal').click();
|
|
|
|
cy.getByTestId('toast-complete-withdrawal').click();
|
|
|
|
cy.getByTestId(toastContent, txTimeout).should(
|
|
|
|
cy.getByTestId(toastContent, txTimeout).should(
|
|
|
|
'contain.text',
|
|
|
|
'contain.text',
|
|
|
|
'Transaction completed'
|
|
|
|
'Transaction confirmed'
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
cy.getByTestId('complete-withdrawal', txTimeout).should('not.exist');
|
|
|
|
cy.getByTestId('complete-withdrawal', txTimeout).should('not.exist');
|
|
|
@@ -258,17 +272,28 @@ describe('capsule', { tags: '@slow' }, () => {
|
|
|
|
cy.get('[col-id="details.receiverAddress"]')
|
|
|
|
cy.get('[col-id="details.receiverAddress"]')
|
|
|
|
.find('a')
|
|
|
|
.find('a')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.and('contain', 'https://sepolia.etherscan.io/address/');
|
|
|
|
.and('contain', `${sepoliaUrl}/address/`);
|
|
|
|
cy.get('[col-id="createdTimestamp"]').should('not.be.empty');
|
|
|
|
cy.get('[col-id="createdTimestamp"]').should('not.be.empty');
|
|
|
|
cy.get('[col-id="withdrawnTimestamp"]').should('not.be.empty');
|
|
|
|
cy.get('[col-id="withdrawnTimestamp"]').should('not.be.empty');
|
|
|
|
cy.get('[col-id="status"]').should('have.text', 'Completed');
|
|
|
|
cy.get('[col-id="status"]').should('have.text', 'Completed');
|
|
|
|
cy.get('[col-id="txHash"]')
|
|
|
|
cy.get('[col-id="txHash"]')
|
|
|
|
.find('a')
|
|
|
|
.find('a')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.should('have.attr', 'href')
|
|
|
|
.and('contain', 'https://sepolia.etherscan.io/tx/0x');
|
|
|
|
.and('contain', `${sepoliaUrl}/tx/0x`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('deposit - if approved amount is less than deposit: must see that an approval is needed and be prompted to approve more', function () {
|
|
|
|
|
|
|
|
// 1001-DEPO-006
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cy.getByTestId(depositsTab).click();
|
|
|
|
|
|
|
|
cy.getByTestId('deposit-button').click();
|
|
|
|
|
|
|
|
cy.get(assetSelectField, txTimeout).select(btcName, { force: true });
|
|
|
|
|
|
|
|
cy.get(amountField).clear().type('20000000');
|
|
|
|
|
|
|
|
cy.getByTestId('deposit-approve-submit').should('be.visible');
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function checkIfDataAndTimeOfCreationAndUpdateIsEqual(date: string) {
|
|
|
|
function checkIfDataAndTimeOfCreationAndUpdateIsEqual(date: string) {
|
|
|
|
cy.get(`[col-id='${date}'] .ag-cell-wrapper`)
|
|
|
|
cy.get(`[col-id='${date}'] .ag-cell-wrapper`)
|
|
|
|
.children('span')
|
|
|
|
.children('span')
|
|
|
|