Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
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
vicotor
frontend
Commits
b970f662
Commit
b970f662
authored
May 03, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue with zero values in gas tracker
parent
5ddd4557
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
40 deletions
+48
-40
GasTrackerPriceSnippet.pw.tsx
ui/gasTracker/GasTrackerPriceSnippet.pw.tsx
+42
-35
GasTrackerPriceSnippet.tsx
ui/gasTracker/GasTrackerPriceSnippet.tsx
+4
-4
GasTrackerPriceSnippet.pw.tsx_default_with-zero-values-1.png
...TrackerPriceSnippet.pw.tsx_default_with-zero-values-1.png
+0
-0
GasTracker.tsx
ui/pages/GasTracker.tsx
+2
-1
No files found.
ui/gasTracker/GasTrackerPriceSnippet.pw.tsx
View file @
b970f662
import
{
test
,
expect
}
from
'
@playwright/experimental-ct-react
'
;
import
React
from
'
react
'
;
import
*
as
statsMock
from
'
mocks/stats/index
'
;
import
contextWithEnvs
from
'
playwright/fixtures/contextWithEnvs
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
{
test
,
expect
}
from
'
playwright/lib
'
;
import
*
as
configs
from
'
playwright/utils/configs
'
;
import
GasTrackerPriceSnippet
from
'
./GasTrackerPriceSnippet
'
;
...
...
@@ -13,48 +11,57 @@ test.use({ viewport: configs.viewport.md });
const
data
=
statsMock
.
base
.
gas_prices
.
fast
;
const
clip
=
{
x
:
0
,
y
:
0
,
width
:
334
,
height
:
204
};
test
(
'
with usd as primary unit +@dark-mode
'
,
async
({
mount
,
page
})
=>
{
await
mount
(
<
TestApp
>
test
(
'
with usd as primary unit +@dark-mode
'
,
async
({
render
,
page
})
=>
{
await
render
(
<
GasTrackerPriceSnippet
data=
{
data
}
type=
"fast"
isLoading=
{
false
}
/>
</
TestApp
>,
/>,
);
await
expect
(
page
).
toHaveScreenshot
({
clip
});
});
test
(
'
loading state
'
,
async
({
mount
,
page
})
=>
{
await
mount
(
<
TestApp
>
test
(
'
loading state
'
,
async
({
render
,
page
})
=>
{
await
render
(
<
GasTrackerPriceSnippet
data=
{
data
}
type=
"fast"
isLoading=
{
true
}
/>
</
TestApp
>,
/>,
);
await
expect
(
page
).
toHaveScreenshot
({
clip
});
});
const
gweiUnitsTest
=
test
.
extend
({
context
:
contextWithEnvs
([
{
name
:
'
NEXT_PUBLIC_GAS_TRACKER_UNITS
'
,
value
:
'
["gwei","usd"]
'
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
])
as
any
,
test
(
'
with gwei as primary unit +@dark-mode
'
,
async
({
render
,
page
,
mockEnvs
})
=>
{
await
mockEnvs
([
[
'
NEXT_PUBLIC_GAS_TRACKER_UNITS
'
,
'
["gwei","usd"]
'
],
]);
await
render
(
<
GasTrackerPriceSnippet
data=
{
data
}
type=
"slow"
isLoading=
{
false
}
/>,
);
await
expect
(
page
).
toHaveScreenshot
({
clip
});
});
gweiUnitsTest
(
'
with gwei as primary unit +@dark-mode
'
,
async
({
mount
,
page
})
=>
{
await
mount
(
<
TestApp
>
test
(
'
with zero values
'
,
async
({
render
,
page
})
=>
{
const
data
=
{
fiat_price
:
'
1.74
'
,
price
:
0.0
,
time
:
0
,
base_fee
:
0
,
priority_fee
:
0
,
};
await
render
(
<
GasTrackerPriceSnippet
data=
{
data
}
type=
"slow"
isLoading=
{
false
}
/>
</
TestApp
>,
/>,
);
await
expect
(
page
).
toHaveScreenshot
({
clip
});
});
ui/gasTracker/GasTrackerPriceSnippet.tsx
View file @
b970f662
...
...
@@ -50,14 +50,14 @@ const GasTrackerPriceSnippet = ({ data, type, isLoading }: Props) => {
</
Skeleton
>
</
Flex
>
<
Skeleton
isLoaded=
{
!
isLoading
}
fontSize=
"sm"
color=
"text_secondary"
mt=
{
3
}
w=
"fit-content"
>
{
data
.
price
&&
data
.
fiat_price
&&
<
GasPrice
data=
{
data
}
prefix=
{
`${ asymp } `
}
unitMode=
"secondary"
/>
}
{
data
.
price
!==
null
&&
data
.
fiat_price
!==
null
&&
<
GasPrice
data=
{
data
}
prefix=
{
`${ asymp } `
}
unitMode=
"secondary"
/>
}
<
span
>
per transaction
</
span
>
{
typeof
data
.
time
===
'
number
'
&&
data
.
time
>
0
&&
<
span
>
/
{
(
data
.
time
/
SECOND
).
toLocaleString
(
undefined
,
{
maximumFractionDigits
:
1
})
}
s
</
span
>
}
</
Skeleton
>
<
Skeleton
isLoaded=
{
!
isLoading
}
fontSize=
"sm"
color=
"text_secondary"
mt=
{
2
}
w=
"fit-content"
whiteSpace=
"pre"
>
{
data
.
base_fee
&&
<
span
>
Base
{
data
.
base_fee
.
toLocaleString
(
undefined
,
{
maximumFractionDigits
:
0
})
}
</
span
>
}
{
data
.
base_fee
&&
data
.
priority_fee
&&
<
span
>
/
</
span
>
}
{
data
.
priority_fee
&&
<
span
>
Priority
{
data
.
priority_fee
.
toLocaleString
(
undefined
,
{
maximumFractionDigits
:
0
})
}
</
span
>
}
{
typeof
data
.
base_fee
===
'
number
'
&&
<
span
>
Base
{
data
.
base_fee
.
toLocaleString
(
undefined
,
{
maximumFractionDigits
:
0
})
}
</
span
>
}
{
typeof
data
.
base_fee
===
'
number
'
&&
typeof
data
.
priority_fee
===
'
number
'
&&
<
span
>
/
</
span
>
}
{
typeof
data
.
priority_fee
===
'
number
'
&&
<
span
>
Priority
{
data
.
priority_fee
.
toLocaleString
(
undefined
,
{
maximumFractionDigits
:
0
})
}
</
span
>
}
</
Skeleton
>
</
Box
>
);
...
...
ui/gasTracker/__screenshots__/GasTrackerPriceSnippet.pw.tsx_default_with-zero-values-1.png
0 → 100644
View file @
b970f662
8.77 KB
ui/pages/GasTracker.tsx
View file @
b970f662
...
...
@@ -36,7 +36,8 @@ const GasTracker = () => {
rowGap=
{
1
}
flexDir=
{
{
base
:
'
column
'
,
lg
:
'
row
'
}
}
>
{
data
?.
network_utilization_percentage
&&
<
GasTrackerNetworkUtilization
percentage=
{
data
.
network_utilization_percentage
}
isLoading=
{
isLoading
}
/>
}
{
typeof
data
?.
network_utilization_percentage
===
'
number
'
&&
<
GasTrackerNetworkUtilization
percentage=
{
data
.
network_utilization_percentage
}
isLoading=
{
isLoading
}
/>
}
{
data
?.
gas_price_updated_at
&&
(
<
Skeleton
isLoaded=
{
!
isLoading
}
whiteSpace=
"pre"
display=
"flex"
alignItems=
"center"
>
<
span
>
Last updated
</
span
>
...
...
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