Skip to content

Commit

Permalink
Tests: Update twap tests (#4590)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca authored Dec 2, 2024
1 parent 374f556 commit b30a74b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
16 changes: 16 additions & 0 deletions cypress/e2e/pages/swaps.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
Expand All @@ -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'
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 11 additions & 4 deletions cypress/e2e/regression/twaps.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]`
})
Expand All @@ -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)
})
Expand All @@ -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)
Expand All @@ -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')
Expand Down
22 changes: 15 additions & 7 deletions cypress/e2e/regression/twaps_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
},
)
Expand Down

0 comments on commit b30a74b

Please sign in to comment.