From 460144a6e742b2b1c09569373a36a58d9b0ad188 Mon Sep 17 00:00:00 2001 From: Davide Brocchetto Date: Tue, 3 Sep 2024 11:32:37 +0200 Subject: [PATCH 1/7] Added one additional swipe gesture --- e2e/pages/swaps/SwapView.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/pages/swaps/SwapView.js b/e2e/pages/swaps/SwapView.js index a82ad154b83..bde715bbddf 100644 --- a/e2e/pages/swaps/SwapView.js +++ b/e2e/pages/swaps/SwapView.js @@ -37,11 +37,11 @@ class SwapView { async swipeToSwap() { const percentage = device.getPlatform() === 'ios' ? 0.72 : 0.95; - // Wait for counter to go down to 0:05 - // as the flashing gas fees happening when counter is 0:15 - // will disables the swipe button - await Assertions.checkIfTextIsDisplayed('New quotes in 0:05'); + // Two swipes are needed because the flashing gas fee + // could interupt the first swipe await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); + await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); + await Assertions.checkIfTextIsDisplayed('Swap!'); } swapCompleteLabel(sourceTokenSymbol, destTokenSymbol) { From 0158f8b9890f30b28152d43e2c3c789c30f809de Mon Sep 17 00:00:00 2001 From: Davide Brocchetto Date: Tue, 3 Sep 2024 16:08:54 +0200 Subject: [PATCH 2/7] Changed the code to a loop --- e2e/pages/swaps/SwapView.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/e2e/pages/swaps/SwapView.js b/e2e/pages/swaps/SwapView.js index bde715bbddf..aedb802ed14 100644 --- a/e2e/pages/swaps/SwapView.js +++ b/e2e/pages/swaps/SwapView.js @@ -5,7 +5,7 @@ import { import Matchers from '../../utils/Matchers'; import Gestures from '../../utils/Gestures'; -import Assertions from '../../utils/Assertions'; +import TestHelpers from '../../helpers'; class SwapView { get quoteSummary() { @@ -37,11 +37,16 @@ class SwapView { async swipeToSwap() { const percentage = device.getPlatform() === 'ios' ? 0.72 : 0.95; - // Two swipes are needed because the flashing gas fee - // could interupt the first swipe - await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); - await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); - await Assertions.checkIfTextIsDisplayed('Swap!'); + + // Swipe could happen at the same time when gas fees are falshing + // and that's when the swipe button becomes disabled + // that's the need to retry + let swapCompleteted + do { + await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); + await TestHelpers.delay(1000); + swapCompleteted = await Matchers.getElementByText('Swap!') + } while (!swapCompleteted) } swapCompleteLabel(sourceTokenSymbol, destTokenSymbol) { From 173c637c0edba75a1cddb8ee53cf9ee4e066aaac Mon Sep 17 00:00:00 2001 From: Davide Brocchetto Date: Tue, 3 Sep 2024 17:03:38 +0200 Subject: [PATCH 3/7] Removed loop --- e2e/pages/swaps/SwapView.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/e2e/pages/swaps/SwapView.js b/e2e/pages/swaps/SwapView.js index aedb802ed14..6d08e40571f 100644 --- a/e2e/pages/swaps/SwapView.js +++ b/e2e/pages/swaps/SwapView.js @@ -41,12 +41,9 @@ class SwapView { // Swipe could happen at the same time when gas fees are falshing // and that's when the swipe button becomes disabled // that's the need to retry - let swapCompleteted - do { - await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); - await TestHelpers.delay(1000); - swapCompleteted = await Matchers.getElementByText('Swap!') - } while (!swapCompleteted) + await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); + await TestHelpers.delay(4000); + await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); } swapCompleteLabel(sourceTokenSymbol, destTokenSymbol) { From 3cccc35fd80ce44757a30101aa2689429825374a Mon Sep 17 00:00:00 2001 From: Davide Brocchetto Date: Tue, 3 Sep 2024 18:12:46 +0200 Subject: [PATCH 4/7] Changed timeout to 10 sec for waitAndTap --- e2e/utils/Gestures.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/utils/Gestures.js b/e2e/utils/Gestures.js index f5d5957fc34..73b4df867f2 100644 --- a/e2e/utils/Gestures.js +++ b/e2e/utils/Gestures.js @@ -51,9 +51,9 @@ class Gestures { * Wait for an element to be visible and then tap it. * * @param {Promise} elementID - ID of the element to tap - * @param {number} timeout - Timeout for waiting (default: 8000ms) + * @param {number} timeout - Timeout for waiting (default: 10000ms) */ - static async waitAndTap(elementID, timeout = 15000) { + static async waitAndTap(elementID, timeout = 10000) { const element = await elementID; await waitFor(element).toBeVisible().withTimeout(timeout); await element.tap(); From 0c92a1f1088c5090a54edf40c8e46f540cff743d Mon Sep 17 00:00:00 2001 From: Davide Brocchetto Date: Tue, 3 Sep 2024 18:53:36 +0200 Subject: [PATCH 5/7] Added waitToBeVisible to swipe gesture --- e2e/utils/Gestures.js | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/utils/Gestures.js b/e2e/utils/Gestures.js index 73b4df867f2..bcb9c3caca3 100644 --- a/e2e/utils/Gestures.js +++ b/e2e/utils/Gestures.js @@ -132,6 +132,7 @@ class Gestures { static async swipe(elementID, direction, speed, percentage, xStart, yStart) { const element = await elementID; + await waitFor(element).toBeVisible(); await element.swipe(direction, speed, percentage, xStart, yStart); } From 2f1a6d735484d6504edfba9cc3413a25f7092355 Mon Sep 17 00:00:00 2001 From: Davide Brocchetto Date: Tue, 3 Sep 2024 21:41:14 +0200 Subject: [PATCH 6/7] Add timeout to tap IUnderstandPriceWarning --- e2e/pages/swaps/SwapView.js | 2 +- e2e/utils/Gestures.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/e2e/pages/swaps/SwapView.js b/e2e/pages/swaps/SwapView.js index 6d08e40571f..019efbc6776 100644 --- a/e2e/pages/swaps/SwapView.js +++ b/e2e/pages/swaps/SwapView.js @@ -54,7 +54,7 @@ class SwapView { async tapIUnderstandPriceWarning() { try { - await Gestures.waitAndTap(this.iUnderstandLabel); + await Gestures.waitAndTap(this.iUnderstandLabel, 5000); } catch (e) { // eslint-disable-next-line no-console console.log(`Price warning not displayed: ${e}`); diff --git a/e2e/utils/Gestures.js b/e2e/utils/Gestures.js index bcb9c3caca3..f5d5957fc34 100644 --- a/e2e/utils/Gestures.js +++ b/e2e/utils/Gestures.js @@ -51,9 +51,9 @@ class Gestures { * Wait for an element to be visible and then tap it. * * @param {Promise} elementID - ID of the element to tap - * @param {number} timeout - Timeout for waiting (default: 10000ms) + * @param {number} timeout - Timeout for waiting (default: 8000ms) */ - static async waitAndTap(elementID, timeout = 10000) { + static async waitAndTap(elementID, timeout = 15000) { const element = await elementID; await waitFor(element).toBeVisible().withTimeout(timeout); await element.tap(); @@ -132,7 +132,6 @@ class Gestures { static async swipe(elementID, direction, speed, percentage, xStart, yStart) { const element = await elementID; - await waitFor(element).toBeVisible(); await element.swipe(direction, speed, percentage, xStart, yStart); } From a9242c82c8b670f3eaf8b41360eeb8fbef9715c1 Mon Sep 17 00:00:00 2001 From: Davide Brocchetto Date: Tue, 3 Sep 2024 21:43:17 +0200 Subject: [PATCH 7/7] Removed Delay --- e2e/pages/swaps/SwapView.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e/pages/swaps/SwapView.js b/e2e/pages/swaps/SwapView.js index 019efbc6776..46abf95cb5b 100644 --- a/e2e/pages/swaps/SwapView.js +++ b/e2e/pages/swaps/SwapView.js @@ -5,7 +5,6 @@ import { import Matchers from '../../utils/Matchers'; import Gestures from '../../utils/Gestures'; -import TestHelpers from '../../helpers'; class SwapView { get quoteSummary() { @@ -42,7 +41,6 @@ class SwapView { // and that's when the swipe button becomes disabled // that's the need to retry await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); - await TestHelpers.delay(4000); await Gestures.swipe(this.swipeToSwapButton, 'right', 'fast', percentage); }