|
1 | | -import { NightwatchBrowser, NightwatchTestConstantFunctionExpectedInput } from 'nightwatch' |
| 1 | +import { |
| 2 | + NightwatchBrowser, |
| 3 | + NightwatchTestConstantFunctionExpectedInput |
| 4 | +} from 'nightwatch' |
2 | 5 | import EventEmitter from 'events' |
3 | 6 |
|
4 | 7 | class TestConstantFunction extends EventEmitter { |
5 | | - command (this: NightwatchBrowser, address: string, fnFullName: string, expectedInput: NightwatchTestConstantFunctionExpectedInput | null, expectedOutput: string): NightwatchBrowser { |
| 8 | + command( |
| 9 | + this: NightwatchBrowser, |
| 10 | + address: string, |
| 11 | + fnFullName: string, |
| 12 | + expectedInput: NightwatchTestConstantFunctionExpectedInput | null, |
| 13 | + expectedOutput: string |
| 14 | + ): NightwatchBrowser { |
6 | 15 | console.log('TestConstantFunction ' + address + ' fnFullName') |
7 | 16 | this.api.perform((done) => { |
8 | | - testConstantFunction(this.api, address, fnFullName, expectedInput, expectedOutput, () => { |
9 | | - done() |
10 | | - this.emit('complete') |
11 | | - }) |
| 17 | + testConstantFunction( |
| 18 | + this.api, |
| 19 | + address, |
| 20 | + fnFullName, |
| 21 | + expectedInput, |
| 22 | + expectedOutput, |
| 23 | + () => { |
| 24 | + done() |
| 25 | + this.emit('complete') |
| 26 | + } |
| 27 | + ) |
12 | 28 | }) |
13 | 29 | return this |
14 | 30 | } |
15 | 31 | } |
16 | 32 |
|
17 | | -function testConstantFunction (browser: NightwatchBrowser, address: string, fnFullName: string, expectedInput: NightwatchTestConstantFunctionExpectedInput, expectedOutput: string, cb: VoidFunction) { |
18 | | - browser.waitForElementPresent('.instance button[data-title="' + fnFullName + '"]').perform(function (client, done) { |
19 | | - client.execute(function () { |
20 | | - document.querySelector('#runTabView').scrollTop = document.querySelector('#runTabView').scrollHeight |
21 | | - }, [], function () { |
22 | | - if (expectedInput) { |
23 | | - client.waitForElementPresent('#runTabView input[data-title="' + expectedInput.types + '"]') |
24 | | - .setValue('#runTabView input[data-title="' + expectedInput.types + '"]', expectedInput.values) |
25 | | - } |
26 | | - done() |
| 33 | +function testConstantFunction( |
| 34 | + browser: NightwatchBrowser, |
| 35 | + address: string, |
| 36 | + fnFullName: string, |
| 37 | + expectedInput: NightwatchTestConstantFunctionExpectedInput, |
| 38 | + expectedOutput: string, |
| 39 | + cb: VoidFunction |
| 40 | +) { |
| 41 | + browser |
| 42 | + .waitForElementPresent('.instance *[data-title="' + fnFullName + '"]') |
| 43 | + .perform(function (client, done) { |
| 44 | + client.execute( |
| 45 | + function () { |
| 46 | + document.querySelector('#runTabView').scrollTop = |
| 47 | + document.querySelector('#runTabView').scrollHeight |
| 48 | + }, |
| 49 | + [], |
| 50 | + function () { |
| 51 | + if (expectedInput) { |
| 52 | + client |
| 53 | + .waitForElementPresent( |
| 54 | + '#runTabView input[data-title="' + expectedInput.types + '"]' |
| 55 | + ) |
| 56 | + .setValue( |
| 57 | + '#runTabView input[data-title="' + expectedInput.types + '"]', |
| 58 | + expectedInput.values |
| 59 | + ) |
| 60 | + } |
| 61 | + done() |
| 62 | + } |
| 63 | + ) |
27 | 64 | }) |
28 | | - }) |
29 | | - .click(`#instance${address} button[data-title="${fnFullName}"]`) |
| 65 | + .click(`#instance${address} *[data-title="${fnFullName}"]`) |
30 | 66 | .pause(1000) |
31 | | - .waitForElementPresent('#instance' + address + ' .udapp_contractActionsContainer .udapp_value') |
32 | | - .scrollInto('#instance' + address + ' .udapp_contractActionsContainer .udapp_value') |
33 | | - .assert.containsText('#instance' + address + ' .udapp_contractActionsContainer', expectedOutput).perform(() => { |
| 67 | + .waitForElementPresent( |
| 68 | + '#instance' + address + ' .udapp_contractActionsContainer .udapp_value' |
| 69 | + ) |
| 70 | + .scrollInto( |
| 71 | + '#instance' + address + ' .udapp_contractActionsContainer .udapp_value' |
| 72 | + ) |
| 73 | + .assert.containsText( |
| 74 | + '#instance' + address + ' .udapp_contractActionsContainer', |
| 75 | + expectedOutput |
| 76 | + ) |
| 77 | + .perform(() => { |
34 | 78 | cb() |
35 | 79 | }) |
36 | 80 | } |
|
0 commit comments