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
0987a311
Unverified
Commit
0987a311
authored
Oct 21, 2022
by
Jordan Frankfurt
Committed by
GitHub
Oct 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(nft): empty bag state render (#4947)
* fix empty bag state render * add tests
parent
a97a6b7f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
60 deletions
+90
-60
Bag.tsx
src/nft/components/bag/Bag.tsx
+12
-38
BagHeader.css.ts
src/nft/components/bag/BagHeader.css.ts
+2
-2
EmptyContent.tsx
src/nft/components/bag/EmptyContent.tsx
+36
-0
bag.test.tsx.snap
src/nft/components/bag/__snapshots__/bag.test.tsx.snap
+3
-0
bag.test.tsx
src/nft/components/bag/bag.test.tsx
+21
-0
CTACards.test.tsx
src/pages/Pool/CTACards.test.tsx
+1
-6
index.test.tsx
src/pages/Pool/index.test.tsx
+2
-11
test-utils.tsx
src/test-utils.tsx
+13
-3
No files found.
src/nft/components/bag/Bag.tsx
View file @
0987a311
...
@@ -6,11 +6,9 @@ import { BagFooter } from 'nft/components/bag/BagFooter'
...
@@ -6,11 +6,9 @@ import { BagFooter } from 'nft/components/bag/BagFooter'
import
ListingModal
from
'
nft/components/bag/profile/ListingModal
'
import
ListingModal
from
'
nft/components/bag/profile/ListingModal
'
import
{
Box
}
from
'
nft/components/Box
'
import
{
Box
}
from
'
nft/components/Box
'
import
{
Portal
}
from
'
nft/components/common/Portal
'
import
{
Portal
}
from
'
nft/components/common/Portal
'
import
{
Center
,
Column
}
from
'
nft/components/Flex
'
import
{
Column
}
from
'
nft/components/Flex
'
import
{
LargeBagIcon
,
LargeTagIcon
}
from
'
nft/components/icons
'
import
{
Overlay
}
from
'
nft/components/modals/Overlay
'
import
{
Overlay
}
from
'
nft/components/modals/Overlay
'
import
{
buttonTextMedium
,
commonButtonStyles
,
subhead
}
from
'
nft/css/common.css
'
import
{
buttonTextMedium
,
commonButtonStyles
}
from
'
nft/css/common.css
'
import
{
themeVars
}
from
'
nft/css/sprinkles.css
'
import
{
import
{
useBag
,
useBag
,
useIsMobile
,
useIsMobile
,
...
@@ -34,39 +32,9 @@ import { useLocation } from 'react-router-dom'
...
@@ -34,39 +32,9 @@ import { useLocation } from 'react-router-dom'
import
*
as
styles
from
'
./Bag.css
'
import
*
as
styles
from
'
./Bag.css
'
import
{
BagContent
}
from
'
./BagContent
'
import
{
BagContent
}
from
'
./BagContent
'
import
{
BagHeader
}
from
'
./BagHeader
'
import
{
BagHeader
}
from
'
./BagHeader
'
import
EmptyState
from
'
./EmptyContent
'
import
{
ProfileBagContent
}
from
'
./profile/ProfileBagContent
'
import
{
ProfileBagContent
}
from
'
./profile/ProfileBagContent
'
const
EmptyState
=
()
=>
{
const
{
pathname
}
=
useLocation
()
const
isProfilePage
=
pathname
.
startsWith
(
'
/profile
'
)
return
(
<
Center
height=
"full"
>
<
Column
gap=
{
isProfilePage
?
'
16
'
:
'
12
'
}
>
<
Center
>
{
isProfilePage
?
(
<
LargeTagIcon
color=
{
themeVars
.
colors
.
textTertiary
}
/>
)
:
(
<
LargeBagIcon
color=
{
themeVars
.
colors
.
textTertiary
}
/>
)
}
</
Center
>
{
isProfilePage
?
(
<
span
className=
{
subhead
}
>
No NFTs Selected
</
span
>
)
:
(
<
Column
gap=
"16"
>
<
Center
className=
{
subhead
}
style=
{
{
lineHeight
:
'
24px
'
}
}
>
Your bag is empty
</
Center
>
<
Center
fontSize=
"12"
fontWeight=
"normal"
color=
"textSecondary"
style=
{
{
lineHeight
:
'
16px
'
}
}
>
Selected NFTs will appear here
</
Center
>
</
Column
>
)
}
</
Column
>
</
Center
>
)
}
interface
SeparatorProps
{
interface
SeparatorProps
{
top
?:
boolean
top
?:
boolean
show
?:
boolean
show
?:
boolean
...
@@ -282,6 +250,13 @@ const Bag = () => {
...
@@ -282,6 +250,13 @@ const Bag = () => {
setScrollProgress
(
scrollTop
?
((
scrollTop
+
containerHeight
)
/
scrollHeight
)
*
100
:
0
)
setScrollProgress
(
scrollTop
?
((
scrollTop
+
containerHeight
)
/
scrollHeight
)
*
100
:
0
)
}
}
const
isBuyingAssets
=
itemsInBag
.
length
>
0
const
isSellingAssets
=
sellAssets
.
length
>
0
const
shouldRenderEmptyState
=
Boolean
(
(
!
isProfilePage
&&
!
isBuyingAssets
&&
bagStatus
===
BagStatus
.
ADDING_TO_BAG
)
||
(
isProfilePage
&&
!
isSellingAssets
)
)
return
(
return
(
<>
<>
{
bagExpanded
&&
shouldShowBag
?
(
{
bagExpanded
&&
shouldShowBag
?
(
...
@@ -295,8 +270,7 @@ const Bag = () => {
...
@@ -295,8 +270,7 @@ const Bag = () => {
resetFlow=
{
isProfilePage
?
resetSellAssets
:
reset
}
resetFlow=
{
isProfilePage
?
resetSellAssets
:
reset
}
isProfilePage=
{
isProfilePage
}
isProfilePage=
{
isProfilePage
}
/>
/>
{
(
!
isProfilePage
&&
itemsInBag
.
length
===
0
&&
bagStatus
===
BagStatus
.
ADDING_TO_BAG
)
||
{
shouldRenderEmptyState
&&
<
EmptyState
/>
}
(
isProfilePage
&&
sellAssets
.
length
===
0
&&
<
EmptyState
/>)
}
<
ScrollingIndicator
top
show=
{
userCanScroll
&&
scrollProgress
>
0
}
/>
<
ScrollingIndicator
top
show=
{
userCanScroll
&&
scrollProgress
>
0
}
/>
<
Column
ref=
{
scrollRef
}
className=
{
styles
.
assetsContainer
}
onScroll=
{
scrollHandler
}
gap=
"12"
>
<
Column
ref=
{
scrollRef
}
className=
{
styles
.
assetsContainer
}
onScroll=
{
scrollHandler
}
gap=
"12"
>
{
isProfilePage
?
<
ProfileBagContent
/>
:
<
BagContent
/>
}
{
isProfilePage
?
<
ProfileBagContent
/>
:
<
BagContent
/>
}
...
@@ -314,7 +288,7 @@ const Bag = () => {
...
@@ -314,7 +288,7 @@ const Bag = () => {
assetsAreInReview=
{
itemsInBag
.
some
((
item
)
=>
item
.
status
===
BagItemStatus
.
REVIEWING_PRICE_CHANGE
)
}
assetsAreInReview=
{
itemsInBag
.
some
((
item
)
=>
item
.
status
===
BagItemStatus
.
REVIEWING_PRICE_CHANGE
)
}
/>
/>
)
}
)
}
{
sellAssets
.
length
!==
0
&&
isProfilePage
&&
(
{
isSellingAssets
&&
isProfilePage
&&
(
<
Box
<
Box
marginTop=
"32"
marginTop=
"32"
marginX=
"28"
marginX=
"28"
...
...
src/nft/components/bag/BagHeader.css.ts
View file @
0987a311
import
{
style
}
from
'
@vanilla-extract/css
'
import
{
style
}
from
'
@vanilla-extract/css
'
import
{
subhead
}
from
'
nft/css/common.css
'
import
{
headlineSmall
}
from
'
nft/css/common.css
'
import
{
sprinkles
,
vars
}
from
'
nft/css/sprinkles.css
'
import
{
sprinkles
,
vars
}
from
'
nft/css/sprinkles.css
'
export
const
header
=
style
([
export
const
header
=
style
([
subhead
,
headlineSmall
,
sprinkles
({
sprinkles
({
color
:
'
textPrimary
'
,
color
:
'
textPrimary
'
,
justifyContent
:
'
space-between
'
,
justifyContent
:
'
space-between
'
,
...
...
src/nft/components/bag/EmptyContent.tsx
0 → 100644
View file @
0987a311
import
{
Center
,
Column
}
from
'
nft/components/Flex
'
import
{
LargeBagIcon
,
LargeTagIcon
}
from
'
nft/components/icons
'
import
{
subhead
}
from
'
nft/css/common.css
'
import
{
themeVars
}
from
'
nft/css/sprinkles.css
'
import
{
useLocation
}
from
'
react-router-dom
'
const
EmptyState
=
()
=>
{
const
{
pathname
}
=
useLocation
()
const
isProfilePage
=
pathname
.
startsWith
(
'
/profile
'
)
return
(
<
Column
gap=
{
isProfilePage
?
'
16
'
:
'
12
'
}
marginTop=
"36"
>
<
Center
>
{
isProfilePage
?
(
<
LargeTagIcon
color=
{
themeVars
.
colors
.
textTertiary
}
/>
)
:
(
<
LargeBagIcon
color=
{
themeVars
.
colors
.
textTertiary
}
/>
)
}
</
Center
>
{
isProfilePage
?
(
<
span
className=
{
subhead
}
>
No NFTs Selected
</
span
>
)
:
(
<
Column
gap=
"16"
>
<
Center
className=
{
subhead
}
style=
{
{
lineHeight
:
'
24px
'
}
}
>
Your bag is empty
</
Center
>
<
Center
fontSize=
"12"
fontWeight=
"normal"
color=
"textSecondary"
style=
{
{
lineHeight
:
'
16px
'
}
}
>
Selected NFTs will appear here
</
Center
>
</
Column
>
)
}
</
Column
>
)
}
export
default
EmptyState
src/nft/components/bag/__snapshots__/bag.test.tsx.snap
0 → 100644
View file @
0987a311
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Bag.tsx matches base snapshot 1`] = `<DocumentFragment />`;
src/nft/components/bag/bag.test.tsx
0 → 100644
View file @
0987a311
import
{
render
}
from
'
test-utils
'
import
Bag
from
'
./Bag
'
jest
.
mock
(
'
@web3-react/core
'
,
()
=>
{
const
web3React
=
jest
.
requireActual
(
'
@web3-react/core
'
)
return
{
useWeb3React
:
()
=>
({
account
:
'
0x52270d8234b864dcAC9947f510CE9275A8a116Db
'
,
isActive
:
true
,
}),
...
web3React
,
}
})
describe
(
'
Bag.tsx
'
,
()
=>
{
it
(
'
matches base snapshot
'
,
()
=>
{
const
{
asFragment
}
=
render
(<
Bag
/>)
expect
(
asFragment
()).
toMatchSnapshot
()
})
})
src/pages/Pool/CTACards.test.tsx
View file @
0987a311
import
*
as
useV3Positions
from
'
hooks/useV3Positions
'
import
*
as
useV3Positions
from
'
hooks/useV3Positions
'
import
{
BrowserRouter
as
Router
}
from
'
react-router-dom
'
import
{
render
,
screen
}
from
'
test-utils
'
import
{
render
,
screen
}
from
'
test-utils
'
import
CTACards
from
'
./CTACards
'
import
CTACards
from
'
./CTACards
'
...
@@ -20,11 +19,7 @@ describe('CTAcard links', () => {
...
@@ -20,11 +19,7 @@ describe('CTAcard links', () => {
return
{
loading
:
false
,
positions
:
undefined
}
return
{
loading
:
false
,
positions
:
undefined
}
})
})
render
(
render
(<
CTACards
/>)
<
Router
>
<
CTACards
/>
</
Router
>
)
expect
(
screen
.
getByTestId
(
'
cta-infolink
'
)).
toHaveAttribute
(
'
href
'
,
'
https://info.uniswap.org/#/pools
'
)
expect
(
screen
.
getByTestId
(
'
cta-infolink
'
)).
toHaveAttribute
(
'
href
'
,
'
https://info.uniswap.org/#/pools
'
)
})
})
})
})
src/pages/Pool/index.test.tsx
View file @
0987a311
import
*
as
chains
from
'
constants/chains
'
import
*
as
chains
from
'
constants/chains
'
import
*
as
useV3Positions
from
'
hooks/useV3Positions
'
import
*
as
useV3Positions
from
'
hooks/useV3Positions
'
import
{
BrowserRouter
as
Router
}
from
'
react-router-dom
'
import
{
render
,
screen
}
from
'
test-utils
'
import
{
render
,
screen
}
from
'
test-utils
'
import
Pool
from
'
.
'
import
Pool
from
'
.
'
...
@@ -22,11 +21,7 @@ describe('networks', () => {
...
@@ -22,11 +21,7 @@ describe('networks', () => {
return
{
loading
:
false
,
positions
:
undefined
}
return
{
loading
:
false
,
positions
:
undefined
}
})
})
render
(
render
(<
Pool
/>)
<
Router
>
<
Pool
/>
</
Router
>
)
expect
(
screen
.
getByText
(
'
Your connected network is unsupported.
'
)).
toBeInTheDocument
()
expect
(
screen
.
getByText
(
'
Your connected network is unsupported.
'
)).
toBeInTheDocument
()
})
})
...
@@ -36,11 +31,7 @@ describe('networks', () => {
...
@@ -36,11 +31,7 @@ describe('networks', () => {
return
{
loading
:
false
,
positions
:
undefined
}
return
{
loading
:
false
,
positions
:
undefined
}
})
})
render
(
render
(<
Pool
/>)
<
Router
>
<
Pool
/>
</
Router
>
)
expect
(
screen
.
getByText
(
'
Your active V3 liquidity positions will appear here.
'
)).
toBeInTheDocument
()
expect
(
screen
.
getByText
(
'
Your active V3 liquidity positions will appear here.
'
)).
toBeInTheDocument
()
})
})
})
})
src/test-utils.tsx
View file @
0987a311
...
@@ -3,9 +3,12 @@ import { I18nProvider } from '@lingui/react'
...
@@ -3,9 +3,12 @@ import { I18nProvider } from '@lingui/react'
import
{
render
}
from
'
@testing-library/react
'
import
{
render
}
from
'
@testing-library/react
'
import
Web3Provider
from
'
components/Web3Provider
'
import
Web3Provider
from
'
components/Web3Provider
'
import
{
DEFAULT_LOCALE
}
from
'
constants/locales
'
import
{
DEFAULT_LOCALE
}
from
'
constants/locales
'
import
{
BlockNumberProvider
}
from
'
lib/hooks/useBlockNumber
'
import
{
en
}
from
'
make-plural/plurals
'
import
{
en
}
from
'
make-plural/plurals
'
import
{
ReactElement
,
ReactNode
}
from
'
react
'
import
{
ReactElement
,
ReactNode
}
from
'
react
'
import
{
QueryClient
,
QueryClientProvider
}
from
'
react-query
'
import
{
Provider
}
from
'
react-redux
'
import
{
Provider
}
from
'
react-redux
'
import
{
HashRouter
}
from
'
react-router-dom
'
import
store
from
'
state
'
import
store
from
'
state
'
import
ThemeProvider
from
'
theme
'
import
ThemeProvider
from
'
theme
'
...
@@ -20,14 +23,21 @@ i18n.loadLocaleData({
...
@@ -20,14 +23,21 @@ i18n.loadLocaleData({
i18n
.
activate
(
DEFAULT_LOCALE
)
i18n
.
activate
(
DEFAULT_LOCALE
)
const
MockedI18nProvider
=
({
children
}:
any
)
=>
<
I18nProvider
i18n=
{
i18n
}
>
{
children
}
</
I18nProvider
>
const
MockedI18nProvider
=
({
children
}:
any
)
=>
<
I18nProvider
i18n=
{
i18n
}
>
{
children
}
</
I18nProvider
>
const
queryClient
=
new
QueryClient
()
const
WithProviders
=
({
children
}:
{
children
?:
ReactNode
})
=>
{
const
WithProviders
=
({
children
}:
{
children
?:
ReactNode
})
=>
{
return
(
return
(
<
MockedI18nProvider
>
<
MockedI18nProvider
>
<
Provider
store=
{
store
}
>
<
Provider
store=
{
store
}
>
<
Web3Provider
>
<
QueryClientProvider
client=
{
queryClient
}
>
<
ThemeProvider
>
{
children
}
</
ThemeProvider
>
<
HashRouter
>
</
Web3Provider
>
<
Web3Provider
>
<
BlockNumberProvider
>
<
ThemeProvider
>
{
children
}
</
ThemeProvider
>
</
BlockNumberProvider
>
</
Web3Provider
>
</
HashRouter
>
</
QueryClientProvider
>
</
Provider
>
</
Provider
>
</
MockedI18nProvider
>
</
MockedI18nProvider
>
)
)
...
...
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