From e10828e5c4273f887a161e01afa8e02f88a5627c Mon Sep 17 00:00:00 2001 From: apanizo Date: Mon, 4 Jun 2018 13:26:07 +0200 Subject: [PATCH] WA-238 disable Withdrawn button --- src/routes/safe/component/Safe/DailyLimit.jsx | 6 ++++-- src/routes/safe/component/Safe/index.jsx | 2 +- src/routes/safe/test/Safe.withdrawn.test.js | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/routes/safe/component/Safe/DailyLimit.jsx b/src/routes/safe/component/Safe/DailyLimit.jsx index 9be98714..c44326c0 100644 --- a/src/routes/safe/component/Safe/DailyLimit.jsx +++ b/src/routes/safe/component/Safe/DailyLimit.jsx @@ -10,14 +10,16 @@ import { type DailyLimit } from '~/routes/safe/store/model/dailyLimit' type Props = { dailyLimit: DailyLimit, onWithdrawn: () => void, + balance: string, } export const WITHDRAWN_BUTTON_TEXT = 'Withdrawn' -const DailyLimitComponent = ({ dailyLimit, onWithdrawn }: Props) => { +const DailyLimitComponent = ({ dailyLimit, balance, onWithdrawn }: Props) => { const limit = dailyLimit.get('value') const spentToday = dailyLimit.get('spentToday') - const disabled = spentToday >= limit + + const disabled = spentToday >= limit || Number(balance) === 0 const text = `${limit} ETH (spent today: ${spentToday} ETH)` return ( diff --git a/src/routes/safe/component/Safe/index.jsx b/src/routes/safe/component/Safe/index.jsx index 6852dc1b..8e88fff2 100644 --- a/src/routes/safe/component/Safe/index.jsx +++ b/src/routes/safe/component/Safe/index.jsx @@ -71,7 +71,7 @@ class GnoSafe extends React.PureComponent {
- + diff --git a/src/routes/safe/test/Safe.withdrawn.test.js b/src/routes/safe/test/Safe.withdrawn.test.js index ba77d4e0..c260f997 100644 --- a/src/routes/safe/test/Safe.withdrawn.test.js +++ b/src/routes/safe/test/Safe.withdrawn.test.js @@ -104,4 +104,18 @@ describe('React DOM TESTS > Withdrawn funds from safe', () => { expect(addTxButton.props.disabled).toBe(false) }) + + it('Withdrawn button disabled when balance is 0', async () => { + const Safe = TestUtils.findRenderedComponentWithType(SafeDom, SafeView) + // $FlowFixMe + const buttons = TestUtils.scryRenderedComponentsWithType(Safe, Button) + const addTxButton = buttons[0] + expect(addTxButton.props.children).toEqual(WITHDRAWN_BUTTON_TEXT) + expect(addTxButton.props.disabled).toBe(true) + + await addEtherTo(address, '0.1') + await sleep(1800) + + expect(addTxButton.props.disabled).toBe(false) + }) })