Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
1f7ba5ae
Unverified
Commit
1f7ba5ae
authored
Jan 17, 2023
by
lynn
Committed by
GitHub
Jan 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add token explore integration test (#5820)
* init * fix * fixes * remove extraneous tokens test
parent
3686803c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
72 deletions
+97
-72
token-explore.test.ts
cypress/e2e/token-explore.test.ts
+74
-0
token.test.ts
cypress/e2e/token.test.ts
+0
-55
ChartSection.tsx
src/components/Tokens/TokenDetails/ChartSection.tsx
+1
-1
index.tsx
src/components/Tokens/TokenDetails/index.tsx
+1
-1
TimeSelector.tsx
src/components/Tokens/TokenTable/TimeSelector.tsx
+2
-1
TokenRow.tsx
src/components/Tokens/TokenTable/TokenRow.tsx
+19
-14
No files found.
cypress/e2e/token-explore.test.ts
0 → 100644
View file @
1f7ba5ae
import
{
getTestSelector
,
getTestSelectorStartsWith
}
from
'
../utils
'
describe
(
'
Token explore
'
,
()
=>
{
before
(()
=>
{
cy
.
visit
(
'
/
'
)
})
it
(
'
should load token leaderboard
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelectorStartsWith
(
'
token-table
'
)).
its
(
'
length
'
).
should
(
'
be.eq
'
,
100
)
// check sorted svg icon is present in volume cell, since tokens are sorted by volume by default
cy
.
get
(
getTestSelector
(
'
header-row
'
)).
find
(
getTestSelector
(
'
volume-cell
'
)).
find
(
'
svg
'
).
should
(
'
exist
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
)).
find
(
getTestSelector
(
'
name-cell
'
)).
should
(
'
include.text
'
,
'
Ether
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
)).
find
(
getTestSelector
(
'
volume-cell
'
)).
should
(
'
include.text
'
,
'
$
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
)).
find
(
getTestSelector
(
'
price-cell
'
)).
should
(
'
include.text
'
,
'
$
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
)).
find
(
getTestSelector
(
'
tvl-cell
'
)).
should
(
'
include.text
'
,
'
$
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
))
.
find
(
getTestSelector
(
'
percent-change-cell
'
))
.
should
(
'
include.text
'
,
'
%
'
)
cy
.
get
(
getTestSelector
(
'
header-row
'
)).
find
(
getTestSelector
(
'
price-cell
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
header-row
'
)).
find
(
getTestSelector
(
'
price-cell
'
)).
find
(
'
svg
'
).
should
(
'
exist
'
)
})
it
(
'
should update when time window toggled
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelector
(
'
time-selector
'
)).
should
(
'
contain
'
,
'
1D
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
))
.
find
(
getTestSelector
(
'
volume-cell
'
))
.
then
(
function
(
$elem
)
{
cy
.
wrap
(
$elem
.
text
()).
as
(
'
dailyEthVol
'
)
})
cy
.
get
(
getTestSelector
(
'
time-selector
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
1Y
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
))
.
find
(
getTestSelector
(
'
volume-cell
'
))
.
then
(
function
(
$elem
)
{
cy
.
wrap
(
$elem
.
text
()).
as
(
'
yearlyEthVol
'
)
})
expect
(
cy
.
get
(
'
@dailyEthVol
'
)).
to
.
not
.
equal
(
cy
.
get
(
'
@yearlyEthVol
'
))
})
it
(
'
should navigate to token detail page when row clicked
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
token-details-about-section
'
)).
should
(
'
exist
'
)
cy
.
get
(
getTestSelector
(
'
token-details-stats
'
)).
should
(
'
exist
'
)
cy
.
get
(
getTestSelector
(
'
token-info-container
'
)).
should
(
'
exist
'
)
cy
.
get
(
getTestSelector
(
'
chart-container
'
)).
should
(
'
exist
'
)
cy
.
contains
(
'
Ethereum is a smart contract platform that enables developers to build tokens
'
).
should
(
'
exist
'
)
cy
.
contains
(
'
Etherscan
'
).
should
(
'
exist
'
)
})
it
(
'
should update when global network changed
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
should
(
'
contain
'
,
'
Ethereum
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-ETH
'
)).
should
(
'
exist
'
)
// note: cannot switch global chain via UI because we cannot approve the network switch
// in metamask modal using plain cypress. this is a workaround.
cy
.
visit
(
'
/tokens/polygon
'
)
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
should
(
'
contain
'
,
'
Polygon
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-MATIC
'
)).
should
(
'
exist
'
)
})
it
(
'
should update when token explore table network changed
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-option-optimism
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
should
(
'
contain
'
,
'
Optimism
'
)
cy
.
reload
()
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
should
(
'
contain
'
,
'
Optimism
'
)
cy
.
get
(
getTestSelector
(
'
chain-selector
'
)).
last
().
should
(
'
contain
'
,
'
Ethereum
'
)
})
})
cypress/e2e/token.test.ts
deleted
100644 → 0
View file @
3686803c
import
{
getTestSelector
,
getTestSelectorStartsWith
}
from
'
../utils
'
describe
(
'
Testing tokens on uniswap page
'
,
()
=>
{
before
(()
=>
{
cy
.
visit
(
'
/
'
)
})
it
(
'
should load token leaderboard
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelectorStartsWith
(
'
token-table
'
)).
its
(
'
length
'
).
should
(
'
be.gte
'
,
25
)
})
it
(
'
should keep the same configuration when reloaded: ETH global, OP local
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-option-optimism
'
)).
click
()
cy
.
reload
()
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
should
(
'
contain
'
,
'
Optimism
'
)
})
it
(
'
should have the correct network configuration when reloaded: OP global, Polygon local
'
,
()
=>
{
cy
.
get
(
getTestSelector
(
'
chain-selector
'
)).
last
().
click
()
cy
.
get
(
getTestSelector
(
'
chain-selector-option-optimism
'
)).
click
()
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-option-polygon
'
)).
click
()
cy
.
reload
()
cy
.
get
(
getTestSelector
(
'
tokens-network-filter-selected
'
)).
should
(
'
contain
'
,
'
Polygon
'
)
// With no wallet connected, reloading the page resets the global network.
cy
.
get
(
getTestSelector
(
'
chain-selector
'
)).
last
().
should
(
'
contain
'
,
'
Ethereum
'
)
})
it
(
'
should load go to ethereum token and return to token list page
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum
'
)
cy
.
get
(
getTestSelector
(
'
token-table-row-Ether
'
)).
click
()
cy
.
get
(
getTestSelector
(
'
token-details-stats
'
)).
should
(
'
exist
'
)
cy
.
get
(
getTestSelector
(
'
token-details-return-button
'
)).
click
()
cy
.
get
(
getTestSelectorStartsWith
(
'
token-table
'
)).
its
(
'
length
'
).
should
(
'
be.gte
'
,
25
)
})
it
(
'
should go to native token on ethereum and render description
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum/NATIVE
'
)
cy
.
get
(
getTestSelector
(
'
token-details-about-section
'
)).
should
(
'
exist
'
)
cy
.
contains
(
'
Ethereum is a smart contract platform that enables developers
'
).
should
(
'
exist
'
)
cy
.
contains
(
'
Etherscan
'
).
should
(
'
exist
'
)
})
it
(
'
should go to native token on polygon and render description and links
'
,
()
=>
{
cy
.
visit
(
'
/tokens/polygon/NATIVE
'
)
cy
.
get
(
getTestSelector
(
'
token-details-about-section
'
)).
should
(
'
exist
'
)
cy
.
contains
(
'
Wrapped Matic on Polygon
'
).
should
(
'
exist
'
)
cy
.
contains
(
'
Block Explorer
'
).
should
(
'
exist
'
)
})
})
src/components/Tokens/TokenDetails/ChartSection.tsx
View file @
1f7ba5ae
...
@@ -58,7 +58,7 @@ function Chart({
...
@@ -58,7 +58,7 @@ function Chart({
const
timePeriod
=
useAtomValue
(
pageTimePeriodAtom
)
const
timePeriod
=
useAtomValue
(
pageTimePeriodAtom
)
return
(
return
(
<
ChartContainer
>
<
ChartContainer
data
-
testid=
"chart-container"
>
<
ParentSize
>
<
ParentSize
>
{
({
width
})
=>
<
PriceChart
prices=
{
prices
??
null
}
width=
{
width
}
height=
{
436
}
timePeriod=
{
timePeriod
}
/>
}
{
({
width
})
=>
<
PriceChart
prices=
{
prices
??
null
}
width=
{
width
}
height=
{
436
}
timePeriod=
{
timePeriod
}
/>
}
</
ParentSize
>
</
ParentSize
>
...
...
src/components/Tokens/TokenDetails/index.tsx
View file @
1f7ba5ae
...
@@ -186,7 +186,7 @@ export default function TokenDetails({
...
@@ -186,7 +186,7 @@ export default function TokenDetails({
<
BreadcrumbNavLink
to=
{
`/tokens/${chain.toLowerCase()}`
}
>
<
BreadcrumbNavLink
to=
{
`/tokens/${chain.toLowerCase()}`
}
>
<
ArrowLeft
data
-
testid=
"token-details-return-button"
size=
{
14
}
/>
Tokens
<
ArrowLeft
data
-
testid=
"token-details-return-button"
size=
{
14
}
/>
Tokens
</
BreadcrumbNavLink
>
</
BreadcrumbNavLink
>
<
TokenInfoContainer
>
<
TokenInfoContainer
data
-
testid=
"token-info-container"
>
<
TokenNameCell
>
<
TokenNameCell
>
<
LogoContainer
>
<
LogoContainer
>
<
CurrencyLogo
currency=
{
token
}
size=
"32px"
/>
<
CurrencyLogo
currency=
{
token
}
size=
"32px"
/>
...
...
src/components/Tokens/TokenTable/TimeSelector.tsx
View file @
1f7ba5ae
...
@@ -111,7 +111,7 @@ export default function TimeSelector() {
...
@@ -111,7 +111,7 @@ export default function TimeSelector() {
return
(
return
(
<
StyledMenu
ref=
{
node
}
>
<
StyledMenu
ref=
{
node
}
>
<
FilterOption
onClick=
{
toggleMenu
}
aria
-
label=
"timeSelector"
active=
{
open
}
>
<
FilterOption
onClick=
{
toggleMenu
}
aria
-
label=
"timeSelector"
active=
{
open
}
data
-
testid=
"time-selector"
>
<
StyledMenuContent
>
<
StyledMenuContent
>
{
DISPLAYS
[
activeTime
]
}
{
DISPLAYS
[
activeTime
]
}
<
Chevron
open=
{
open
}
>
<
Chevron
open=
{
open
}
>
...
@@ -128,6 +128,7 @@ export default function TimeSelector() {
...
@@ -128,6 +128,7 @@ export default function TimeSelector() {
{
ORDERED_TIMES
.
map
((
time
)
=>
(
{
ORDERED_TIMES
.
map
((
time
)
=>
(
<
InternalLinkMenuItem
<
InternalLinkMenuItem
key=
{
DISPLAYS
[
time
]
}
key=
{
DISPLAYS
[
time
]
}
data
-
testid=
{
DISPLAYS
[
time
]
}
onClick=
{
()
=>
{
onClick=
{
()
=>
{
setTime
(
time
)
setTime
(
time
)
toggleMenu
()
toggleMenu
()
...
...
src/components/Tokens/TokenTable/TokenRow.tsx
View file @
1f7ba5ae
...
@@ -378,15 +378,23 @@ function TokenRow({
...
@@ -378,15 +378,23 @@ function TokenRow({
const rowCells = (
const rowCells = (
<>
<>
<ListNumberCell header={header}>{listNumber}</ListNumberCell>
<ListNumberCell header={header}>{listNumber}</ListNumberCell>
<NameCell>{tokenInfo}</NameCell>
<NameCell data-testid="name-cell">{tokenInfo}</NameCell>
<PriceCell sortable={header}>{price}</PriceCell>
<PriceCell data-testid="price-cell" sortable={header}>
<PercentChangeCell sortable={header}>{percentChange}</PercentChangeCell>
{price}
<TvlCell sortable={header}>{tvl}</TvlCell>
</PriceCell>
<VolumeCell sortable={header}>{volume}</VolumeCell>
<PercentChangeCell data-testid="percent-change-cell" sortable={header}>
{percentChange}
</PercentChangeCell>
<TvlCell data-testid="tvl-cell" sortable={header}>
{tvl}
</TvlCell>
<VolumeCell data-testid="volume-cell" sortable={header}>
{volume}
</VolumeCell>
<SparkLineCell>{sparkLine}</SparkLineCell>
<SparkLineCell>{sparkLine}</SparkLineCell>
</>
</>
)
)
if (header) return <StyledHeaderRow>{rowCells}</StyledHeaderRow>
if (header) return <StyledHeaderRow
data-testid="header-row"
>{rowCells}</StyledHeaderRow>
return <StyledTokenRow {...rest}>{rowCells}</StyledTokenRow>
return <StyledTokenRow {...rest}>{rowCells}</StyledTokenRow>
}
}
...
@@ -440,9 +448,6 @@ interface LoadedRowProps {
...
@@ -440,9 +448,6 @@ interface LoadedRowProps {
/* Loaded State: row component with token information */
/* Loaded State: row component with token information */
export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HTMLDivElement>) => {
export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HTMLDivElement>) => {
const { tokenListIndex, tokenListLength, token, volumeRank } = props
const { tokenListIndex, tokenListLength, token, volumeRank } = props
const tokenAddress = token.address
const tokenName = token.name
const tokenSymbol = token.symbol
const filterString = useAtomValue(filterStringAtom)
const filterString = useAtomValue(filterStringAtom)
const lowercaseChainName = useParams<{ chainName?: string }>().chainName?.toUpperCase() ?? 'ethereum'
const lowercaseChainName = useParams<{ chainName?: string }>().chainName?.toUpperCase() ?? 'ethereum'
...
@@ -457,8 +462,8 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
...
@@ -457,8 +462,8 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
const exploreTokenSelectedEventProperties = {
const exploreTokenSelectedEventProperties = {
chain_id: chainId,
chain_id: chainId,
token_address: token
A
ddress,
token_address: token
.a
ddress,
token_symbol: token
S
ymbol,
token_symbol: token
.s
ymbol,
token_list_index: tokenListIndex,
token_list_index: tokenListIndex,
token_list_rank: volumeRank,
token_list_rank: volumeRank,
token_list_length: tokenListLength,
token_list_length: tokenListLength,
...
@@ -468,7 +473,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
...
@@ -468,7 +473,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
// TODO: currency logo sizing mobile (32px) vs. desktop (24px)
// TODO: currency logo sizing mobile (32px) vs. desktop (24px)
return (
return (
<div ref={ref} data-testid={`
token
-
table
-
row
-
$
{
token
Name
}
`
}
>
<div ref={ref} data-testid={`
token
-
table
-
row
-
$
{
token
.
symbol
}
`
}
>
<
StyledLink
<
StyledLink
to=
{
getTokenDetailsURL
(
token
.
address
??
''
,
token
.
chain
)
}
to=
{
getTokenDetailsURL
(
token
.
address
??
''
,
token
.
chain
)
}
onClick=
{
()
=>
onClick=
{
()
=>
...
@@ -485,8 +490,8 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
...
@@ -485,8 +490,8 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
<
L2NetworkLogo
networkUrl=
{
L2Icon
}
/>
<
L2NetworkLogo
networkUrl=
{
L2Icon
}
/>
</
LogoContainer
>
</
LogoContainer
>
<
TokenInfoCell
>
<
TokenInfoCell
>
<
TokenName
>
{
token
N
ame
}
</
TokenName
>
<
TokenName
>
{
token
.
n
ame
}
</
TokenName
>
<
TokenSymbol
>
{
token
S
ymbol
}
</
TokenSymbol
>
<
TokenSymbol
>
{
token
.
s
ymbol
}
</
TokenSymbol
>
</
TokenInfoCell
>
</
TokenInfoCell
>
</
ClickableName
>
</
ClickableName
>
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment