Skip to content

Commit

Permalink
Merge branch 'fix-kyberdao-approve-issue' of https://github.com/Kyber…
Browse files Browse the repository at this point in the history
…Network/kyberswap-interface into fix-kyberdao-approve-issue
  • Loading branch information
XiaoYhun committed Jul 20, 2023
2 parents 8da7407 + e918e1e commit 459d901
Show file tree
Hide file tree
Showing 12 changed files with 717 additions and 14 deletions.
58 changes: 58 additions & 0 deletions cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { tag } from '../../pages/swap-page.po.cy'
import { homePage, menu, network } from '../../selectors/selectors.cy'

const mainPage = 'swap/arbitrum'
describe('Intercept', { tags: tag.regression }, () => {
beforeEach(() => {
cy.visit('/' + mainPage)
cy.url().should('include', mainPage)
cy.clickButton(homePage.skipTutorial)
})
describe('Swap', () => {
it('Should get route successfully', () => {
cy.intercept('GET', '**/routes?**').as('get-route')
cy.wait('@get-route', { timeout: 20000 }).its('response.statusCode').should('be.oneOf', [200, 404, 408])
})
})

describe('Pools', () => {
it('Should get pool, farm list successfully', () => {
cy.intercept('GET', '**/farm-pools?**').as('get-farm-list')
cy.intercept('GET', '**/pools?**').as('get-pool-list')
cy.intercept('GET', '**/block?**').as('get-block')
cy.get(menu.earnMenu).click({ force: true })
cy.get(menu.poolMenu).click({ force: true })
cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-pool-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-block', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
})
})

describe('My Pools', () => {
it('Should get farm list successfully', () => {
cy.intercept('GET', '**/farm-pools?**').as('get-farm-list')
cy.get(menu.earnMenu).click({ force: true })
cy.get(menu.myPoolMenu).click({ force: true })
cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
})
})

describe('Farms', () => {
it('Should get pool, farm list successfully', () => {
cy.intercept('GET', '**/farm-pools?**').as('get-farm-list')
cy.intercept('GET', '**/pools?**').as('get-pool-list')
cy.intercept('GET', '**/block?**').as('get-block')
cy.get(menu.earnMenu).click({ force: true })
cy.get(menu.farmMenu).click({ force: true })
cy.get('[data-testid=farm-block]')
.should(_ => {})
.then($list => {
if ($list.length) {
cy.wait('@get-pool-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
}
cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-block', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
})
})
})
})
195 changes: 195 additions & 0 deletions cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
import { homePage, tab, token } from '../../selectors/selectors.cy'

const mainPage = 'swap/arbitrum'
const tokenSymbol = ['ARB', 'DAI', 'USDT', 'USDC.e']
const unListedToken = ['KNNC', 'KCCN']

const unWhiteListedToken = {
OHM: {
name: 'OHM',
address: '0xf0cb2dc0db5e6c66b9a70ac27b06b878da017028',
},
GBL: {
name: 'GBL',
address: '0xe9a264e9d45ff72e1b4a85d77643cdbd4c950207',
},
Y2K: {
name: 'Y2K',
address: '0x65c936f008bc34fe819bce9fa5afd9dc2d49977f',
},
}

describe('Token Catalog', { tags: 'regression' }, () => {
beforeEach(() => {
cy.visit('/' + mainPage)
cy.url().should('include', mainPage)
cy.clickButton(homePage.skipTutorial)
})
describe('Select token in favorite tokens list', () => {
it('Should be selected tokenIn in favorite tokens list successfully', () => {
cy.clickButton(token.tokenIn)
cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1])
cy.verifySelectedToken(token.tokenIn, tokenSymbol[1])
cy.verifyURL(tokenSymbol[1], '')
})

it('Should be selected tokenOut in favorite tokens list successfully', () => {
cy.clickButton(token.tokenOut)
cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1])
cy.verifySelectedToken(token.tokenOut, tokenSymbol[1])
cy.verifyURL('', tokenSymbol[1])
})
})

describe('Remove/add token with favorite tokens list', () => {
it('Should be removed tokenIn from favorite tokens list', () => {
cy.clickButton(token.tokenIn)
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], true)
cy.removeTokenInFavoriteTokensList(tokenSymbol[3])
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], false)
cy.input(token.inputToken, tokenSymbol[3])
cy.verifyIcon('false')
})

it('Should be added tokenIn to favorite tokens list', () => {
cy.clickButton(token.tokenIn)
cy.addTokenToFavoriteTokensList(tokenSymbol[0])
cy.verifyIcon('true')
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true)
})

it('Should be removed tokenOut from favorite tokens list', () => {
cy.clickButton(token.tokenOut)
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], true)
cy.removeTokenInFavoriteTokensList(tokenSymbol[2])
cy.wait(2000)
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], false)
cy.input(token.inputToken, tokenSymbol[2])
cy.verifyIcon('false')
})

