aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan Miller <danjm.com@gmail.com>2018-11-06 01:01:46 +0800
committerDan Miller <danjm.com@gmail.com>2018-12-04 11:36:22 +0800
commitb70886a99b466366e84d24271adbb890aebf6460 (patch)
treeb4ce415c80ec78120306d358c20d4c51744c8db3 /ui
parenta8259f7f6a26fe5ae21b26b2a5c05dfdb09e32bd (diff)
downloadtangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar
tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.gz
tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.bz2
tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.lz
tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.xz
tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.tar.zst
tangerine-wallet-browser-b70886a99b466366e84d24271adbb890aebf6460.zip
Fixes for components that break e2e gas customization tests, plus unit test updates.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/gas-customization/gas-price-chart/gas-price-chart.component.js2
-rw-r--r--ui/app/components/gas-customization/gas-price-chart/tests/gas-price-chart.component.test.js2
-rw-r--r--ui/app/components/send/send-content/send-gas-row/gas-fee-display/gas-fee-display.component.js6
-rw-r--r--ui/app/components/send/send-content/send-gas-row/gas-fee-display/test/gas-fee-display.component.test.js8
-rw-r--r--ui/app/components/send/send-content/send-gas-row/send-gas-row.component.js6
-rw-r--r--ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js12
-rw-r--r--ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-component.test.js15
-rw-r--r--ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js13
-rw-r--r--ui/app/ducks/tests/gas-duck.test.js59
9 files changed, 102 insertions, 21 deletions
diff --git a/ui/app/components/gas-customization/gas-price-chart/gas-price-chart.component.js b/ui/app/components/gas-customization/gas-price-chart/gas-price-chart.component.js
index 993dd0a2b..5ca465ba9 100644
--- a/ui/app/components/gas-customization/gas-price-chart/gas-price-chart.component.js
+++ b/ui/app/components/gas-customization/gas-price-chart/gas-price-chart.component.js
@@ -19,7 +19,7 @@ export default class GasPriceChart extends Component {
gasPrices: PropTypes.array,
estimatedTimes: PropTypes.array,
gasPricesMax: PropTypes.number,
- estimatedTimesMax: PropTypes.number,
+ estimatedTimesMax: PropTypes.string,
currentPrice: PropTypes.number,
updateCustomGasPrice: PropTypes.func,
}
diff --git a/ui/app/components/gas-customization/gas-price-chart/tests/gas-price-chart.component.test.js b/ui/app/components/gas-customization/gas-price-chart/tests/gas-price-chart.component.test.js
index 158813edb..46341195b 100644
--- a/ui/app/components/gas-customization/gas-price-chart/tests/gas-price-chart.component.test.js
+++ b/ui/app/components/gas-customization/gas-price-chart/tests/gas-price-chart.component.test.js
@@ -51,7 +51,7 @@ const testProps = {
gasPrices: [1.5, 2.5, 4, 8],
estimatedTimes: [100, 80, 40, 10],
gasPricesMax: 9,
- estimatedTimesMax: 100,
+ estimatedTimesMax: '100',
currentPrice: 6,
updateCustomGasPrice: propsMethodSpies.updateCustomGasPrice,
}
diff --git a/ui/app/components/send/send-content/send-gas-row/gas-fee-display/gas-fee-display.component.js b/ui/app/components/send/send-content/send-gas-row/gas-fee-display/gas-fee-display.component.js
index 40f8b1fe0..b667aa037 100644
--- a/ui/app/components/send/send-content/send-gas-row/gas-fee-display/gas-fee-display.component.js
+++ b/ui/app/components/send/send-content/send-gas-row/gas-fee-display/gas-fee-display.component.js
@@ -11,7 +11,7 @@ export default class GasFeeDisplay extends Component {
convertedCurrency: PropTypes.string,
gasLoadingError: PropTypes.bool,
gasTotal: PropTypes.string,
- showGasButtonGroup: PropTypes.func,
+ onReset: PropTypes.func,
};
static contextTypes = {
@@ -19,7 +19,7 @@ export default class GasFeeDisplay extends Component {
};
render () {
- const { gasTotal, onClick, gasLoadingError } = this.props
+ const { gasTotal, gasLoadingError, onReset } = this.props
return (
<div className="send-v2__gas-fee-display">
@@ -47,7 +47,7 @@ export default class GasFeeDisplay extends Component {
}
<button
className="gas-fee-reset"
- onClick={showGasButtonGroup}
+ onClick={onReset}
>
{ this.context.t('reset') }
</button>
diff --git a/ui/app/components/send/send-content/send-gas-row/gas-fee-display/test/gas-fee-display.component.test.js b/ui/app/components/send/send-content/send-gas-row/gas-fee-display/test/gas-fee-display.component.test.js
index c7ac175d9..cb4180508 100644
--- a/ui/app/components/send/send-content/send-gas-row/gas-fee-display/test/gas-fee-display.component.test.js
+++ b/ui/app/components/send/send-content/send-gas-row/gas-fee-display/test/gas-fee-display.component.test.js
@@ -8,9 +8,10 @@ import sinon from 'sinon'
const propsMethodSpies = {
showCustomizeGasModal: sinon.spy(),
+ onReset: sinon.spy(),
}
-describe('SendGasRow Component', function () {
+describe('GasFeeDisplay Component', function () {
let wrapper
beforeEach(() => {
@@ -20,6 +21,7 @@ describe('SendGasRow Component', function () {
primaryCurrency={'mockPrimaryCurrency'}
convertedCurrency={'mockConvertedCurrency'}
showGasButtonGroup={propsMethodSpies.showCustomizeGasModal}
+ onReset={propsMethodSpies.onReset}
/>, {context: {t: str => str + '_t'}})
})
@@ -47,9 +49,9 @@ describe('SendGasRow Component', function () {
className,
} = wrapper.find('button').props()
assert.equal(className, 'gas-fee-reset')
- assert.equal(propsMethodSpies.showCustomizeGasModal.callCount, 0)
+ assert.equal(propsMethodSpies.onReset.callCount, 0)
onClick()
- assert.equal(propsMethodSpies.showCustomizeGasModal.callCount, 1)
+ assert.equal(propsMethodSpies.onReset.callCount, 1)
})
it('should render the reset button with the correct text', () => {
diff --git a/ui/app/components/send/send-content/send-gas-row/send-gas-row.component.js b/ui/app/components/send/send-content/send-gas-row/send-gas-row.component.js
index 507407306..8d305dd4f 100644
--- a/ui/app/components/send/send-content/send-gas-row/send-gas-row.component.js
+++ b/ui/app/components/send/send-content/send-gas-row/send-gas-row.component.js
@@ -14,8 +14,8 @@ export default class SendGasRow extends Component {
gasTotal: PropTypes.string,
showCustomizeGasModal: PropTypes.func,
gasPriceButtonGroupProps: PropTypes.object,
- showGasButtonGroup: PropTypes.func,
gasButtonGroupShown: PropTypes.bool,
+ resetGasButtons: PropTypes.func,
}
static contextTypes = {
@@ -32,7 +32,7 @@ export default class SendGasRow extends Component {
showCustomizeGasModal,
gasPriceButtonGroupProps,
gasButtonGroupShown,
- showGasButtonGroup,
+ resetGasButtons,
} = this.props
return (
@@ -57,7 +57,7 @@ export default class SendGasRow extends Component {
convertedCurrency={convertedCurrency}
gasLoadingError={gasLoadingError}
gasTotal={gasTotal}
- showGasButtonGroup={showGasButtonGroup}
+ onReset={resetGasButtons}
onClick={() => showCustomizeGasModal()}
/>}
diff --git a/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js b/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
index dd16559d0..39266e590 100644
--- a/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
+++ b/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js
@@ -13,6 +13,9 @@ import {
import {
showGasButtonGroup,
} from '../../../../ducks/send.duck'
+import {
+ resetCustomData,
+} from '../../../../ducks/gas.duck'
import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js'
import { showModal, setGasPrice } from '../../../../actions'
import SendGasRow from './send-gas-row.component'
@@ -44,13 +47,17 @@ function mapDispatchToProps (dispatch) {
showCustomizeGasModal: () => dispatch(showModal({ name: 'CUSTOMIZE_GAS', hideBasic: true })),
setGasPrice: newPrice => dispatch(setGasPrice(newPrice)),
showGasButtonGroup: () => dispatch(showGasButtonGroup()),
+ resetCustomData: () => dispatch(resetCustomData()),
}
}
function mergeProps (stateProps, dispatchProps, ownProps) {
const { gasPriceButtonGroupProps } = stateProps
+ const { gasButtonInfo } = gasPriceButtonGroupProps
const {
setGasPrice: dispatchSetGasPrice,
+ showGasButtonGroup: dispatchShowGasButtonGroup,
+ resetCustomData: dispatchResetCustomData,
...otherDispatchProps
} = dispatchProps
@@ -62,5 +69,10 @@ function mergeProps (stateProps, dispatchProps, ownProps) {
...gasPriceButtonGroupProps,
handleGasPriceSelection: dispatchSetGasPrice,
},
+ resetGasButtons: () => {
+ dispatchResetCustomData()
+ dispatchSetGasPrice(gasButtonInfo[1].priceInHexWei)
+ dispatchShowGasButtonGroup()
+ },
}
}
diff --git a/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-component.test.js b/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-component.test.js
index 171cd7bf6..059c6cdd3 100644
--- a/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-component.test.js
+++ b/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-component.test.js
@@ -10,6 +10,7 @@ import GasPriceButtonGroup from '../../../../gas-customization/gas-price-button-
const propsMethodSpies = {
showCustomizeGasModal: sinon.spy(),
+ resetGasButtons: sinon.spy(),
}
describe('SendGasRow Component', function () {
@@ -22,9 +23,9 @@ describe('SendGasRow Component', function () {
gasFeeError={'mockGasFeeError'}
gasLoadingError={false}
gasTotal={'mockGasTotal'}
- showGasButtonGroup={'mockShowGasPriceButtonGroup'}
gasButtonGroupShown={false}
showCustomizeGasModal={propsMethodSpies.showCustomizeGasModal}
+ resetGasButtons={propsMethodSpies.resetGasButtons}
gasPriceButtonGroupProps={{
someGasPriceButtonGroupProp: 'foo',
anotherGasPriceButtonGroupProp: 'bar',
@@ -33,7 +34,7 @@ describe('SendGasRow Component', function () {
})
afterEach(() => {
- propsMethodSpies.showCustomizeGasModal.resetHistory()
+ propsMethodSpies.resetGasButtons.resetHistory()
})
describe('render', () => {
@@ -63,17 +64,15 @@ describe('SendGasRow Component', function () {
convertedCurrency,
gasLoadingError,
gasTotal,
- onClick,
- showGasButtonGroup,
+ onReset,
} = wrapper.find(SendRowWrapper).childAt(0).props()
assert.equal(conversionRate, 20)
assert.equal(convertedCurrency, 'mockConvertedCurrency')
assert.equal(gasLoadingError, false)
assert.equal(gasTotal, 'mockGasTotal')
- assert.equal(showGasButtonGroup, 'mockShowGasPriceButtonGroup')
- assert.equal(propsMethodSpies.showCustomizeGasModal.callCount, 0)
- onClick()
- assert.equal(propsMethodSpies.showCustomizeGasModal.callCount, 1)
+ assert.equal(propsMethodSpies.resetGasButtons.callCount, 0)
+ onReset()
+ assert.equal(propsMethodSpies.resetGasButtons.callCount, 1)
})
it('should render the GasPriceButtonGroup if gasButtonGroupShown is true', () => {
diff --git a/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js b/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js
index 1c385e216..766bf6cab 100644
--- a/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js
+++ b/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js
@@ -15,6 +15,10 @@ const sendDuckSpies = {
showGasButtonGroup: sinon.spy(),
}
+const gasDuckSpies = {
+ resetCustomData: sinon.spy(),
+}
+
proxyquire('../send-gas-row.container.js', {
'react-redux': {
connect: (ms, md, mp) => {
@@ -42,6 +46,7 @@ proxyquire('../send-gas-row.container.js', {
getDefaultActiveButtonIndex: (gasButtonInfo, gasPrice) => gasButtonInfo.length + gasPrice.length,
},
'../../../../ducks/send.duck': sendDuckSpies,
+ '../../../../ducks/gas.duck': gasDuckSpies,
})
describe('send-gas-row container', () => {
@@ -104,6 +109,14 @@ describe('send-gas-row container', () => {
})
})
+ describe('resetCustomData()', () => {
+ it('should dispatch an action', () => {
+ mapDispatchToPropsObject.resetCustomData()
+ assert(dispatchSpy.calledOnce)
+ assert(gasDuckSpies.resetCustomData.calledOnce)
+ })
+ })
+
})
describe('mergeProps', () => {
diff --git a/ui/app/ducks/tests/gas-duck.test.js b/ui/app/ducks/tests/gas-duck.test.js
index 96c00383b..009758cde 100644
--- a/ui/app/ducks/tests/gas-duck.test.js
+++ b/ui/app/ducks/tests/gas-duck.test.js
@@ -1,7 +1,16 @@
import assert from 'assert'
import sinon from 'sinon'
+import proxyquire from 'proxyquire'
-import GasReducer, {
+
+const GasDuck = proxyquire('../gas.duck.js', {
+ '../../lib/local-storage-helpers': {
+ loadLocalStorageData: sinon.spy(),
+ saveLocalStorageData: sinon.spy(),
+ },
+})
+
+const {
basicGasEstimatesLoadingStarted,
basicGasEstimatesLoadingFinished,
setBasicGasEstimateData,
@@ -16,7 +25,8 @@ import GasReducer, {
setPricesAndTimeEstimates,
fetchGasEstimates,
setApiEstimatesLastRetrieved,
-} from '../gas.duck.js'
+} = GasDuck
+const GasReducer = GasDuck.default
describe('Gas Duck', () => {
let tempFetch
@@ -312,6 +322,11 @@ describe('Gas Duck', () => {
describe('fetchGasEstimates', () => {
const mockDistpatch = sinon.spy()
+
+ beforeEach(() => {
+ mockDistpatch.resetHistory()
+ })
+
it('should call fetch with the expected params', async () => {
global.fetch.resetHistory()
await fetchGasEstimates(5)(mockDistpatch, () => ({ gas: Object.assign(
@@ -377,6 +392,46 @@ describe('Gas Duck', () => {
[{ type: GAS_ESTIMATE_LOADING_FINISHED }]
)
})
+
+ it('should not call fetch if the estimates were retrieved < 75000 ms ago', async () => {
+ global.fetch.resetHistory()
+ await fetchGasEstimates(5)(mockDistpatch, () => ({ gas: Object.assign(
+ {},
+ initState,
+ {
+ priceAndTimeEstimatesLastRetrieved: Date.now(),
+ priceAndTimeEstimates: [{
+ expectedTime: '10',
+ expectedWait: 2,
+ gasprice: 50,
+ }],
+ }
+ ) }))
+ assert.deepEqual(
+ mockDistpatch.getCall(0).args,
+ [{ type: GAS_ESTIMATE_LOADING_STARTED} ]
+ )
+ assert.equal(global.fetch.callCount, 0)
+
+ assert.deepEqual(
+ mockDistpatch.getCall(1).args,
+ [{
+ type: SET_PRICE_AND_TIME_ESTIMATES,
+ value: [
+ {
+ expectedTime: '10',
+ expectedWait: 2,
+ gasprice: 50,
+ },
+ ],
+
+ }]
+ )
+ assert.deepEqual(
+ mockDistpatch.getCall(2).args,
+ [{ type: GAS_ESTIMATE_LOADING_FINISHED }]
+ )
+ })
})
describe('gasEstimatesLoadingStarted', () => {