-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
404 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
import * as constants from '../../support/constants.js' | ||
import * as main from '../pages/main.page.js' | ||
|
||
// Incoming from CowSwap | ||
export const inputCurrencyInput = '[id="input-currency-input"]' | ||
export const outputurrencyInput = '[id="output-currency-input"]' | ||
const tokenList = '[id="tokens-list"]' | ||
export const swapBtn = '[id="swap-button"]' | ||
const exceedFeesChkbox = 'input[id="fees-exceed-checkbox"]' | ||
const settingsBtn = 'button[id="open-settings-dialog-button"]' | ||
export const assetsSwapBtn = '[data-testid="swap-btn"]' | ||
export const dashboardSwapBtn = '[data-testid="overview-swap-btn"]' | ||
const confirmSwapStr = 'Confirm Swap' | ||
const swapBtnStr = /Confirm Swap|Swap|Confirm (Approve COW and Swap)|Confirm/ | ||
const orderSubmittedStr = 'Order Submitted' | ||
|
||
export const swapTokens = { | ||
cow: 'COW', | ||
dai: 'DAI', | ||
eth: 'ETH', | ||
} | ||
|
||
const swapOrders = '**/api/v1/orders/*' | ||
const surplus = '**/users/*/total_surplus' | ||
const nativePrice = '**/native_price' | ||
const quote = '**/quote/*' | ||
|
||
export function clickOnAssetSwapBtn(index) { | ||
cy.get(assetsSwapBtn).eq(index).as('btn') | ||
cy.get('@btn').click() | ||
} | ||
|
||
export function verifyOrderSubmittedConfirmation() { | ||
cy.get('div').contains(orderSubmittedStr).should('exist') | ||
} | ||
|
||
export function clickOnSettingsBtn() { | ||
cy.get(settingsBtn).click() | ||
} | ||
|
||
export function setExpiry(value) { | ||
cy.get('div').contains('Swap deadline').parent().next().find('input').clear().type(value) | ||
} | ||
|
||
export function setSlippage(value) { | ||
cy.contains('button', 'Auto').next('button').find('input').clear().type(value) | ||
} | ||
export function waitForOrdersCallToComplete() { | ||
cy.intercept('GET', swapOrders).as('Orders') | ||
cy.wait('@Orders') | ||
} | ||
|
||
export function waitForSurplusCallToComplete() { | ||
cy.intercept('GET', surplus).as('Surplus') | ||
cy.wait('@Surplus') | ||
} | ||
|
||
export function waitFornativePriceCallToComplete() { | ||
cy.intercept('GET', nativePrice).as('Price') | ||
cy.wait('@Price') | ||
} | ||
|
||
export function waitForQuoteCallToComplete() { | ||
cy.intercept('GET', quote).as('Quote') | ||
cy.wait('@Quote') | ||
} | ||
|
||
export function clickOnConfirmSwapBtn() { | ||
cy.get('button').contains(confirmSwapStr).click() | ||
} | ||
|
||
export function clickOnExceeFeeChkbox() { | ||
cy.wait(1000) | ||
cy.get(exceedFeesChkbox) | ||
.should(() => {}) | ||
.then(($button) => { | ||
if (!$button.length) { | ||
return | ||
} | ||
cy.wrap($button).click() | ||
}) | ||
} | ||
|
||
export function clickOnSwapBtn() { | ||
cy.get('button').contains(swapBtnStr).as('swapBtn') | ||
|
||
cy.get('@swapBtn').should('exist').click() | ||
} | ||
|
||
export function checkSwapBtnIsVisible() { | ||
cy.get('button').contains(swapBtnStr).should('be.visible') | ||
} | ||
|
||
export const currencyDirectionOptions = { | ||
input: 'input', | ||
output: 'output', | ||
} | ||
|
||
export function acceptLegalDisclaimer() { | ||
cy.get('button').contains('Continue').click() | ||
} | ||
|
||
export function checkTokenBalance(safe, tokenSymbol) { | ||
cy.get(inputCurrencyInput) | ||
.invoke('text') | ||
.then((text) => { | ||
main.getSafeBalance(safe, constants.networkKeys.sepolia).then((response) => { | ||
const targetToken = response.body.items.find((token) => token.tokenInfo.symbol === tokenSymbol) | ||
const tokenBalance = targetToken.balance.toString() | ||
let formattedBalance | ||
|
||
if (tokenBalance.length > 4) { | ||
formattedBalance = `${tokenBalance[0]},${tokenBalance.slice(1, 4)}` | ||
} else { | ||
formattedBalance = tokenBalance | ||
} | ||
|
||
expect(text).to.include(`${formattedBalance} ${tokenSymbol}`) | ||
}) | ||
}) | ||
} | ||
|
||
export function verifySelectedInputCurrancy(option) { | ||
cy.get(inputCurrencyInput).within(() => { | ||
cy.get('span').contains(option).should('be.visible') | ||
}) | ||
} | ||
export function selectInputCurrency(option) { | ||
cy.get(inputCurrencyInput).within(() => { | ||
cy.get('button').trigger('mouseover').trigger('click') | ||
}) | ||
cy.get(tokenList).find('span').contains(option).click() | ||
} | ||
|
||
export function selectOutputCurrency(option) { | ||
cy.get(outputurrencyInput).within(() => { | ||
cy.get('button').trigger('mouseover').trigger('click') | ||
}) | ||
cy.get(tokenList).find('span').contains(option).click() | ||
} | ||
|
||
export function setInputValue(value) { | ||
cy.get(inputCurrencyInput).within(() => { | ||
cy.get('input').type(value) | ||
}) | ||
} | ||
|
||
export function setOutputValue(value) { | ||
cy.get(outputurrencyInput).within(() => { | ||
cy.get('input').type(value) | ||
}) | ||
} | ||
|
||
export function isInputGreaterZero(inputSelector) { | ||
return cy | ||
.get(inputSelector) | ||
.find('input') | ||
.invoke('val') | ||
.then((val) => { | ||
const n = parseFloat(val) | ||
return n > 0 | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as constants from '../../support/constants.js' | ||
import * as main from '../pages/main.page.js' | ||
import * as swaps from '../pages/swaps.pages.js' | ||
import * as tx from '../pages/transactions.page.js' | ||
import * as create_tx from '../pages/create_tx.pages.js' | ||
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js' | ||
import * as owner from '../pages/owners.pages' | ||
|
||
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS')) | ||
const signer = walletCredentials.OWNER_4_PRIVATE_KEY | ||
let staticSafes = [] | ||
|
||
let iframeSelector | ||
|
||
describe('Swaps tests', () => { | ||
before(async () => { | ||
staticSafes = await getSafes(CATEGORIES.static) | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.clearLocalStorage() | ||
cy.visit(constants.swapUrl + staticSafes.SEP_STATIC_SAFE_1) | ||
main.acceptCookies() | ||
iframeSelector = `iframe[src*="${constants.swapWidget}"]` | ||
}) | ||
|
||
// TODO: Waiting for signer connection issue be resolved | ||
it.skip('Verify an order can be created, signed and appear in tx queue', { defaultCommandTimeout: 30000 }, () => { | ||
swaps.acceptLegalDisclaimer() | ||
swaps.waitForOrdersCallToComplete() | ||
cy.wait(2000) | ||
main.getIframeBody(iframeSelector).within(() => { | ||
swaps.clickOnSettingsBtn() | ||
swaps.setSlippage('0.30') | ||
swaps.setExpiry('2') | ||
swaps.clickOnSettingsBtn() | ||
swaps.selectInputCurrency(swaps.swapTokens.cow) | ||
swaps.checkTokenBalance(staticSafes.SEP_STATIC_SAFE_1.substring(4), swaps.swapTokens.cow) | ||
swaps.setInputValue(4) | ||
swaps.selectOutputCurrency(swaps.swapTokens.dai) | ||
swaps.checkSwapBtnIsVisible() | ||
swaps.isInputGreaterZero(swaps.outputurrencyInput).then((isGreaterThanZero) => { | ||
cy.wrap(isGreaterThanZero).should('be.true') | ||
}) | ||
swaps.clickOnExceeFeeChkbox() | ||
swaps.clickOnSwapBtn() | ||
swaps.clickOnSwapBtn() | ||
}) | ||
create_tx.changeNonce(12) | ||
tx.selectExecuteLater() | ||
cy.wait(1000) | ||
|
||
create_tx.clickOnSignTransactionBtn() | ||
main.getIframeBody(iframeSelector).within(() => { | ||
swaps.verifyOrderSubmittedConfirmation() | ||
}) | ||
cy.visit(constants.transactionQueueUrl + staticSafes.SEP_STATIC_SAFE_1) | ||
main.verifyElementsCount(create_tx.transactionItem, 1) | ||
create_tx.verifySummaryByName(swapsQueue.contractName, [swapsQueue.action, swapsQueue.oneOfOne]) | ||
cy.visit(constants.transactionQueueUrl + staticSafes.SEP_STATIC_SAFE_1) | ||
owner.waitForConnectionStatus() | ||
main.acceptCookies() | ||
// main.connectSigner(signer) | ||
create_tx.clickOnTransactionItem(0) | ||
create_tx.deleteTx() | ||
main.verifyElementsCount(create_tx.transactionItem, 0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as constants from '../../support/constants.js' | ||
import * as main from '../pages/main.page.js' | ||
import * as create_tx from '../pages/create_tx.pages.js' | ||
import * as swaps_data from '../../fixtures/swaps_data.json' | ||
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js' | ||
|
||
let staticSafes = [] | ||
|
||
const swapsHistory = swaps_data.type.history | ||
const limitOrder = | ||
'&id=multisig_0x8f4A19C85b39032A37f7a6dCc65234f966F72551_0x3faf510142c9ade7ac2a701fb697b95f321fd51f5eb9b17e7e534a8abe472b07' | ||
const limitOrderSafe = 'sep:0x8f4A19C85b39032A37f7a6dCc65234f966F72551' | ||
|
||
describe('[SMOKE] Swaps history tests', () => { | ||
before(async () => { | ||
staticSafes = await getSafes(CATEGORIES.static) | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.clearLocalStorage() | ||
cy.visit(constants.transactionsHistoryUrl + staticSafes.SEP_STATIC_SAFE_1) | ||
main.acceptCookies() | ||
}) | ||
|
||
it('Verify operation names are correct for buying and selling of tokens', { defaultCommandTimeout: 30000 }, () => { | ||
create_tx.clickOnTransactionItemByName('8:05 AM') | ||
create_tx.verifyExpandedDetails([ | ||
swapsHistory.buyOrder, | ||
swapsHistory.buy, | ||
swapsHistory.oneGNO, | ||
swapsHistory.forAtMost, | ||
swapsHistory.cow, | ||
swapsHistory.expired, | ||
swapsHistory.actionApprove, | ||
swapsHistory.actionPreSignature, | ||
]) | ||
cy.reload() | ||
|
||
create_tx.clickOnTransactionItemByName('11:14 AM') | ||
create_tx.verifyExpandedDetails([ | ||
swapsHistory.sellOrder, | ||
swapsHistory.sell, | ||
swapsHistory.oneCOW, | ||
swapsHistory.forAtLeast, | ||
swapsHistory.dai, | ||
swapsHistory.filled, | ||
swapsHistory.actionApprove, | ||
swapsHistory.actionPreSignature, | ||
]) | ||
}) | ||
|
||
it('Verify "Partially filled" field is displayed in limit order', () => { | ||
cy.visit(constants.transactionUrl + limitOrderSafe + limitOrder) | ||
create_tx.verifyExpandedDetails([swapsHistory.partiallyFilled]) | ||
}) | ||
}) |
Oops, something went wrong.