it('Should be added tokenOut to favorite tokens list', () => {
cy.clickButton(token.tokenOut)
cy.addTokenToFavoriteTokensList(tokenSymbol[0])
cy.wait(2000)
cy.verifyIcon('true')
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true)
})
})

describe('Select token by symbol', () => {
it('Should be selected tokenIn by symbol successfully', () => {
cy.clickButton(token.tokenIn)
cy.selectTokenBySymbol(token.inputToken, tokenSymbol[0])
cy.verifySelectedToken(token.tokenIn, tokenSymbol[0])
cy.verifyURL(tokenSymbol[0], '')
})

it('Should be selected tokenOut by symbol successfully', () => {
cy.clickButton(token.tokenOut)
cy.selectTokenBySymbol(token.inputToken, tokenSymbol[1])
cy.verifySelectedToken(token.tokenOut, tokenSymbol[1])
cy.verifyURL('', tokenSymbol[1])
})

it('Should be unselected tokenIn not exist in whitelist', () => {
cy.clickButton(token.tokenIn)
cy.input(token.inputToken, unListedToken[0])
cy.verifyNoResultFound()
})

it('Should be unselected tokenOut not exist in whitelist', () => {
cy.clickButton(token.tokenOut)
cy.input(token.inputToken, unListedToken[1])
cy.verifyNoResultFound()
})
})

describe('Import token', () => {
it('Should be imported tokenIn successfully', () => {
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.OHM.address)
cy.verifySelectedToken(token.tokenIn, unWhiteListedToken.OHM.name)
cy.clickButton(token.tokenIn)
cy.clickButton(tab.import)
cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.OHM.name], true)
})

it('Should be imported tokenOut successfully', () => {
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.GBL.address)
cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.GBL.name)
cy.clickButton(token.tokenOut)
cy.clickButton(tab.import)
cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.GBL.name], true)
})
})

describe('Delete token', () => {
it('Should be deleted the imported tokenIn successfully', () => {
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.OHM.address)
cy.clickButton(token.tokenIn)
cy.clickButton(tab.import)
cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.OHM.name], true)
cy.deleteImportedToken(unWhiteListedToken.OHM.address)
cy.verifyNoResultFound()
})

it('Should be deleted the imported tokenOut successfully', () => {
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.OHM.address)
cy.clickButton(token.tokenOut)
cy.clickButton(tab.import)
cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.OHM.name], true)
cy.deleteImportedToken(unWhiteListedToken.OHM.address)
cy.verifyNoResultFound()
})

it('Should be cleared all the imported tokenIn successfully', () => {
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.OHM.address)
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.GBL.address)
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.Y2K.address)
cy.clickButton(token.tokenIn)
cy.clickButton(tab.import)
cy.verifyValueInList(
token.rowInWhiteList,
[unWhiteListedToken.OHM.name, unWhiteListedToken.GBL.name, unWhiteListedToken.Y2K.name],
true,
)
cy.clearAllImportedTokens()
cy.verifyNoResultFound()
})

it('Should be cleared all the imported tokenOut successfully', () => {
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.OHM.address)
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.GBL.address)
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.Y2K.address)
cy.clickButton(token.tokenOut)
cy.clickButton(tab.import)
cy.verifyValueInList(
token.rowInWhiteList,
[unWhiteListedToken.OHM.name, unWhiteListedToken.GBL.name, unWhiteListedToken.Y2K.name],
true,
)
cy.clearAllImportedTokens()
cy.verifyNoResultFound()
})
})

describe('E2E Token Catalog', () => {
it('Should be selected tokenIn and tokenOut to swap', () => {
//select tokenIn
cy.clickButton(token.tokenIn)
cy.selectTokenInFavoriteTokensList(token.favoriteToken, tokenSymbol[1])
cy.verifySelectedToken(token.tokenIn, tokenSymbol[1])
//select tokenOut
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.OHM.address)
cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.OHM.name)
cy.verifyURL(tokenSymbol[1], unWhiteListedToken.OHM.name)
//delete imported tokenOut
cy.clickButton(token.tokenOut)
cy.clickButton(tab.import)
cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.OHM.name], true)
cy.deleteImportedToken(unWhiteListedToken.OHM.address)
cy.verifyNoResultFound()
cy.get(token.tokenOut).should('include.text', 'Select a token')
})
})
})
22 changes: 12 additions & 10 deletions cypress/e2e/specs/ethereum/swap-page.e2e-spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const unWhiteListedToken = {
name: 'SCOOBY',
address: '0xAd497eE6a70aCcC3Cbb5eB874e60d87593B86F2F',
},
TUSD: {
name: 'TUSD',
address: '0x0000000000085d4780b73119b644ae5ecd22b376',
UNIBOT: {
name: 'UNIBOT',
address: '0x25127685dc35d4dc96c7feac7370749d004c5040',
},
BGB: {
name: 'BGB',
Expand Down Expand Up @@ -46,6 +46,7 @@ describe('Token Catalog', () => {
cy.clickButton(token.tokenIn)
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], true)
cy.removeTokenInFavoriteTokensList(tokenSymbol[3])
cy.wait(2000)
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[3]], false)
cy.input(token.inputToken, tokenSymbol[3])
cy.verifyIcon('false')
Expand All @@ -62,6 +63,7 @@ describe('Token Catalog', () => {
cy.clickButton(token.tokenOut)
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], true)
cy.removeTokenInFavoriteTokensList(tokenSymbol[2])
cy.wait(2000)
cy.verifyValueInList(token.favoriteToken, [tokenSymbol[2]], false)
cy.input(token.inputToken, tokenSymbol[2])
cy.verifyIcon('false')
Expand Down Expand Up @@ -113,11 +115,11 @@ describe('Token Catalog', () => {
})

