Skip to content

Commit 541ab94

Browse files
committed
fix(neuron-ui): fix the relationship between transaction price and speed
1 parent ca38b40 commit 541ab94

2 files changed

Lines changed: 49 additions & 12 deletions

File tree

packages/neuron-ui/src/components/TransactionFeePanel/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const TransactionFee: React.FunctionComponent<TransactionFee> = ({
3838
const selectedSpeed = calculateSpeed(+price)
3939

4040
return (
41-
<Stack tokens={{ childrenGap: 15 }}>
41+
<Stack tokens={{ childrenGap: 15 }} aria-label="transaction fee">
4242
<Stack horizontal verticalAlign="end" horizontalAlign="space-between">
4343
<Stack horizontal tokens={{ childrenGap: 20 }} styles={{ root: { width: leftStackWidth } }}>
4444
<Stack.Item styles={{ root: { width: labelWidth } }}>
@@ -76,7 +76,7 @@ const TransactionFee: React.FunctionComponent<TransactionFee> = ({
7676
<Label>{t('send.price')}</Label>
7777
</Stack.Item>
7878
<Stack.Item grow>
79-
<TextField value={price} onChange={onPriceChange} />
79+
<TextField value={price} onChange={onPriceChange} aria-label="price" />
8080
</Stack.Item>
8181
{actionSpacer}
8282
</Stack>
@@ -90,10 +90,10 @@ const TransactionFee: React.FunctionComponent<TransactionFee> = ({
9090
dropdownWidth={140}
9191
selectedKey={selectedSpeed}
9292
options={[
93-
{ key: '0', text: 'immediately' },
94-
{ key: '30', text: '~ 30s' },
95-
{ key: '60', text: '~ 1min' },
96-
{ key: '180', text: '~ 3min' },
93+
{ key: '180', text: 'immediately' },
94+
{ key: '60', text: '~ 30s' },
95+
{ key: '30', text: '~ 1min' },
96+
{ key: '0', text: '~ 3min' },
9797
]}
9898
onRenderCaretDown={() => {
9999
return <Icon iconName="ArrowDown" />
@@ -103,6 +103,7 @@ const TransactionFee: React.FunctionComponent<TransactionFee> = ({
103103
onPriceChange(e, item.key)
104104
}
105105
}}
106+
aria-label="expected speed"
106107
/>
107108
</Stack.Item>
108109
</Stack>

packages/neuron-wallet/tests-e2e/tests/sendTransaction.ts

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ export default (app: Application) => {
2525
await app.waitUntilLoaded()
2626
})
2727

28-
afterEach(async() => {
28+
afterEach(async () => {
2929
const { client } = app.spectron
3030
client.click('button[type=reset]')
3131
await client.waitUntilWindowLoaded()
3232
})
3333

3434
describe('Test address field boundary validation', () => {
3535
app.test('Invalid address should show alert', async () => {
36-
const { client } = app.spectron
36+
const { client } = app.spectron
3737
const invalidAddress = 'invalid-address'
3838
const inputs = await app.elements('input')
3939
client.elementIdValue(inputs.value[0].ELEMENT, invalidAddress)
@@ -52,7 +52,6 @@ export default (app: Application) => {
5252
const errorMessage = await app.element('.ms-TextField-errorMessage')
5353
const msg = await client.elementIdText(errorMessage.value.ELEMENT)
5454
expect(msg.value).toBe('Address cannot be empty')
55-
5655
})
5756

5857
app.test('Valid address should not show alert', async () => {
@@ -66,8 +65,6 @@ export default (app: Application) => {
6665
})
6766
})
6867

69-
70-
7168
describe('Test amount field boundary validation', () => {
7269
const validAddress = 'ckt1qyq0cwanfaf2t2cwmuxd8ujv2ww6kjv7n53sfwv2l0'
7370
app.test('Amount 60.99999999 is too small, 61 CKB is required', async () => {
@@ -110,5 +107,44 @@ export default (app: Application) => {
110107
expect(msg.value).toBe('Amount is not enough')
111108
})
112109
})
113-
}
114110

111+
describe('Test the transaction fee operations', () => {
112+
beforeAll(async () => {
113+
const { client } = app.spectron
114+
client.click('button[role=switch]')
115+
await app.waitUntilLoaded()
116+
})
117+
118+
app.test('default price should be 0 and default speed should be 3min', async () => {
119+
const { client } = app.spectron
120+
const transactionFeePanel = client.$('div[aria-label="transaction fee"]')
121+
const [, priceField] = await transactionFeePanel.$$('input')
122+
expect((await client.elementIdAttribute(priceField.value.ELEMENT, 'value')).value).toBe('0')
123+
const speedDropdown = await client.$('div[role=listbox]')
124+
expect((await client.elementIdAttribute(speedDropdown.value.ELEMENT, 'innerText')).value).toBe('~ 3min')
125+
})
126+
127+
app.test('Change speed to immediately and the price should be 180', async () => {
128+
const { client } = app.spectron
129+
client.click('div[role=listbox]')
130+
await app.waitUntilLoaded()
131+
client.click('button[title=immediately]')
132+
await app.waitUntilLoaded()
133+
const transactionFeePanel = client.$('div[aria-label="transaction fee"]')
134+
const [, priceField] = await transactionFeePanel.$$('input')
135+
expect((await client.elementIdAttribute(priceField.value.ELEMENT, 'value')).value).toBe('180')
136+
})
137+
138+
app.test('Change the price to 150 and the speed should switch to ~ 30s', async () => {
139+
const { client } = app.spectron
140+
const transactionFeePanel = client.$('div[aria-label="transaction fee"]')
141+
const [, priceField] = await transactionFeePanel.$$('input')
142+
client.elementIdClear(priceField.value.ELEMENT)
143+
await app.waitUntilLoaded()
144+
client.elementIdValue(priceField.value.ELEMENT, '150')
145+
const speedDropdown = await client.$('div[role=listbox]')
146+
147+
expect((await client.elementIdAttribute(speedDropdown.value.ELEMENT, 'innerText')).value).toBe('~ 30s')
148+
})
149+
})
150+
}

0 commit comments

Comments
 (0)