Merge pull request #229 from poanetwork/bool-select

(Feature) Select input for Boolean type for contract type acc
This commit is contained in:
Victor Baranov 2018-12-26 16:09:57 +03:00 committed by GitHub
commit 67466deb02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 29 deletions

View File

@ -17,7 +17,6 @@ class SendTransactionField extends Component {
this.state = {
val: props.defaultValue,
}
this.timerID = null
}
static propTypes = {
@ -40,11 +39,11 @@ class SendTransactionField extends Component {
placeholder={this.props.placeholder}
value={this.state.val}
disabled={this.props.disabled}
onChange={e => {
onChange={(e) => {
this.setState({
val: e.target.value,
})
this.props.onChange(e)
this.props.onChange(e.target.value)
}}
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 {
constructor (props) {
super(props)
@ -71,6 +109,7 @@ class SendTransactionScreen extends PersistentForm {
copyDisabled: true,
}
this.timerID = null
PersistentForm.call(this)
}
@ -184,16 +223,27 @@ class SendTransactionScreen extends PersistentForm {
})
}
}
const field = (
<SendTransactionField
key={Math.random()}
ind={ind}
disabled={!isInput}
placeholder={params.type}
defaultValue={defaultValue}
onChange={e => isInput ? this.handleInputChange(e.target.value, params.type, ind) : null}
/>
)
let field
if (params.type === 'bool' && isInput) {
field = (
<SendTransactionInputSelect
ind={ind}
defaultValue={defaultValue}
onChange={val => this.handleInputChange(val, params.type, ind)}
/>
)
} 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 = (
<div key={`method_label_container_${ind}`}>
{label}

View File

@ -108,3 +108,4 @@ async function verboseReportOnFailure ({ browser, driver, title }) {
const htmlSource = await driver.getPageSource()
await fs.writeFile(`${filepathBase}-dom.html`, htmlSource)
}

View File

@ -532,7 +532,6 @@ describe('Metamask popup page', async function () {
})
})
describe('Check output for data type : BOOLEAN', () => {
it("Select method 'returnBoolean'", async function () {
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
await field.click()
@ -542,11 +541,14 @@ describe('Metamask popup page', async function () {
assert.equal(list.length, 22, "drop down menu isn't displayed")
})
it('Fill out input parameter field, value is TRUE', async function () {
await waitUntilShowUp(screens.executeMethod.fieldParameter)
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
await fields[0].sendKeys('true')
it('Select value TRUE from dropdown menu', async function () {
const arrows = await driver.findElements(screens.executeMethod.selectArrow)
await arrows[1].click()
await waitUntilShowUp(screens.executeMethod.items)
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 () {
@ -560,16 +562,19 @@ describe('Metamask popup page', async function () {
await delay(3000)
await waitUntilShowUp(screens.executeMethod.fieldOutput)
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
const text = await waitUntilHasValue(fields[1])
assert.notEqual(fields[0], false, "field 'Output' isn't displayed")
const text = await waitUntilHasValue(fields[0])
assert.equal(text, 'true', 'incorrect value was returned')
})
it('Fill out input parameter field, value is FALSE ', async function () {
await waitUntilShowUp(screens.executeMethod.fieldParameter)
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
await clearField(fields[0])
await fields[0].sendKeys('false')
it('Select value FALSE from dropdown menu', async function () {
const arrows = await driver.findElements(screens.executeMethod.selectArrow)
await arrows[1].click()
await waitUntilShowUp(screens.executeMethod.items)
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 () {
@ -583,8 +588,8 @@ describe('Metamask popup page', async function () {
await delay(3000)
await waitUntilShowUp(screens.executeMethod.fieldOutput)
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
const text = await waitUntilHasValue(fields[1])
assert.notEqual(fields[0], false, "field 'Output' isn't displayed")
const text = await waitUntilHasValue(fields[0])
assert.equal(text, 'false', 'incorrect value was returned')
})
it('icon copy cliboard is displayed and clickable', async function () {