Added defaultLayout tests

pull/343/head
ioedeveloper 4 years ago
parent e023afa8dc
commit 6c5a8da9a3
  1. 1
      apps/remix-ide-e2e/.eslintrc
  2. 31
      apps/remix-ide-e2e/src/commands/checkElementStyle.ts
  3. 27
      apps/remix-ide-e2e/src/commands/openFile.ts
  4. 80
      apps/remix-ide-e2e/src/tests/defaultLayout.test.ts
  5. 4
      apps/remix-ide-e2e/src/types/index.d.ts
  6. 1
      apps/remix-ide-e2e/tsconfig.json

@ -9,5 +9,6 @@
}
}
],
"extends": ["../../.eslintrc"],
"ignorePatterns": ["!**/*"]
}

@ -0,0 +1,31 @@
import EventEmitter from "events"
import { NightwatchBrowser } from 'nightwatch'
class checkElementStyle extends EventEmitter {
command (this: NightwatchBrowser, cssSelector: string, styleProperty: string, expectedResult: string): NightwatchBrowser {
this.api.perform((done) => {
checkStyle(this.api, cssSelector, styleProperty, expectedResult, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkStyle (browser: NightwatchBrowser, cssSelector: string, styleProperty: string, expectedResult: string, callback: VoidFunction) {
browser.execute(function (cssSelector, styleProperty) {
return window.getComputedStyle(document.querySelector(cssSelector)).getPropertyValue(styleProperty)
}, [cssSelector, styleProperty], function (result) {
const value = result.value
if (typeof value === 'string') {
browser.assert.equal(value.trim(), expectedResult)
} else {
browser.assert.fail('Failed with error info :', result.value.toString())
}
callback()
})
}
module.exports = checkElementStyle

@ -0,0 +1,27 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events"
class OpenFile extends EventEmitter {
command (this: NightwatchBrowser, name: string) {
this.api.perform((done) => {
openFile(this.api, name, () => {
done()
this.emit('complete')
})
})
return this
}
}
// click on fileExplorer can toggle it. We go through settings to be sure FE is open
function openFile (browser: NightwatchBrowser, name: string, done: VoidFunction) {
browser.clickLaunchIcon('settings').clickLaunchIcon('fileExplorers')
.waitForElementVisible('li[key="' + name + '"]')
.click('li[key="' + name + '"]')
.pause(2000)
.perform(() => {
done()
})
}
module.exports = OpenFile

@ -0,0 +1,80 @@
'use strict'
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import sauce from './sauce'
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080', false)
},
'Loads Icon\'s Panel': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="remixIdeIconPanel"]', 10000)
.waitForElementVisible('div[data-id="verticalIconsHomeIcon"]')
.waitForElementVisible('div[plugin="fileExplorers"]')
.waitForElementVisible('div[plugin="pluginManager"]')
.waitForElementVisible('div[plugin="settings"]')
},
'Loads Side Panel': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="remixIdeSidePanel"]')
.assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS')
.waitForElementVisible('div[data-id="filePanelFileExplorerTree"]')
.waitForElementVisible('li[key="browser/3_Ballot.sol"]')
},
'Loads Main View': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="mainPanelPluginsContainer"]')
.waitForElementVisible('div[data-id="landingPageHomeContainer"]')
.waitForElementVisible('div[data-id="landingPageHpSections"]')
.waitForElementVisible('div[data-id="terminalContainer"]')
},
'Loads terminal': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('div[data-id="terminalCli"]', 10000)
.journalLastChildIncludes('Welcome to Remix')
},
'Toggles Side Panel': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="remixIdeSidePanel"]')
.assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS')
.clickLaunchIcon('fileExplorers')
.assert.hidden('div[data-id="remixIdeSidePanel"]')
.clickLaunchIcon('fileExplorers')
.assert.visible('div[data-id="remixIdeSidePanel"]')
.assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'FILE EXPLORERS')
},
'Toggles Terminal': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('div[data-id="terminalContainer"]')
.assert.visible('div[data-id="terminalContainerDisplay"]')
.click('i[data-id="terminalToggleIcon"]')
.checkElementStyle('div[data-id="terminalToggleMenu"]', 'height', '35px')
.click('i[data-id="terminalToggleIcon"]')
.assert.visible('div[data-id="terminalContainerDisplay"]')
},
'Toggles File Explorer Browser': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('div[data-id="filePanelFileExplorerTree"]')
.assert.visible('ul[key="browser"]')
.click('div[data-id="treeViewTogglebrowser"]')
.assert.hidden('ul[key="browser"]')
.click('div[data-id="treeViewTogglebrowser"]')
.assert.visible('ul[key="browser"]')
},
'Switch Tabs using tabs icon': function (browser: NightwatchBrowser) {
browser
.waitForElementVisible('div[data-id="filePanelFileExplorerTree"]')
.openFile('browser/3_Ballot.sol')
.assert.containsText('div[title="browser/3_Ballot.sol"]', '3_Ballot.sol')
.click('span[class^=dropdownCaret]')
.click('#homeItem')
.assert.containsText('div[title="home"]', 'Home')
.end()
},
tearDown: sauce
}

@ -24,7 +24,9 @@ declare module "nightwatch" {
executeScript(script: string): NightwatchBrowser,
clearEditableContent(cssSelector: string): NightwatchBrowser,
journalChildIncludes(val: string): NightwatchBrowser,
debugTransaction(index: number): NightwatchBrowser
debugTransaction(index: number): NightwatchBrowser,
checkElementStyle(cssSelector: string, styleProperty: string, expectedResult: string): NightwatchBrowser,
openFile(name: string): NightwatchBrowser
}
export interface NightwatchBrowser {

@ -3,6 +3,7 @@
"compilerOptions": {
"types": ["node", "nightwatch"],
"esModuleInterop": true,
"strict": true
},
"include": ["**/*.ts", "**/*.js"]
}

Loading…
Cancel
Save