it('Should be imported tokenOut successfully', { tags: 'regression' }, () => {
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.TUSD.address)
cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.TUSD.name)
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.UNIBOT.address)
cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.UNIBOT.name)
cy.clickButton(token.tokenOut)
cy.clickButton(tab.import)
cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.TUSD.name], true)
cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.UNIBOT.name], true)
})
})

Expand All @@ -143,12 +145,12 @@ describe('Token Catalog', () => {
it('Should be cleared all the imported tokenIn successfully', { tags: 'regression' }, () => {
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.SCOOBY.address)
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.BGB.address)
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.TUSD.address)
cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.UNIBOT.address)
cy.clickButton(token.tokenIn)
cy.clickButton(tab.import)
cy.verifyValueInList(
token.rowInWhiteList,
[unWhiteListedToken.SCOOBY.name, unWhiteListedToken.BGB.name, unWhiteListedToken.TUSD.name],
[unWhiteListedToken.SCOOBY.name, unWhiteListedToken.BGB.name, unWhiteListedToken.UNIBOT.name],
true,
)
cy.clearAllImportedTokens()
Expand All @@ -158,12 +160,12 @@ describe('Token Catalog', () => {
it('Should be cleared all the imported tokenOut successfully', { tags: 'regression' }, () => {
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.SCOOBY.address)
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.BGB.address)
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.TUSD.address)
cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.UNIBOT.address)
cy.clickButton(token.tokenOut)
cy.clickButton(tab.import)
cy.verifyValueInList(
token.rowInWhiteList,
[unWhiteListedToken.SCOOBY.name, unWhiteListedToken.BGB.name, unWhiteListedToken.TUSD.name],
[unWhiteListedToken.SCOOBY.name, unWhiteListedToken.BGB.name, unWhiteListedToken.UNIBOT.name],
true,
)
cy.clearAllImportedTokens()
Expand Down
58 changes: 58 additions & 0 deletions cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { tag } from '../../pages/swap-page.po.cy'
import { homePage, menu, network } from '../../selectors/selectors.cy'

const mainPage = 'swap/optimism'
describe('Intercept', { tags: tag.regression }, () => {
beforeEach(() => {
cy.visit('/' + mainPage)
cy.url().should('include', mainPage)
cy.clickButton(homePage.skipTutorial)
})
describe('Swap', { tags: tag.smoke }, () => {
it('Should get route successfully', () => {
cy.intercept('GET', '**/routes?**').as('get-route')
cy.wait('@get-route', { timeout: 20000 }).its('response.statusCode').should('be.oneOf', [200, 404, 408])
})
})

describe('Pools', () => {
it('Should get pool, farm list successfully', () => {
cy.intercept('GET', '**/farm-pools?**').as('get-farm-list')
cy.intercept('GET', '**/pools?**').as('get-pool-list')
cy.intercept('GET', '**/block?**').as('get-block')
cy.get(menu.earnMenu).click({ force: true })
cy.get(menu.poolMenu).click({ force: true })
cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-pool-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-block', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
})
})

describe('My Pools', () => {
it('Should get farm list successfully', () => {
cy.intercept('GET', '**/farm-pools?**').as('get-farm-list')
cy.get(menu.earnMenu).click({ force: true })
cy.get(menu.myPoolMenu).click({ force: true })
cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
})
})

describe('Farms', () => {
it('Should get pool, farm list successfully', () => {
cy.intercept('GET', '**/farm-pools?**').as('get-farm-list')
cy.intercept('GET', '**/pools?**').as('get-pool-list')
cy.intercept('GET', '**/block?**').as('get-block')
cy.get(menu.earnMenu).click({ force: true })
cy.get(menu.farmMenu).click({ force: true })
cy.get('[data-testid=farm-block]')
.should(_ => {})
.then($list => {
if ($list.length) {
cy.wait('@get-pool-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
}
cy.wait('@get-farm-list', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
cy.wait('@get-block', { timeout: 5000 }).its('response.statusCode').should('equal', 200)
})
})
})
})
Loading

0 comments on commit 459d901

Please sign in to comment.