Add custom commands types

pull/5370/head
ioedeveloper 4 years ago
parent 4b4e1c7229
commit 8d164e7860
  1. 9
      apps/remix-ide-e2e/.eslintrc
  2. 15
      apps/remix-ide-e2e/src/commands/clickLaunchIcon.ts
  3. 38
      apps/remix-ide-e2e/src/helpers/init.ts
  4. 29
      apps/remix-ide-e2e/src/tests/ballot.test.ts
  5. 15
      apps/remix-ide-e2e/src/types/index.d.ts
  6. 2
      apps/remix-ide-e2e/tsconfig.json
  7. 6
      package-lock.json
  8. 1
      package.json

@ -2,14 +2,13 @@
"rules": {},
"overrides": [
{
"files": ["src/plugins/index.js"],
"files": ["**/*.ts"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off"
"no-undef": "off",
"@typescript-eslint/no-var-requires": 0
}
}
],
"extends": ["../../.eslintrc"],
"ignorePatterns": ["!**/*"]
}
}

@ -0,0 +1,15 @@
import { NightwatchBrowser } from "nightwatch"
const EventEmitter = require('events')
class ClickLaunchIcon extends EventEmitter {
command (this: NightwatchBrowser, icon: string) {
this.api.waitForElementVisible('#icon-panel div[plugin="' + icon + '"]').click('#icon-panel div[plugin="' + icon + '"]').perform((done: CallableFunction) => {
done()
this.emit('complete')
})
return this
}
}
module.exports = ClickLaunchIcon

@ -0,0 +1,38 @@
import { NightwatchBrowser } from "nightwatch"
require('dotenv').config()
module.exports = function (browser: NightwatchBrowser, callback: CallableFunction, url: string, preloadPlugins = true) {
browser
.url(url || 'http://127.0.0.1:8080')
.pause(5000)
.switchBrowserTab(0)
.injectScript('test-browser/helpers/applytestmode.js', function () {
browser.fullscreenWindow(() => {
if (preloadPlugins) {
console.log('preloadPlugins: ', preloadPlugins)
initModules(browser, () => {
browser.clickLaunchIcon('solidity')
.waitForElementPresent('[for="autoCompile"]')
.click('[for="autoCompile"]')
})
}
})
})
.perform(() => {
callback()
})
}
function initModules (browser, callback) {
browser.pause(5000)
.click('[data-id="verticalIconsKindpluginManager"]')
.scrollAndClick('[data-id="pluginManagerComponentActivateButtonsolidityStaticAnalysis"]')
.scrollAndClick('[data-id="pluginManagerComponentActivateButtondebugger"]')
.scrollAndClick('[data-id="verticalIconsKindfileExplorers"]')
.clickLaunchIcon('settings')
.setValue('[data-id="settingsTabGistAccessToken"]', process.env.gist_token)
.click('[data-id="settingsTabSaveGistToken"]')
.click('[data-id="settingsTabThemeFlatly"]') // e2e tests were initially developed with Flatly. Some tests are failing with the default one (Dark), because the dark theme put uppercase everywhere.
.perform(() => { callback() })
}

@ -1,20 +1,23 @@
'use strict'
var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var sources = [
{'browser/Untitled.sol': {content: examples.ballot.content}}
import { NightwatchBrowser, NightwatchCallbackResult } from 'nightwatch'
import * as init from '../helpers/init'
const examples = require('../../../../../apps/remix-ide/src/app/editor/example-contracts') // reference example-contracts from inside dist directory
const sauce = require('./sauce')
const sources = [
{'browser/Untitled.sol': { content: examples.ballot.content }}
]
module.exports = {
before: function (browser, done) {
before: function (browser: NightwatchBrowser, done: NightwatchCallbackResult<void>) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Deploy Ballot': function (browser) {
'Deploy Ballot': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.clickLaunchIcon('solidity')
@ -34,7 +37,7 @@ module.exports = {
})
},
'Debug Ballot / delegate': function (browser) {
'Debug Ballot / delegate': function (browser: NightwatchBrowser) {
browser.pause(500)
.click('*[data-id="txLoggerDebugButton0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3"]')
.pause(2000)
@ -47,7 +50,7 @@ module.exports = {
.checkVariableDebug('soliditylocals', localsCheck)
},
'Access Ballot via at address': function (browser) {
'Access Ballot via at address': function (browser: NightwatchBrowser) {
browser.clickLaunchIcon('udapp')
.click('*[data-id="universalDappUiUdappClose"]')
.addFile('ballot.abi', { content: ballotABI })
@ -66,7 +69,7 @@ module.exports = {
})
},
'Deploy and use Ballot using external web3': function (browser) {
'Deploy and use Ballot using external web3': function (browser: NightwatchBrowser) {
browser
.click('*[data-id="settingsWeb3Mode"]')
.modalFooterOKClick()
@ -86,14 +89,14 @@ module.exports = {
tearDown: sauce
}
var localsCheck = {
const localsCheck = {
'to': {
'value': '0x4B0897B0513FDC7C541B6D9D7E929C4E5364D2DB',
'type': 'address'
}
}
var stateCheck = {
const stateCheck = {
'chairperson': {
'value': '0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C',
'type': 'address',
@ -148,7 +151,7 @@ var stateCheck = {
}
}
var ballotABI = `[
const ballotABI = `[
{
"inputs": [
{

@ -0,0 +1,15 @@
// Merge custom command types with nightwatch types
import { NightwatchBrowser, NightwatchAPI, NightwatchBrowser, NightwatchBrowser } from "nightwatch";
declare module "nightwatch" {
export interface NightwatchCustomCommands {
clickLaunchIcon(this: NightwatchBrowser, icon: string),
switchBrowserTab(this: NightwatchBrowser, index: number)
}
export interface NightwatchBrowser {
api: NightwatchAPI,
emit: (status: string) => void
}
}

@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["node"]
"types": ["node", "nightwatch"]
},
"include": ["**/*.ts", "**/*.js"]
}

6
package-lock.json generated

@ -6824,6 +6824,12 @@
"integrity": "sha512-ZvO2tAcjmMi8V/5Z3JsyofMe3hasRcaw88cto5etSVMwVQfeivGAlEYmaQgceUSVYFofVjT+ioHsATjdWcFt1w==",
"dev": true
},
"@types/nightwatch": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/@types/nightwatch/-/nightwatch-1.1.6.tgz",
"integrity": "sha512-QFreK7brv9R6gc0J1sqm2kYzMaQtDSMRyK1btna+GrqvrqVypWsY2XwuYn3x/45kMcdHKnhZQDQfqts3yK/cEw==",
"dev": true
},
"@types/node": {
"version": "8.9.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.9.5.tgz",

@ -165,6 +165,7 @@
"@resolver-engine/imports": "^0.3.0",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/nightwatch": "^1.1.6",
"@types/node": "~8.9.4",
"@types/react": "16.9.17",
"@types/react-dom": "16.9.4",

Loading…
Cancel
Save