Skip to content

Commit

Permalink
Merge branch 'main' into dao-quorum-status-apr
Browse files Browse the repository at this point in the history
  • Loading branch information
nhd98z authored Oct 16, 2023
2 parents 4487136 + 10c0d27 commit ce01298
Show file tree
Hide file tree
Showing 69 changed files with 983 additions and 944 deletions.
24 changes: 24 additions & 0 deletions cypress/e2e/pages/limit-order.po.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { LimitOrderLocators } from "../selectors/selectors.cy"
import { TokenCatalog } from "./swap-page.po.cy"
export interface myCallbackType<T> {
(myArgument: T): void
}
export const LimitOder = {

selectTokenSell(): TokenCatalog {
cy.selectToken(LimitOrderLocators.dropdownTokenSell)
return new TokenCatalog()
},
selectTokenBuy(): TokenCatalog {
cy.selectToken(LimitOrderLocators.dropdownTokenBuy)
return new TokenCatalog()
},

getCurrentTokenSell(text: myCallbackType<string>) {
cy.getContent(LimitOrderLocators.dropdownTokenSell, text)
},

getCurrentTokenBuy(text: myCallbackType<string>) {
cy.getContent(LimitOrderLocators.dropdownTokenBuy, text)
},
}
20 changes: 13 additions & 7 deletions cypress/e2e/pages/swap-page.po.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HeaderLocators, NetworkLocators, SwapPageLocators, TokenCatalogLocators, WalletLocators } from "../selectors/selectors.cy"
import { HeaderLocators, LimitOrderLocators, NetworkLocators, SwapPageLocators, TokenCatalogLocators, WalletLocators } from "../selectors/selectors.cy"

