Skip to content

Commit

Permalink
test(e2e): finishes pool tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodressel authored and mmpetarpeshev committed Jun 25, 2024
1 parent 2083a04 commit 059fa0d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 38 deletions.
1 change: 1 addition & 0 deletions src/views/RemoveLiquidity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
class="remove-btn"
:class="{ transparent: !enoughAllowance }"
:disabled="!removeButtonEnabled"
data-cy="remove-liquidity-btn"
@click="handleRemove"
>
{{ removing ? $t('removeLiquidity.removing') : $t('liquidityDetails.remove') }}
Expand Down
60 changes: 24 additions & 36 deletions tests/e2e/specs/pool.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,50 +28,38 @@ describe('Pool', () => {
cy.selectToken(1, 'ct_b7FZHQzBcAW4r43ECWpV3qQJMQJp5BxkZUGNKrqqLyjVRN3SC');
cy.get('.input-token input').eq(0).type('0.1');

// intercept the approval transaction
cy.intercept({
method: 'POST',
url: 'https://testnet.aeternity.io/v3/transactions*',
times: 1,
}).as('postTx');
cy.approveTokenUsageIfNessesary();

cy.contains('Approve').click();
cy.interceptTxPost();
cy.contains('Supply').click();
cy.get('.transaction-details').should('be.visible');
cy.contains('Confirm Supply').click();
cy.wait('@walletSignTx', { timeout: 10000 });
cy.wait('@postTx', { timeout: 10000 });

// wait for notification to appear
cy.get('.notification-transaction-status').should('be.visible', { timeout: 10000 });
cy.get('.notification-transaction-status').should('be.visible');
});

it('Import Pool Share', () => {
cy.importLiquidity();
});

it('Remove Liquidity', () => {
// Setup test
cy.importLiquidity();
cy.get('.liquidity-item').click();
cy.get('.liquidity-item .body').should('be.visible');
cy.contains('Remove').click();
cy.get('.remove-liquidity').should('be.visible');
cy.contains('100%').click();
cy.approveTokenUsageIfNessesary();
cy.interceptTxPost();
cy.contains('Supply').click();
cy.get('[data-cy="remove-liquidity-btn"]').click();
cy.get('.confirm-add-modal').should('be.visible');
cy.get('.confirm-add-modal button.primary').click();
cy.wait('@walletSignTx', { timeout: 10000 });
cy.wait('@postTx', { timeout: 10000 });
});

it.skip('Remove Liquidity', () => {
cy.login()
.get('[data-cy=pool]')
.filter(':visible')
.click()
.get('.title')
.should('contain', 'Pool')
.get('.pool-view')
.should('be.visible')
.get('.remove-liquidity-button')
.click()
.get('.remove-liquidity-modal')
.should('be.visible')
.get('.input-token input')
.eq(0)
.type('1')
.get('.input-token input')
.eq(1)
.type('1')
.get('.remove-liquidity-modal button.primary')
.click()
.get('.confirm-transaction-modal')
.should('be.visible')
.get('.confirm-transaction-modal button.primary')
.click();
cy.get('.notification-transaction-status').should('be.visible');
});
});
42 changes: 40 additions & 2 deletions tests/e2e/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Cypress.Commands.add('login', () => {
.should('contain', 'Testnet');
});

Cypress.Commands.add('selectToken', (slot, token) => {
Cypress.Commands.add('selectToken', (slot, token, initialSelector = '.input-token button') => {
// get first .input-token
cy.get('.input-token button')
cy.get(initialSelector)
.eq(slot)
.click()
// token pop up should open
Expand Down Expand Up @@ -51,3 +51,41 @@ Cypress.Commands.add('interceptTxPost', () => {
{ tx_hash: 'th_8zREhgdJmg8LxG5hnJ2Eq63n7ZTbJMeZfi8EETDjtdnmv4Ksk' },
).as('postTx');
});

Cypress.Commands.add('importLiquidity', () => {
cy.login();
cy.get('[data-cy=pool]').filter(':visible').click();
cy.get('.title').should('contain', 'Pool');
cy.get('.pool-view').should('be.visible');

cy.contains('Import it.').click();

cy.get('.import-pool').should('be.visible');
cy.selectToken(0, undefined, '.button-token');
cy.selectToken(1, 'ct_b7FZHQzBcAW4r43ECWpV3qQJMQJp5BxkZUGNKrqqLyjVRN3SC', '.button-token');

cy.get('.pool-found').should('be.visible');

cy.contains('Ok').click();

cy.get('.liquidity-item').should('be.visible');
});

Cypress.Commands.add('approveTokenUsageIfNessesary', () => {
cy.contains('Approve').then(($btn) => {
if (!$btn.is(':disabled')) {
// intercept the approval transaction
cy.intercept({
method: 'POST',
url: 'https://testnet.aeternity.io/v3/transactions*',
times: 1,
}).as('postTx');
cy.contains('Approve').click();
cy.wait('@walletSignTx', { timeout: 10000 });
cy.wait('@postTx', { timeout: 10000 });

// wait for notification to appear
cy.get('.notification-transaction-status').should('be.visible', { timeout: 10000 });
}
});
});

0 comments on commit 059fa0d

Please sign in to comment.