Define missing types

nightwatch-ts
ioedeveloper 4 years ago
parent 31dd550714
commit a199d4a89e
  1. 22
      apps/remix-ide-e2e/src/commands/switchBrowserTab.ts
  2. 4
      apps/remix-ide-e2e/src/helpers/init.ts
  3. 8
      apps/remix-ide-e2e/src/tests/ballot.test.ts
  4. 9
      apps/remix-ide-e2e/src/tests/sample.test.ts
  5. 60
      apps/remix-ide-e2e/src/tests/sauce.ts
  6. 8
      apps/remix-ide-e2e/src/types/index.d.ts

@ -0,0 +1,22 @@
import { NightwatchBrowser } from "nightwatch"
const EventEmitter = require('events')
/*
Switches between browser tabs
*/
class SwitchBrowserTab extends EventEmitter {
command (this: NightwatchBrowser, index: number) {
this.api.perform((browser: NightwatchBrowser, done: VoidFunction) => {
browser.windowHandles((result) => {
browser.switchWindow(result.value[index])
done()
})
this.emit('complete')
})
return this
}
}
module.exports = SwitchBrowserTab

@ -2,7 +2,7 @@ import { NightwatchBrowser } from "nightwatch"
require('dotenv').config()
module.exports = function (browser: NightwatchBrowser, callback: CallableFunction, url: string, preloadPlugins = true) {
export default function (browser: NightwatchBrowser, callback: VoidFunction, url?: string, preloadPlugins = true): void {
browser
.url(url || 'http://127.0.0.1:8080')
.pause(5000)
@ -24,7 +24,7 @@ module.exports = function (browser: NightwatchBrowser, callback: CallableFunctio
})
}
function initModules (browser, callback) {
function initModules (browser: NightwatchBrowser, callback: VoidFunction) {
browser.pause(5000)
.click('[data-id="verticalIconsKindpluginManager"]')
.scrollAndClick('[data-id="pluginManagerComponentActivateButtonsolidityStaticAnalysis"]')

@ -1,17 +1,17 @@
'use strict'
import { NightwatchBrowser, NightwatchCallbackResult } from 'nightwatch'
import * as init from '../helpers/init'
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
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: NightwatchBrowser, done: NightwatchCallbackResult<void>) {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {

@ -1,9 +0,0 @@
module.exports = {
before: function (browser, done) {
done()
},
'Test Computation': function (browser) {
browser
.url('https://google.com')
}
}

@ -0,0 +1,60 @@
// const https = require('https')
export default function sauce (callback: VoidFunction): void {
if (typeof callback === 'function') return callback()
/*
const currentTest = this.client.currentTest
const username = this.client.options.username
const sessionId = this.client.capabilities['webdriver.remote.sessionid']
const accessKey = this.client.options.accessKey
if (!username || !accessKey || !sessionId) {
console.log(this.client)
console.log('No username, accessKey or sessionId')
return callback()
}
const passed = currentTest.results.passed === currentTest.results.tests
const data = JSON.stringify({passed})
const requestPath = `/rest/v1/${username}/jobs/${sessionId}`
function responseCallback (res) {
res.setEncoding('utf8')
console.log('Response: ', res.statusCode, JSON.stringify(res.headers))
res.on('data', function onData (chunk) {
console.log('BODY: ' + chunk)
})
res.on('end', function onEnd () {
console.info('Finished updating saucelabs')
callback()
})
}
try {
console.log('Updating saucelabs', requestPath)
const req = https.request({
hostname: 'saucelabs.com',
path: requestPath,
method: 'PUT',
auth: `${username}:${accessKey}`,
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}, responseCallback)
req.on('error', function onError (e) {
console.log('problem with request: ' + e.message)
})
req.write(data)
req.end()
} catch (error) {
console.log('Error', error)
callback()
}
*/
}

@ -4,12 +4,14 @@ import { NightwatchBrowser, NightwatchAPI, NightwatchBrowser, NightwatchBrowser
declare module "nightwatch" {
export interface NightwatchCustomCommands {
clickLaunchIcon(this: NightwatchBrowser, icon: string),
switchBrowserTab(this: NightwatchBrowser, index: number)
clickLaunchIcon(this: NightwatchBrowser, icon: string): NightwatchBrowser,
switchBrowserTab(this: NightwatchBrowser, index: number): NightwatchBrowser
}
export interface NightwatchBrowser {
api: NightwatchAPI,
emit: (status: string) => void
emit: (status: string) => void,
fullscreenWindow: (result?: any) => this,
injectScript: (scriptUrl: string, callback?: VoidFunction) => this
}
}
Loading…
Cancel
Save