export interface myCallbackType<T> {
(myArgument: T): void
Expand All @@ -12,11 +12,11 @@ export const SwapPage = {
},

selectTokenIn(): TokenCatalog {
cy.selectTokenIn()
cy.selectToken(SwapPageLocators.dropdownTokenIn)
return new TokenCatalog()
},
selectTokenOut(): TokenCatalog {
cy.selectTokenOut()
cy.selectToken(SwapPageLocators.dropdownTokenOut)
return new TokenCatalog()
},

Expand All @@ -37,6 +37,10 @@ export const SwapPage = {
cy.get(WalletLocators.statusConnected, { timeout: 10000 }).should('be.visible')
},

goToLimitOrder() {
cy.get(LimitOrderLocators.btnLimit).click()
},

goToFarmPage() {
cy.get(HeaderLocators.dropdownEarn).click({ force: true })
cy.get(HeaderLocators.lblFarms).click({ force: true })
Expand Down Expand Up @@ -78,10 +82,12 @@ export class TokenCatalog {
cy.selectTokenBySymbol(tokenSymbol)
}

addFavoriteToken(tokenSymbol: string) {
this.searchToken(tokenSymbol)
cy.wait(2000)
cy.addFavoriteToken()
addFavoriteToken(tokenSymbol: Array<string>) {
tokenSymbol.forEach(element => {
this.searchToken(element)
cy.wait(2000)
cy.addFavoriteToken()
});
}

removeFavoriteToken(tokenSymbol: string) {
Expand Down
6 changes: 6 additions & 0 deletions cypress/e2e/selectors/selectors.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export const SwapPageLocators = {
btnSkipTutorial: '[data-testid=button-skip-tutorial]',
}

export const LimitOrderLocators = {
dropdownTokenSell: '[data-testid=limit-order-input-tokena] [data-testid=token-symbol-container]',
dropdownTokenBuy: '[data-testid=limit-order-input-tokenb] [data-testid=token-symbol-container]',
btnLimit: '[data-testid=limit-button]'
}

export const WalletLocators = {
btnConnectWallet: '[data-testid=button-connect-wallet]',
btnMetaMask: '[data-testid=connect-METAMASK]',
Expand Down
86 changes: 86 additions & 0 deletions cypress/e2e/specs/limit-order.e2e.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { LimitOder } from "../pages/limit-order.po.cy"
import { SwapPage, TokenCatalog } from "../pages/swap-page.po.cy"
import { DEFAULT_URL, NETWORK, NORESULTS_TEXT, NOTOKENS_TEXT, TAG, TOKEN_SYMBOLS, UNWHITELIST_SYMBOL_TOKENS, UNWHITELIST_TOKENS } from "../selectors/constants.cy"

const unWhitelistTokens = UNWHITELIST_TOKENS[NETWORK]
const tokenSymbols = TOKEN_SYMBOLS[NETWORK]

const arrAddress = [unWhitelistTokens[0].address, unWhitelistTokens[1].address, unWhitelistTokens[2].address]
const arrSymbol = [unWhitelistTokens[0].symbol, unWhitelistTokens[1].symbol, unWhitelistTokens[2].symbol]


const tokenCatalog = new TokenCatalog();


describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => {
beforeEach(() => {
SwapPage.open(DEFAULT_URL)
SwapPage.goToLimitOrder()
})

describe('Add/remove/select token with favorite tokens list', () => {
it('Should be added, selected and removed favorite token sell', () => {
LimitOder.selectTokenSell().addFavoriteToken([tokenSymbols[0], tokenSymbols[1]])
tokenCatalog.getFavoriteTokens((list) => {
expect(list).to.include.members([tokenSymbols[1]])
})

tokenCatalog.selectFavoriteToken(tokenSymbols[1])
LimitOder.getCurrentTokenSell((text) => {
expect(text).to.equal(tokenSymbols[1])
})
LimitOder.selectTokenSell()
tokenCatalog.removeFavoriteToken(tokenSymbols[0])
tokenCatalog.getFavoriteTokens((list) => {
expect(list).not.to.include.members([tokenSymbols[0]])
})
})

it('Should be added, selected and removed favorite token buy', () => {
LimitOder.selectTokenBuy().addFavoriteToken([tokenSymbols[0], tokenSymbols[1]])
tokenCatalog.getFavoriteTokens((list) => {
expect(list).to.include.members([tokenSymbols[1]])
})

tokenCatalog.selectFavoriteToken(tokenSymbols[1])
LimitOder.getCurrentTokenBuy((text) => {
expect(text).to.equal(tokenSymbols[1])
})
LimitOder.selectTokenBuy()
tokenCatalog.removeFavoriteToken(tokenSymbols[0])
tokenCatalog.getFavoriteTokens((list) => {
expect(list).not.to.include.members([tokenSymbols[0]])
})
})
})

describe('Select token by symbol', () => {
it('Should be selected token sell by symbol successfully', () => {
LimitOder.selectTokenSell().selectTokenBySymbol(tokenSymbols[0])
LimitOder.getCurrentTokenSell((text) => {
expect(text).to.equal(tokenSymbols[0])
})
})

it('Should be selected token buy by symbol successfully', () => {
LimitOder.selectTokenBuy().selectTokenBySymbol(tokenSymbols[1])
LimitOder.getCurrentTokenBuy((text) => {
expect(text).to.equal(tokenSymbols[1])
})
})

it('Should be unselected tokenIn not exist in whitelist', () => {
LimitOder.selectTokenSell().searchToken(UNWHITELIST_SYMBOL_TOKENS[0])
tokenCatalog.getNoResultsFound((text) => {
expect(text).to.equal(NORESULTS_TEXT)
})
})

it('Should be unselected tokenOut not exist in whitelist', () => {
LimitOder.selectTokenBuy().searchToken(UNWHITELIST_SYMBOL_TOKENS[0])
tokenCatalog.getNoResultsFound((text) => {
expect(text).to.equal(NORESULTS_TEXT)
})
})
})
})
4 changes: 2 additions & 2 deletions cypress/e2e/specs/swap-page.e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => {
})

it('Should be added tokenIn to favorite tokens list', () => {
SwapPage.selectTokenIn().addFavoriteToken(tokenSymbols[0])
SwapPage.selectTokenIn().addFavoriteToken([tokenSymbols[0]])
tokenCatalog.getFavoriteTokens((list) => {
expect(list).to.include.members([tokenSymbols[0]])
})
Expand All @@ -63,7 +63,7 @@ describe(`Token Catalog on ${NETWORK}`, { tags: TAG.regression }, () => {
})

it('Should be added tokenOut to favorite tokens list', () => {
SwapPage.selectTokenOut().addFavoriteToken(tokenSymbols[0])
SwapPage.selectTokenOut().addFavoriteToken([tokenSymbols[0]])
tokenCatalog.getFavoriteTokens((list) => {
expect(list).to.include.members([tokenSymbols[0]])
})
Expand Down
12 changes: 4 additions & 8 deletions cypress/support/selectTokenCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ declare global {
interface Chainable {
closeTutorialPopup(): Chainable<void>
searchToken(value: string): Chainable<void>
selectTokenIn(): Chainable<void>
selectTokenOut(): Chainable<void>
selectToken(selector: string): Chainable<void>
selectTokenBySymbol(value: string): Chainable<void>
removeFavoriteToken(value: string): Chainable<void>
addFavoriteToken(): Chainable<void>
Expand All @@ -30,15 +29,12 @@ Cypress.Commands.add('closeTutorialPopup', () => {
cy.get(SwapPageLocators.btnSkipTutorial, { timeout: 30000 }).should('be.visible').click()
})

Cypress.Commands.add('selectTokenIn', () => {
cy.get(SwapPageLocators.dropdownTokenIn, { timeout: 30000 }).should('be.visible').click()
})

Cypress.Commands.add('selectTokenOut', () => {
cy.get(SwapPageLocators.dropdownTokenOut, { timeout: 30000 }).should('be.visible').click()
Cypress.Commands.add('selectToken', (selector: string) => {
cy.get(selector, { timeout: 30000 }).should('be.visible').click()
})

Cypress.Commands.add('searchToken', (value) => {
cy.get(TokenCatalogLocators.txtToken).clear()
cy.get(TokenCatalogLocators.txtToken).should('be.visible').type(value)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ItemWrapper = styled.div`
gap: 8px;
`
export const TokenInfo = ({
showPrice = true,
showPrice = false,
logoSize = '12px',
token,
}: {
Expand Down Expand Up @@ -73,7 +73,7 @@ function InboxItemBridge({
}

return (
<InboxItemWrapper isRead={isRead} onClick={onClick} style={{ ...style, paddingTop: '8px', gap: '6px' }}>
<InboxItemWrapper isRead={isRead} onClick={onClick} style={style}>
<InboxItemRow>
<RowItem>
<InboxIcon type={templateType} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function AnnouncementItem({
{!expand &&
minimalAssets.map((token, i) => (
<Fragment key={i}>
<TokenInfo token={token} showPrice={false} key={i} logoSize={'14px'} />
<TokenInfo token={token} key={i} logoSize={'14px'} />
{i === minimalAssets.length - 1 ? (minimalAssets.length < slice ? '' : ', ...') : ', '}
</Fragment>
))}
Expand Down
20 changes: 0 additions & 20 deletions src/components/Announcement/helper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import { useCallback } from 'react'
import AnnouncementApi from 'services/announcement'

import { AnnouncementTemplatePopup, PopupContentAnnouncement, PopupItemType } from 'components/Announcement/type'
import { TIMES_IN_SECS } from 'constants/index'
import { useAppDispatch } from 'state/hooks'

const LsKey = 'ack-announcements'
export const getAnnouncementsAckMap = () => JSON.parse(localStorage[LsKey] || '{}')
Expand Down Expand Up @@ -42,20 +39,3 @@ export const isPopupCanShow = (
const isExpired = Date.now() < startAt * 1000 || Date.now() > endAt * 1000
return !isRead && !isExpired && isRightChain && isOwn
}

export const useInvalidateTags = (reducerPath: string) => {
const dispatch = useAppDispatch()
return useCallback(
(tag: string | string[]) => {
dispatch({
type: `${reducerPath}/invalidateTags`,
payload: Array.isArray(tag) ? tag : [tag],
})
},
[dispatch, reducerPath],
)
}

export const useInvalidateTagAnnouncement = () => {
return useInvalidateTags(AnnouncementApi.reducerPath)
}
3 changes: 2 additions & 1 deletion src/components/Announcement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import styled, { css } from 'styled-components'

import AnnouncementView, { Tab } from 'components/Announcement/AnnoucementView'
import DetailAnnouncementPopup from 'components/Announcement/Popups/DetailAnnouncementPopup'
import { formatNumberOfUnread, useInvalidateTagAnnouncement } from 'components/Announcement/helper'
import { formatNumberOfUnread } from 'components/Announcement/helper'
import { Announcement, PrivateAnnouncement } from 'components/Announcement/type'
import NotificationIcon from 'components/Icons/NotificationIcon'
import MenuFlyout from 'components/MenuFlyout'
import Modal from 'components/Modal'
import { RTK_QUERY_TAGS } from 'constants/index'
import useInterval from 'hooks/useInterval'
import { useInvalidateTagAnnouncement } from 'hooks/useInvalidateTags'
import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
import { ApplicationModal } from 'state/application/actions'
import { useDetailAnnouncement, useModalOpen, useToggleNotificationCenter } from 'state/application/hooks'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/web3/SelectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function Web3StatusInner() {
id={TutorialIds.BUTTON_CONNECT_WALLET}
data-testid="button-connect-wallet"
>
<Trans>Connect Wallet</Trans>
<Trans>Connect</Trans>
</ButtonLight>
)
}
Expand Down
46 changes: 13 additions & 33 deletions src/components/Header/web3/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
useWalletModalToggle,
} from 'state/application/hooks'
import { useIsConnectingWallet } from 'state/authen/hooks'
import { useIsAcceptedTerm } from 'state/user/hooks'
import { ExternalLink } from 'theme'
import { isEVMWallet, isOverriddenWallet, isSolanaWallet } from 'utils'

Expand Down Expand Up @@ -62,7 +61,7 @@ const ContentWrapper = styled.div`
`

const TermAndCondition = styled.div`
padding: 8px;
padding: 8px 16px;
font-size: 12px;
font-weight: 500;
line-height: 16px;
Expand Down Expand Up @@ -158,8 +157,6 @@ export default function WalletModal() {

const previousAccount = usePrevious(account)

const [isAcceptedTerm, setIsAcceptedTerm] = useIsAcceptedTerm()

const location = useLocation()
const { mixpanelHandler } = useMixpanel()

Expand Down Expand Up @@ -316,36 +313,19 @@ export default function WalletModal() {
</CloseIcon>
</RowBetween>
{(walletView === WALLET_VIEWS.ACCOUNT || walletView === WALLET_VIEWS.CHANGE_WALLET) && (
<TermAndCondition
onClick={() => {
if (!isAcceptedTerm) {
mixpanelHandler(MIXPANEL_TYPE.WALLET_CONNECT_ACCEPT_TERM_CLICK)
}
setIsAcceptedTerm(!isAcceptedTerm)
}}
>
<input
onChange={() => {
//
}}
type="checkbox"
checked={isAcceptedTerm}
data-testid="accept-term"
style={{ marginRight: '12px', height: '14px', width: '14px', minWidth: '14px', cursor: 'pointer' }}
/>
<TermAndCondition>
<Text color={theme.subText}>
<Trans>Accept </Trans>{' '}
<ExternalLink href={TERM_FILES_PATH.KYBERSWAP_TERMS} onClick={e => e.stopPropagation()}>
<Trans>KyberSwap&lsquo;s Terms of Use</Trans>
</ExternalLink>{' '}
<Trans>and</Trans>{' '}
<ExternalLink href={TERM_FILES_PATH.PRIVACY_POLICY} onClick={e => e.stopPropagation()}>
<Trans>Privacy Policy</Trans>
</ExternalLink>
{'. '}
<Text fontSize={10} as="span">
<Trans>Last updated: {dayjs(TERM_FILES_PATH.VERSION).format('DD MMM YYYY')}</Trans>
</Text>
<Trans>
By connecting a wallet, you accept{' '}
<ExternalLink href={TERM_FILES_PATH.KYBERSWAP_TERMS} onClick={e => e.stopPropagation()}>
KyberSwap&lsquo;s Terms of Use
</ExternalLink>{' '}
and consent to its{' '}
<ExternalLink href={TERM_FILES_PATH.PRIVACY_POLICY} onClick={e => e.stopPropagation()}>
Privacy Policy
</ExternalLink>
. Last updated: {dayjs(TERM_FILES_PATH.VERSION).format('DD MMM YYYY')}
</Trans>
</Text>
</TermAndCondition>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Menu/FaucetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function FaucetModal() {
}}
style={{ borderRadius: '24px', height: '44px' }}
>
<Trans>Connect Wallet</Trans>
<Trans>Connect</Trans>
</ButtonPrimary>
)}
</Flex>
Expand Down
Loading

0 comments on commit ce01298

Please sign in to comment.