Merge pull request #229 from poanetwork/bool-select
(Feature) Select input for Boolean type for contract type acc
This commit is contained in:
commit
67466deb02
|
@ -17,7 +17,6 @@ class SendTransactionField extends Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
val: props.defaultValue,
|
val: props.defaultValue,
|
||||||
}
|
}
|
||||||
this.timerID = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -40,11 +39,11 @@ class SendTransactionField extends Component {
|
||||||
placeholder={this.props.placeholder}
|
placeholder={this.props.placeholder}
|
||||||
value={this.state.val}
|
value={this.state.val}
|
||||||
disabled={this.props.disabled}
|
disabled={this.props.disabled}
|
||||||
onChange={e => {
|
onChange={(e) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
val: e.target.value,
|
val: e.target.value,
|
||||||
})
|
})
|
||||||
this.props.onChange(e)
|
this.props.onChange(e.target.value)
|
||||||
}}
|
}}
|
||||||
style={{ marginTop: '5px' }}
|
style={{ marginTop: '5px' }}
|
||||||
/>
|
/>
|
||||||
|
@ -52,6 +51,45 @@ class SendTransactionField extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SendTransactionInputSelect extends Component {
|
||||||
|
constructor (props) {
|
||||||
|
super(props)
|
||||||
|
this.state = {
|
||||||
|
val: props.defaultValue,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
defaultValue: PropTypes.string,
|
||||||
|
value: PropTypes.string,
|
||||||
|
onChange: PropTypes.func,
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
clearable={false}
|
||||||
|
value={this.state.val}
|
||||||
|
options={[{
|
||||||
|
label: 'false',
|
||||||
|
value: 'false',
|
||||||
|
}, {
|
||||||
|
label: 'true',
|
||||||
|
value: 'true',
|
||||||
|
}]}
|
||||||
|
onChange={(opt) => {
|
||||||
|
this.setState({
|
||||||
|
val: opt.value,
|
||||||
|
})
|
||||||
|
this.props.onChange(opt.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
style={{ marginTop: '5px' }}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class SendTransactionScreen extends PersistentForm {
|
class SendTransactionScreen extends PersistentForm {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
@ -71,6 +109,7 @@ class SendTransactionScreen extends PersistentForm {
|
||||||
copyDisabled: true,
|
copyDisabled: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.timerID = null
|
||||||
PersistentForm.call(this)
|
PersistentForm.call(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,16 +223,27 @@ class SendTransactionScreen extends PersistentForm {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const field = (
|
let field
|
||||||
<SendTransactionField
|
if (params.type === 'bool' && isInput) {
|
||||||
key={Math.random()}
|
field = (
|
||||||
ind={ind}
|
<SendTransactionInputSelect
|
||||||
disabled={!isInput}
|
ind={ind}
|
||||||
placeholder={params.type}
|
defaultValue={defaultValue}
|
||||||
defaultValue={defaultValue}
|
onChange={val => this.handleInputChange(val, params.type, ind)}
|
||||||
onChange={e => isInput ? this.handleInputChange(e.target.value, params.type, ind) : null}
|
/>
|
||||||
/>
|
)
|
||||||
)
|
} else {
|
||||||
|
field = (
|
||||||
|
<SendTransactionField
|
||||||
|
key={Math.random()}
|
||||||
|
ind={ind}
|
||||||
|
disabled={!isInput}
|
||||||
|
placeholder={params.type}
|
||||||
|
defaultValue={defaultValue}
|
||||||
|
onChange={val => isInput ? this.handleInputChange(val, params.type, ind) : null}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
const fieldObj = (
|
const fieldObj = (
|
||||||
<div key={`method_label_container_${ind}`}>
|
<div key={`method_label_container_${ind}`}>
|
||||||
{label}
|
{label}
|
||||||
|
|
|
@ -108,3 +108,4 @@ async function verboseReportOnFailure ({ browser, driver, title }) {
|
||||||
const htmlSource = await driver.getPageSource()
|
const htmlSource = await driver.getPageSource()
|
||||||
await fs.writeFile(`${filepathBase}-dom.html`, htmlSource)
|
await fs.writeFile(`${filepathBase}-dom.html`, htmlSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -532,7 +532,6 @@ describe('Metamask popup page', async function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('Check output for data type : BOOLEAN', () => {
|
describe('Check output for data type : BOOLEAN', () => {
|
||||||
|
|
||||||
it("Select method 'returnBoolean'", async function () {
|
it("Select method 'returnBoolean'", async function () {
|
||||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||||
await field.click()
|
await field.click()
|
||||||
|
@ -542,11 +541,14 @@ describe('Metamask popup page', async function () {
|
||||||
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Fill out input parameter field, value is TRUE', async function () {
|
it('Select value TRUE from dropdown menu', async function () {
|
||||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
const arrows = await driver.findElements(screens.executeMethod.selectArrow)
|
||||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
await arrows[1].click()
|
||||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
await waitUntilShowUp(screens.executeMethod.items)
|
||||||
await fields[0].sendKeys('true')
|
const list = await driver.findElements(screens.executeMethod.items)
|
||||||
|
assert.equal(await list[1].getText(), 'true', 'TRUE menu item: incorrect text')
|
||||||
|
assert.equal(list.length, 2, "drop down menu isn't displayed")
|
||||||
|
await list[1].click()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Click button 'Call data' ", async function () {
|
it("Click button 'Call data' ", async function () {
|
||||||
|
@ -560,16 +562,19 @@ describe('Metamask popup page', async function () {
|
||||||
await delay(3000)
|
await delay(3000)
|
||||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
assert.notEqual(fields[0], false, "field 'Output' isn't displayed")
|
||||||
const text = await waitUntilHasValue(fields[1])
|
const text = await waitUntilHasValue(fields[0])
|
||||||
assert.equal(text, 'true', 'incorrect value was returned')
|
assert.equal(text, 'true', 'incorrect value was returned')
|
||||||
})
|
})
|
||||||
it('Fill out input parameter field, value is FALSE ', async function () {
|
|
||||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
it('Select value FALSE from dropdown menu', async function () {
|
||||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
const arrows = await driver.findElements(screens.executeMethod.selectArrow)
|
||||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
await arrows[1].click()
|
||||||
await clearField(fields[0])
|
await waitUntilShowUp(screens.executeMethod.items)
|
||||||
await fields[0].sendKeys('false')
|
const list = await driver.findElements(screens.executeMethod.items)
|
||||||
|
assert.equal(await list[0].getText(), 'false', 'FALSE menu item: incorrect text')
|
||||||
|
assert.equal(list.length, 2, "drop down menu isn't displayed")
|
||||||
|
await list[0].click()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Click button 'Call data' ", async function () {
|
it("Click button 'Call data' ", async function () {
|
||||||
|
@ -583,8 +588,8 @@ describe('Metamask popup page', async function () {
|
||||||
await delay(3000)
|
await delay(3000)
|
||||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
assert.notEqual(fields[0], false, "field 'Output' isn't displayed")
|
||||||
const text = await waitUntilHasValue(fields[1])
|
const text = await waitUntilHasValue(fields[0])
|
||||||
assert.equal(text, 'false', 'incorrect value was returned')
|
assert.equal(text, 'false', 'incorrect value was returned')
|
||||||
})
|
})
|
||||||
it('icon copy cliboard is displayed and clickable', async function () {
|
it('icon copy cliboard is displayed and clickable', async function () {
|
||||||
|
|
Loading…
Reference in New Issue