Skip to content

Commit

Permalink
fix: Scroll "View all quotes" button into view before clicking in STX…
Browse files Browse the repository at this point in the history
… migration test
  • Loading branch information
httpJunkie committed Dec 20, 2024
1 parent b58381f commit e92d4dd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
14 changes: 13 additions & 1 deletion test/e2e/tests/swaps/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,21 @@ export const checkNotification = async (
};

export const changeExchangeRate = async (driver: Driver) => {
// Ensure quote view button is present
await driver.waitForSelector('[data-testid="review-quote-view-all-quotes"]');

// Scroll button into view before clicking
await driver.executeScript(`
const element = document.querySelector('[data-testid="review-quote-view-all-quotes"]');
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
`);

// Add small delay allowing for smooth scroll
await driver.delay(500);

// Try to click the element
await driver.clickElement('[data-testid="review-quote-view-all-quotes"]');
await driver.waitForSelector({ text: 'Quote details', tag: 'h2' });

const networkFees = await driver.findElements(
'[data-testid*="select-quote-popover-row"]',
);
Expand Down
38 changes: 18 additions & 20 deletions test/e2e/tests/swaps/swap-eth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,49 @@ import {

// TODO: (MM-PENDING) These tests are planned for deprecation as part of swaps testing revamp
describe('Swap Eth for another Token @no-mmi', function () {
it('Completes second Swaps while first swap is processing', async function () {
withFixturesOptions.ganacheOptions.miner.blockTime = 10;

it('Completes a Swap between ETH and DAI after changing initial rate', async function () {
await withFixtures(
{
...withFixturesOptions,
testSpecificMock: mockEthDaiTrade,
title: this.test?.fullTitle(),
},
async ({ driver }) => {
await unlockWallet(driver);

await buildQuote(driver, {
amount: 0.001,
swapTo: 'USDC',
amount: 2,
swapTo: 'DAI',
});

// Close the STX notification immediately after buildQuote
// This ensures the UI is clear before we proceed with quote review
await closeSmartTransactionsMigrationNotification(driver);

await reviewQuote(driver, {
amount: 0.001,
amount: 2,
swapFrom: 'TESTETH',
swapTo: 'USDC',
});
await driver.clickElement({ text: 'Swap', tag: 'button' });
await driver.clickElement({ text: 'View in activity', tag: 'button' });
await buildQuote(driver, {
amount: 0.003,
swapTo: 'DAI',
});

// The changeExchangeRate function now includes scrolling logic
await changeExchangeRate(driver);

await reviewQuote(driver, {
amount: 0.003,
amount: 2,
swapFrom: 'TESTETH',
swapTo: 'DAI',
skipCounter: true,
});

await driver.clickElement({ text: 'Swap', tag: 'button' });
await waitForTransactionToComplete(driver, { tokenName: 'DAI' });
await checkActivityTransaction(driver, {
index: 0,
amount: '0.003',
amount: '2',
swapFrom: 'TESTETH',
swapTo: 'DAI',
});
await checkActivityTransaction(driver, {
index: 1,
amount: '0.001',
swapFrom: 'TESTETH',
swapTo: 'USDC',
});
},
);
});
Expand Down

0 comments on commit e92d4dd

Please sign in to comment.