mirror of
https://github.com/luxfi/safe-wallet.git
synced 2026-10-30 15:19:21 +00:00
* fix(e2e): fix wait for history * fix(e2e): fixQR code element position in sidebar
87 lines
3.1 KiB
JavaScript
87 lines
3.1 KiB
JavaScript
import * as constants from '../../support/constants.js'
|
|
import * as main from '../pages/main.page.js'
|
|
import * as swaps from '../pages/swaps.pages.js'
|
|
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
|
|
import * as wallet from '../../support/utils/wallet.js'
|
|
|
|
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
|
|
const signer = walletCredentials.OWNER_4_PRIVATE_KEY
|
|
|
|
let staticSafes = []
|
|
let iframeSelector
|
|
|
|
describe('Swaps 2 tests', () => {
|
|
before(async () => {
|
|
staticSafes = await getSafes(CATEGORIES.static)
|
|
})
|
|
|
|
beforeEach(() => {
|
|
cy.intercept('GET', constants.transactionHistoryEndpoint).as('History')
|
|
cy.visit(constants.swapUrl + staticSafes.SEP_STATIC_SAFE_1)
|
|
cy.wait('@History', { timeout: 20000 })
|
|
wallet.connectSigner(signer)
|
|
iframeSelector = `iframe[src*="${constants.swapWidget}"]`
|
|
})
|
|
|
|
it.skip(
|
|
'Verify Setting the top token first in a swap creates a "Sell order" tx',
|
|
{ defaultCommandTimeout: 30000 },
|
|
() => {
|
|
const value = '200 COW'
|
|
swaps.getMockQuoteResponse(swaps.quoteResponse.quote1)
|
|
swaps.acceptLegalDisclaimer()
|
|
cy.wait(4000)
|
|
main.getIframeBody(iframeSelector).within(() => {
|
|
swaps.selectInputCurrency(swaps.swapTokens.cow)
|
|
swaps.setInputValue(200)
|
|
|
|
swaps.selectOutputCurrency(swaps.swapTokens.dai)
|
|
cy.wait('@mockedQuote').then((interception) => {
|
|
expect(interception.response.statusCode).to.eq(200)
|
|
cy.log('Intercepted response:', JSON.stringify(interception.response.body))
|
|
})
|
|
swaps.checkSwapBtnIsVisible()
|
|
swaps.isInputGreaterZero(swaps.outputCurrencyInput).then((isGreaterThanZero) => {
|
|
cy.wrap(isGreaterThanZero).should('be.true')
|
|
})
|
|
swaps.clickOnExceeFeeChkbox()
|
|
swaps.clickOnSwapBtn()
|
|
swaps.checkInputCurrencyPreviewValue(value)
|
|
swaps.clickOnSwapBtn()
|
|
})
|
|
swaps.checkTokenBlockValue(0, value)
|
|
},
|
|
)
|
|
|
|
it.skip(
|
|
'Verify Setting the bottom token first in a swap creates a "Buy order" tx',
|
|
{ defaultCommandTimeout: 30000 },
|
|
() => {
|
|
const value = swaps.getTokenValue()
|
|
const tokenValue = '600'
|
|
swaps.getMockQuoteResponse(swaps.quoteResponse.quote2)
|
|
swaps.acceptLegalDisclaimer()
|
|
cy.wait(4000)
|
|
main.getIframeBody(iframeSelector).within(() => {
|
|
swaps.selectOutputCurrency(swaps.swapTokens.dai)
|
|
swaps.setOutputValue(tokenValue)
|
|
swaps.selectInputCurrency(swaps.swapTokens.cow)
|
|
cy.wait('@mockedQuote').then((interception) => {
|
|
expect(interception.response.statusCode).to.eq(200)
|
|
cy.log('Intercepted response:', JSON.stringify(interception.response.body))
|
|
})
|
|
swaps.checkSwapBtnIsVisible()
|
|
swaps.isInputGreaterZero(swaps.outputCurrencyInput).then((isGreaterThanZero) => {
|
|
cy.wrap(isGreaterThanZero).should('be.true')
|
|
})
|
|
|
|
swaps.clickOnSwapBtn()
|
|
swaps.checkOutputCurrencyPreviewValue(value)
|
|
swaps.clickOnSwapBtn()
|
|
swaps.confirmPriceImpact()
|
|
})
|
|
swaps.checkTokenBlockValue(1, tokenValue)
|
|
},
|
|
)
|
|
})
|