From beb350eeb866c8a71a3e8d2c67afa94a1b0b8177 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Wed, 19 Jul 2023 16:19:10 +0700 Subject: [PATCH 1/4] fix: gas refund pending timer (#2084) --- src/pages/KyberDAO/KNCUtility/GasRefundBox.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/KyberDAO/KNCUtility/GasRefundBox.tsx b/src/pages/KyberDAO/KNCUtility/GasRefundBox.tsx index a7aa37f75d..60c820484a 100644 --- a/src/pages/KyberDAO/KNCUtility/GasRefundBox.tsx +++ b/src/pages/KyberDAO/KNCUtility/GasRefundBox.tsx @@ -94,7 +94,6 @@ export default function GasRefundBox() { const { userTier, gasRefundPerCentage } = useGasRefundTier() const { daoInfo: { first_epoch_start_timestamp = 0, current_epoch = 0, epoch_period_in_seconds = 0 } = {} } = useVotingInfo() - const claimRewards = useCallback(async () => { if (!account || !library || !claimableReward || claimableReward.knc <= 0) return @@ -268,7 +267,7 @@ export default function GasRefundBox() { Available to claim in{' '} From 4e35d00b20a664883c6f5e9da611185633f446f3 Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Wed, 19 Jul 2023 16:24:38 +0700 Subject: [PATCH 2/4] UI for feedback survey kyberAI (#2082) * UI for feedback survey kyberAI * chore * chore * add to single page * fix comments and add end timestamp * fix typo * fix warning --- .../TrueSightV2/components/FeedbackSurvey.tsx | 183 ++++++++++++++++++ src/pages/TrueSightV2/pages/SingleToken.tsx | 2 + .../TrueSightV2/pages/TokenAnalysisList.tsx | 2 + src/pages/TrueSightV2/types/index.tsx | 2 + src/state/user/hooks.tsx | 9 +- 5 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 src/pages/TrueSightV2/components/FeedbackSurvey.tsx diff --git a/src/pages/TrueSightV2/components/FeedbackSurvey.tsx b/src/pages/TrueSightV2/components/FeedbackSurvey.tsx new file mode 100644 index 0000000000..71ba6725d6 --- /dev/null +++ b/src/pages/TrueSightV2/components/FeedbackSurvey.tsx @@ -0,0 +1,183 @@ +import { Trans } from '@lingui/macro' +import { useLocalStorage } from '@solana/wallet-adapter-react' +import { useEffect, useMemo, useState } from 'react' +import { X } from 'react-feather' +import { Text } from 'rebass' +import styled, { css } from 'styled-components' + +import { ButtonOutlined, ButtonPrimary } from 'components/Button' +import Modal from 'components/Modal' +import { RowBetween, RowFit } from 'components/Row' +import useTheme from 'hooks/useTheme' +import { useGetParticipantKyberAIInfo } from 'state/user/hooks' + +import { ParticipantStatus } from '../types' + +const Wrapper = styled.div` + width: min(95vw, 480px); + border-radius: 20px; + padding: 20px; + display: flex; + gap: 20px; + flex-direction: column; + b { + color: ${({ theme }) => theme.text}; + } +` + +const WidgetWrapper = styled.div<{ show?: boolean }>` + position: fixed; + right: 0; + top: 310px; + transition: filter 0.1s ease-out, right 1s ease-out, visibility 1s; + z-index: 20; + transform-origin: 100% 100%; + transform: rotate(-90deg); + border-radius: 8px 8px 0px 0px; + background: ${({ theme }) => theme.primary + '32'}; + padding: 4px 8px; + color: ${({ theme }) => theme.primary}; + cursor: pointer; + ${({ show }) => + !show && + css` + right: -25px; + visibility: hidden; + `}; + + :hover { + filter: brightness(1.2); + } +` + +const XWrapper = styled.span` + padding: 2px; + border-radius: 50%; + transition: all 0.1s; + svg { + display: block; + } + :hover { + background-color: ${({ theme }) => theme.primary + '36'}; + } +` + +const LOCALSTORAGE_MODAL_SHOWED = 'showedKyberAIFeedbackSurvey' +const LOCALSTORAGE_WIDGET_SHOWED = 'showedKyberAIFeedbackSurveyWidget' +const MOMENT_THIS_SURVEY_RELEASE = 1689768000 +const END_DATE = 1691020800000 // Aug 3 + +export default function FeedbackSurvey() { + const [isOpen, setIsOpen] = useState(false) + const [isOpenWidget, setIsOpenWidget] = useState(false) + const theme = useTheme() + const { updatedAt, status } = useGetParticipantKyberAIInfo() + const [isShowModalLS, setIsShowModalLS] = useLocalStorage(LOCALSTORAGE_MODAL_SHOWED, undefined) + const [isShowWidgetLS, setIsShowWidgetLS] = useLocalStorage(LOCALSTORAGE_WIDGET_SHOWED, undefined) + + const isValid = useMemo( + () => updatedAt < MOMENT_THIS_SURVEY_RELEASE && status === ParticipantStatus.WHITELISTED && Date.now() < END_DATE, + [updatedAt, status], + ) + + useEffect(() => { + if (!isValid) return + if (!isShowModalLS) { + setIsOpen(true) + setIsShowModalLS('1') + } + if (!isShowWidgetLS) { + setIsOpenWidget(true) + } + }, [isValid, isShowModalLS, isShowWidgetLS, setIsShowModalLS]) + + if (!isValid) return null + + return ( + <> + + + + + KyberAI Feedback Survey + +
setIsOpen(false)} style={{ cursor: 'pointer' }}> + +
+
+ + + Hey KyberAI Beta Users,
+
+ Your feedback is vital to us! Help shape the future of KyberAI by completing our short Beta + Feedback Survey{' '} + + here + + . Your input will help us meet your trading needs better!
+
+ As a token of appreciation, we will distribute a total of 400 KNC among the top 20 feedback + respondents +
+
+ + setIsOpen(false)}> + Maybe later + + + window.open( + 'https://docs.google.com/forms/d/e/1FAIpQLSebHPpIP0mqtMb57v3N3rmUCzo87ur86ruTF5QchJiJ2sRmfw/viewform?pli=1', + '_blank', + ) + } + > + Fill survey + + +
+
+ { + window.open( + 'https://docs.google.com/forms/d/e/1FAIpQLSebHPpIP0mqtMb57v3N3rmUCzo87ur86ruTF5QchJiJ2sRmfw/viewform?pli=1', + '_blank', + ) + setIsShowWidgetLS('1') + }} + > + + + + + + + + + + + + + Feedback + + { + e.stopPropagation() + setIsOpenWidget(false) + }} + > + + + + + + ) +} diff --git a/src/pages/TrueSightV2/pages/SingleToken.tsx b/src/pages/TrueSightV2/pages/SingleToken.tsx index 0983ba6314..03ce90efa1 100644 --- a/src/pages/TrueSightV2/pages/SingleToken.tsx +++ b/src/pages/TrueSightV2/pages/SingleToken.tsx @@ -20,6 +20,7 @@ import { PROFILE_MANAGE_ROUTES } from 'pages/NotificationCenter/const' import { MEDIA_WIDTHS } from 'theme' import DisplaySettings from '../components/DisplaySettings' +import FeedbackSurvey from '../components/FeedbackSurvey' import KyberAIShareModal from '../components/KyberAIShareModal' import SimpleTooltip from '../components/SimpleTooltip' import { TokenOverview } from '../components/TokenOverview' @@ -612,6 +613,7 @@ export default function SingleToken() { }) } /> + ) } diff --git a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx index 4e3fe387b7..721a2ef413 100644 --- a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx +++ b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx @@ -27,6 +27,7 @@ import useTheme from 'hooks/useTheme' import { MEDIA_WIDTHS } from 'theme' import ChevronIcon from '../components/ChevronIcon' +import FeedbackSurvey from '../components/FeedbackSurvey' import KyberAIShareModal from '../components/KyberAIShareModal' import MultipleChainDropdown from '../components/MultipleChainDropdown' import NetworkSelect from '../components/NetworkSelect' @@ -1102,6 +1103,7 @@ export default function TokenAnalysisList() { }) } /> + ) } diff --git a/src/pages/TrueSightV2/types/index.tsx b/src/pages/TrueSightV2/types/index.tsx index 38a08251bf..613101d388 100644 --- a/src/pages/TrueSightV2/types/index.tsx +++ b/src/pages/TrueSightV2/types/index.tsx @@ -197,6 +197,8 @@ export type ParticipantInfo = { referralCode: string status: ParticipantStatus rankNo: number + updatedAt: number + createdAt: number } export enum KyberAIListType { diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx index ff1dac0025..3d0a9d3ff1 100644 --- a/src/state/user/hooks.tsx +++ b/src/state/user/hooks.tsx @@ -497,7 +497,14 @@ export const useSlippageSettingByPage = (isCrossChain = false) => { return { setRawSlippage, rawSlippage, isSlippageControlPinned, togglePinSlippage } } -const participantDefault = { rankNo: 0, status: ParticipantStatus.UNKNOWN, referralCode: '', id: 0 } +const participantDefault = { + rankNo: 0, + status: ParticipantStatus.UNKNOWN, + referralCode: '', + id: 0, + updatedAt: 0, + createdAt: 0, +} export const useGetParticipantKyberAIInfo = (): ParticipantInfo => { const { userInfo } = useSessionInfo() const { data: data = participantDefault, isError } = useGetParticipantInfoQuery(undefined, { From 4d5e10b723ea8647abeaf089c0120a9adce7cb10 Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Wed, 19 Jul 2023 17:51:16 +0700 Subject: [PATCH 3/4] hotfix wrong click tracking (#2086) --- src/pages/TrueSightV2/components/FeedbackSurvey.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/TrueSightV2/components/FeedbackSurvey.tsx b/src/pages/TrueSightV2/components/FeedbackSurvey.tsx index 71ba6725d6..712e5598e0 100644 --- a/src/pages/TrueSightV2/components/FeedbackSurvey.tsx +++ b/src/pages/TrueSightV2/components/FeedbackSurvey.tsx @@ -148,7 +148,6 @@ export default function FeedbackSurvey() { 'https://docs.google.com/forms/d/e/1FAIpQLSebHPpIP0mqtMb57v3N3rmUCzo87ur86ruTF5QchJiJ2sRmfw/viewform?pli=1', '_blank', ) - setIsShowWidgetLS('1') }} > @@ -172,6 +171,7 @@ export default function FeedbackSurvey() { onClick={e => { e.stopPropagation() setIsOpenWidget(false) + setIsShowWidgetLS('1') }} > From c479a4e5a243ca652ab1510f5e7f2e3857ce9871 Mon Sep 17 00:00:00 2001 From: ltthienn <132639843+ltthienn@users.noreply.github.com> Date: Thu, 20 Jul 2023 09:41:18 +0700 Subject: [PATCH 4/4] [QA-36] | Add existing tests for other chains Add existing tests for other chains: Arbitrum, Optimism --- .../specs/arbitrum/intercept.e2e-spec.cy.ts | 58 ++++++ .../specs/arbitrum/swap-page.e2e-spec.cy.ts | 195 ++++++++++++++++++ .../specs/ethereum/swap-page.e2e-spec.cy.ts | 22 +- .../specs/optimism/intercept.e2e-spec.cy.ts | 58 ++++++ .../specs/optimism/swap-page.e2e-spec.cy.ts | 195 ++++++++++++++++++ cypress/support/selectTokenCommands.ts | 2 +- 6 files changed, 519 insertions(+), 11 deletions(-) create mode 100644 cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts create mode 100644 cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts create mode 100644 cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts create mode 100644 cypress/e2e/specs/optimism/swap-page.e2e-spec.cy.ts diff --git a/cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts b/cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts new file mode 100644 index 0000000000..010a76d894 --- /dev/null +++ b/cypress/e2e/specs/arbitrum/intercept.e2e-spec.cy.ts @@ -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) + }) + }) + }) +}) diff --git a/cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts b/cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts new file mode 100644 index 0000000000..9d223919ee --- /dev/null +++ b/cypress/e2e/specs/arbitrum/swap-page.e2e-spec.cy.ts @@ -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') + }) + }) +}) diff --git a/cypress/e2e/specs/ethereum/swap-page.e2e-spec.cy.ts b/cypress/e2e/specs/ethereum/swap-page.e2e-spec.cy.ts index 49554891ed..bbb3cf8b19 100644 --- a/cypress/e2e/specs/ethereum/swap-page.e2e-spec.cy.ts +++ b/cypress/e2e/specs/ethereum/swap-page.e2e-spec.cy.ts @@ -9,9 +9,9 @@ const unWhiteListedToken = { name: 'SCOOBY', address: '0xAd497eE6a70aCcC3Cbb5eB874e60d87593B86F2F', }, - TUSD: { - name: 'TUSD', - address: '0x0000000000085d4780b73119b644ae5ecd22b376', + UNIBOT: { + name: 'UNIBOT', + address: '0x25127685dc35d4dc96c7feac7370749d004c5040', }, BGB: { name: 'BGB', @@ -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') @@ -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') @@ -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) }) }) @@ -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() @@ -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() diff --git a/cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts b/cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts new file mode 100644 index 0000000000..35725f3ba8 --- /dev/null +++ b/cypress/e2e/specs/optimism/intercept.e2e-spec.cy.ts @@ -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) + }) + }) + }) +}) diff --git a/cypress/e2e/specs/optimism/swap-page.e2e-spec.cy.ts b/cypress/e2e/specs/optimism/swap-page.e2e-spec.cy.ts new file mode 100644 index 0000000000..16c33c7eaa --- /dev/null +++ b/cypress/e2e/specs/optimism/swap-page.e2e-spec.cy.ts @@ -0,0 +1,195 @@ +import { homePage, tab, token } from '../../selectors/selectors.cy' + +const mainPage = 'swap/optimism' +const tokenSymbol = ['BOB', 'DAI', 'USDT', 'USDC'] +const unListedToken = ['KNNC', 'KCCN'] + +const unWhiteListedToken = { + CHI: { + name: 'CHI', + address: '0xca0e54b636db823847b29f506bffee743f57729d', + }, + ACX: { + name: 'ACX', + address: '0xFf733b2A3557a7ed6697007ab5D11B79FdD1b76B', + }, + PSP: { + name: 'PSP', + address: '0xd3594e879b358f430e20f82bea61e83562d49d48', + }, +} + +describe('Token Catalog', { tags: 'regression' }, () => { + beforeEach(() => { + cy.visit('/optimism') + 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', { tags: 'regression' }, () => { + 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', { tags: 'regression' }, () => { + 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', { tags: 'regression' }, () => { + 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') + }) + + it('Should be added tokenIn to favorite tokens list', { tags: 'regression' }, () => { + 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', { tags: 'regression' }, () => { + 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', { tags: 'regression' }, () => { + cy.clickButton(token.tokenOut) + cy.addTokenToFavoriteTokensList(tokenSymbol[0]) + cy.verifyIcon('true') + cy.verifyValueInList(token.favoriteToken, [tokenSymbol[0]], true) + }) + }) + + describe('Select token by symbol', () => { + it('Should be selected tokenIn by symbol successfully', { tags: 'regression' }, () => { + 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', { tags: 'regression' }, () => { + 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', { tags: 'regression' }, () => { + cy.clickButton(token.tokenIn) + cy.input(token.inputToken, unListedToken[0]) + cy.verifyNoResultFound() + }) + + it('Should be unselected tokenOut not exist in whitelist', { tags: 'regression' }, () => { + cy.clickButton(token.tokenOut) + cy.input(token.inputToken, unListedToken[1]) + cy.verifyNoResultFound() + }) + }) + + describe('Import token', () => { + it('Should be imported tokenIn successfully', { tags: 'regression' }, () => { + cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.CHI.address) + cy.verifySelectedToken(token.tokenIn, unWhiteListedToken.CHI.name) + cy.clickButton(token.tokenIn) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.CHI.name], true) + }) + + it('Should be imported tokenOut successfully', { tags: 'regression' }, () => { + cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.ACX.address) + cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.ACX.name) + cy.clickButton(token.tokenOut) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.ACX.name], true) + }) + }) + + describe('Delete token', () => { + it('Should be deleted the imported tokenIn successfully', { tags: 'regression' }, () => { + cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.CHI.address) + cy.clickButton(token.tokenIn) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.CHI.name], true) + cy.deleteImportedToken(unWhiteListedToken.CHI.address) + cy.verifyNoResultFound() + }) + + it('Should be deleted the imported tokenOut successfully', { tags: 'regression' }, () => { + cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.CHI.address) + cy.clickButton(token.tokenOut) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.CHI.name], true) + cy.deleteImportedToken(unWhiteListedToken.CHI.address) + cy.verifyNoResultFound() + }) + + it('Should be cleared all the imported tokenIn successfully', { tags: 'regression' }, () => { + cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.CHI.address) + cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.ACX.address) + cy.importNewTokenByAddress(token.tokenIn, unWhiteListedToken.PSP.address) + cy.clickButton(token.tokenIn) + cy.clickButton(tab.import) + cy.verifyValueInList( + token.rowInWhiteList, + [unWhiteListedToken.CHI.name, unWhiteListedToken.ACX.name, unWhiteListedToken.PSP.name], + true, + ) + cy.clearAllImportedTokens() + cy.verifyNoResultFound() + }) + + it('Should be cleared all the imported tokenOut successfully', { tags: 'regression' }, () => { + cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.CHI.address) + cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.ACX.address) + cy.importNewTokenByAddress(token.tokenOut, unWhiteListedToken.PSP.address) + cy.clickButton(token.tokenOut) + cy.clickButton(tab.import) + cy.verifyValueInList( + token.rowInWhiteList, + [unWhiteListedToken.CHI.name, unWhiteListedToken.ACX.name, unWhiteListedToken.ACX.name], + true, + ) + cy.clearAllImportedTokens() + cy.verifyNoResultFound() + }) + }) + + describe('E2E Token Catalog', () => { + it('Should be selected tokenIn and tokenOut to swap', { tags: ['smoke', 'regression'] }, () => { + //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.CHI.address) + cy.verifySelectedToken(token.tokenOut, unWhiteListedToken.CHI.name) + cy.verifyURL(tokenSymbol[1], unWhiteListedToken.CHI.name) + //delete imported tokenOut + cy.clickButton(token.tokenOut) + cy.clickButton(tab.import) + cy.verifyValueInList(token.rowInWhiteList, [unWhiteListedToken.CHI.name], true) + cy.deleteImportedToken(unWhiteListedToken.CHI.address) + cy.verifyNoResultFound() + cy.get(token.tokenOut).should('include.text', 'Select a token') + }) + }) +}) diff --git a/cypress/support/selectTokenCommands.ts b/cypress/support/selectTokenCommands.ts index 7abe7b5ab3..36c9a8a20b 100644 --- a/cypress/support/selectTokenCommands.ts +++ b/cypress/support/selectTokenCommands.ts @@ -76,7 +76,7 @@ Cypress.Commands.add('addTokenToFavoriteTokensList', value => { cy.input(token.inputToken, value) cy.verifyIcon('false') cy.get(token.rowInWhiteList).eq(0).should('contain', value) - cy.get(token.rowInWhiteList).find(token.iconFavorite).eq(0).click() + cy.get(token.rowInWhiteList).find(token.iconFavorite).eq(0).click({ force: true }) }) Cypress.Commands.add('verifyNoResultFound', () => {