From aa910b1a1b684e5f5cee7dc5106937beb15e2520 Mon Sep 17 00:00:00 2001 From: mike10ca Date: Mon, 2 Dec 2024 15:52:56 +0100 Subject: [PATCH] Update twap tests --- cypress/e2e/pages/swaps.pages.js | 16 ++++++++++++++++ cypress/e2e/regression/twaps.cy.js | 15 +++++++++++---- cypress/e2e/regression/twaps_2.cy.js | 22 +++++++++++++++------- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/pages/swaps.pages.js b/cypress/e2e/pages/swaps.pages.js index 8707e5d35d..84b226c356 100644 --- a/cypress/e2e/pages/swaps.pages.js +++ b/cypress/e2e/pages/swaps.pages.js @@ -14,6 +14,7 @@ export const assetsSwapBtn = '[data-testid="swap-btn"]' export const dashboardSwapBtn = '[data-testid="overview-swap-btn"]' export const customRecipient = 'div[id="recipient"]' const recipientToggle = 'button[id="toggle-recipient-mode-button"]' +const twapsAddressToggle = '[class*="Toggle__Wrapper"]' const orderTypeMenuItem = 'div[class*="MenuItem"]' const explorerBtn = '[data-testid="explorer-btn"]' const limitPriceFld = '[data-testid="limit-price"]' @@ -27,6 +28,7 @@ const groupedItems = '[data-testid="grouped-items"]' const inputCurrencyPreview = '[id="input-currency-preview"]' const outputCurrencyPreview = '[id="output-currency-preview"]' const reviewTwapBtn = '[id="do-trade-button"]' +export const unlockOrdersBtn = '[id="unlock-advanced-orders-btn"]' const swapStrBtn = 'Swap' const twapStrBtn = 'TWAP' @@ -105,6 +107,15 @@ export const swapTxs = { '&id=multisig_0x03042B890b99552b60A073F808100517fb148F60_0x5f08e05edb210a8990791e9df2f287a5311a8137815ec85856a2477a36552f1e', } +export function unlockTwapOrders(iframeSelector) { + main.getIframeBody(iframeSelector).then(($iframeBody) => { + if ($iframeBody.find(unlockOrdersBtn).length > 0) { + cy.wrap($iframeBody).find(unlockOrdersBtn).click() + cy.wait(500) + } + }) +} + export function clickOnAssetSwapBtn(index) { cy.get(assetsSwapBtn).eq(index).as('btn') cy.get('@btn').click() @@ -267,6 +278,10 @@ export function enableCustomRecipient(option) { if (!option) cy.get(recipientToggle).click() } +export function enableTwapCustomRecipient() { + cy.get(twapsAddressToggle).click() +} + export function disableCustomRecipient(option) { if (option) cy.get(recipientToggle).click() } @@ -349,6 +364,7 @@ export function switchToTwap() { cy.get('a').contains(swapStrBtn).click() cy.wait(1000) cy.get('a').contains(twapStrBtn).click() + cy.wait(1000) } export function checkTokenBalanceAndValue(tokenDirection, balance, value) { diff --git a/cypress/e2e/regression/twaps.cy.js b/cypress/e2e/regression/twaps.cy.js index ee918f2776..5b283a8515 100644 --- a/cypress/e2e/regression/twaps.cy.js +++ b/cypress/e2e/regression/twaps.cy.js @@ -10,15 +10,13 @@ const signer = walletCredentials.OWNER_4_PRIVATE_KEY let staticSafes = [] let iframeSelector -// Blocked by a bug on UI -describe.skip('Twaps tests', { defaultCommandTimeout: 30000 }, () => { +describe('Twaps tests', { defaultCommandTimeout: 30000 }, () => { before(async () => { staticSafes = await getSafes(CATEGORIES.static) }) beforeEach(() => { cy.visit(constants.swapUrl + staticSafes.SEP_STATIC_SAFE_27) - main.waitForHistoryCallToComplete() wallet.connectSigner(signer) iframeSelector = `iframe[src*="${constants.swapWidget}"]` }) @@ -37,8 +35,12 @@ describe.skip('Twaps tests', { defaultCommandTimeout: 30000 }, () => { swaps.acceptLegalDisclaimer() cy.wait(4000) + main.getIframeBody(iframeSelector).within(() => { swaps.switchToTwap() + }) + swaps.unlockTwapOrders(iframeSelector) + main.getIframeBody(iframeSelector).within(() => { swaps.clickOnTokenSelctor('input') swaps.checkTokenList(tokens) }) @@ -51,7 +53,9 @@ describe.skip('Twaps tests', { defaultCommandTimeout: 30000 }, () => { cy.wait(4000) main.getIframeBody(iframeSelector).within(() => { swaps.switchToTwap() - + }) + swaps.unlockTwapOrders(iframeSelector) + main.getIframeBody(iframeSelector).within(() => { swaps.selectInputCurrency(swaps.swapTokens.cow) swaps.setInputValue(500) swaps.selectOutputCurrency(swaps.swapTokens.dai) @@ -64,6 +68,9 @@ describe.skip('Twaps tests', { defaultCommandTimeout: 30000 }, () => { cy.wait(4000) main.getIframeBody(iframeSelector).within(() => { swaps.switchToTwap() + }) + swaps.unlockTwapOrders(iframeSelector) + main.getIframeBody(iframeSelector).within(() => { swaps.selectInputCurrency(swaps.swapTokens.cow) swaps.clickOnMaxBtn() swaps.checkInputValue('input', '750') diff --git a/cypress/e2e/regression/twaps_2.cy.js b/cypress/e2e/regression/twaps_2.cy.js index 84f1399de1..c37923b049 100644 --- a/cypress/e2e/regression/twaps_2.cy.js +++ b/cypress/e2e/regression/twaps_2.cy.js @@ -10,8 +10,7 @@ const signer = walletCredentials.OWNER_4_PRIVATE_KEY let staticSafes = [] let iframeSelector -// Blocked by a bug on UI -describe.skip('Twaps 2 tests', { defaultCommandTimeout: 30000 }, () => { +describe('Twaps 2 tests', { defaultCommandTimeout: 30000 }, () => { before(async () => { staticSafes = await getSafes(CATEGORIES.static) }) @@ -32,6 +31,9 @@ describe.skip('Twaps 2 tests', { defaultCommandTimeout: 30000 }, () => { cy.wait(4000) main.getIframeBody(iframeSelector).within(() => { swaps.switchToTwap() + }) + swaps.unlockTwapOrders(iframeSelector) + main.getIframeBody(iframeSelector).within(() => { swaps.selectInputCurrency(swaps.swapTokens.cow) swaps.setInputValue(2000) swaps.selectOutputCurrency(swaps.swapTokens.dai) @@ -49,6 +51,9 @@ describe.skip('Twaps 2 tests', { defaultCommandTimeout: 30000 }, () => { cy.wait(4000) main.getIframeBody(iframeSelector).within(() => { swaps.switchToTwap() + }) + swaps.unlockTwapOrders(iframeSelector) + main.getIframeBody(iframeSelector).within(() => { swaps.selectInputCurrency(swaps.swapTokens.cow) swaps.setInputValue(100) swaps.selectOutputCurrency(swaps.swapTokens.dai) @@ -74,12 +79,15 @@ describe.skip('Twaps 2 tests', { defaultCommandTimeout: 30000 }, () => { }) .within(() => { swaps.switchToTwap() - swaps.selectInputCurrency(swaps.swapTokens.cow) - swaps.clickOnSettingsBtnTwaps() - swaps.enableCustomRecipient(isCustomRecipientFound(swaps.customRecipient)) - swaps.clickOnSettingsBtnTwaps() - swaps.enterRecipient(swaps.blockedAddress) }) + swaps.unlockTwapOrders(iframeSelector) + main.getIframeBody(iframeSelector).within(() => { + swaps.selectInputCurrency(swaps.swapTokens.cow) + swaps.clickOnSettingsBtnTwaps() + swaps.enableTwapCustomRecipient() + swaps.clickOnSettingsBtnTwaps() + swaps.enterRecipient(swaps.blockedAddress) + }) cy.contains(swaps.blockedAddressStr) }, )