-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default to null balance instead of 0 (show '-' for unknown balance) #916
Conversation
MegaLinter status: ✅ SUCCESS
See errors details in artifact MegaLinter reports on CI Job page |
Codecov Report
@@ Coverage Diff @@
## master #916 +/- ##
==========================================
+ Coverage 87.74% 87.77% +0.03%
==========================================
Files 98 97 -1
Lines 1640 1628 -12
Branches 358 360 +2
==========================================
- Hits 1439 1429 -10
+ Misses 201 199 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
gonna have to ask about this on the issue |
const history = createMemoryHistory() | ||
history.push('/account/account_address') | ||
const page = renderPage(store, history) | ||
it('with missing delegations', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not create a snapshot for with missing delegations
test? Both snapshots creates +2k lines and in most cases they are useless as one snapshot already covers page layout markup and styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. I would like it capture:
- "Couldn't load delegations."
- "API appears to be down"
-
Total balance - Available 100.0 Staked - Debonding -
- "Active delegations ()" (so we notice if this breaks. i18n uses "count" to signify plurality, but we give it
null
)
without sprinkling data-testid everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to:
oasis-wallet-web/src/app/pages/AccountPage/__tests__/index.test.tsx
Lines 84 to 90 in 93184ec
expect(page.container).toHaveTextContent('Oasis Scan API appears to be down') | |
const balance = await screen.findByTestId('account-balance-total') | |
expect(balance).toHaveTextContent('-') | |
const balanceSummary = await screen.findByTestId('account-balance-summary') | |
expect(balanceSummary.textContent).toMatchSnapshot() | |
const tabs = await screen.findByRole('navigation') | |
expect(tabs.textContent).toMatchSnapshot() |
oasis-wallet-web/src/app/pages/AccountPage/__tests__/__snapshots__/index.test.tsx.snap
Lines 1225 to 1227 in 93184ec
exports[`<AccountPage /> with missing delegations 1`] = `"Total balance-Available100.0 Staked-Debonding-"`; | |
exports[`<AccountPage /> with missing delegations 2`] = `"TransactionsActive delegations ()Debonding delegations ()"`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, thanks
@@ -147,13 +151,13 @@ export function AccountPage(props: Props) { | |||
<NavItem | |||
route={`/account/${address}/active-delegations`} | |||
label={t('account.subnavigation.activeDelegations', 'Active delegations ({{count}})', { | |||
count: stake.delegations.length, | |||
count: stake.delegations?.length ?? null!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to show a label with an empty bracket when nullish coalescing operator returns its right-hand side operand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it displays Active delegations ()
More effort solutions:
- add another translation string
stake.delegations ? t(account.subnavigation.activeDelegations) : t(account.subnavigation.activeDelegationsNull)
- use a different field:
count
is used for plurality and needs to be a number, andnull
workaround could break. Make that other field a string, so it can be e.g.-
too, and update translations
93184ec
to
a533303
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually prefer -
to ?
, I think it is prettier and looks more professional.
Fixes #816