Skip to content

Commit

Permalink
fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Apr 29, 2020
1 parent 6fe5bfc commit 43461cf
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 56 deletions.
2 changes: 1 addition & 1 deletion ci/browser_tests_chrome_part2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ setupRemixd

sleep 5

npm run nightwatch_local_generalSettings || TEST_EXITCODE=1
npm run nightwatch_local_ballot || TEST_EXITCODE=1
npm run nightwatch_local_gist || TEST_EXITCODE=1
npm run nightwatch_local_workspace || TEST_EXITCODE=1
npm run nightwatch_local_defaultLayout || TEST_EXITCODE=1
npm run nightwatch_local_pluginManager || TEST_EXITCODE=1
npm run nightwatch_local_publishContract || TEST_EXITCODE=1
npm run nightwatch_local_generalSettings || TEST_EXITCODE=1
npm run nightwatch_local_fileExplorer || TEST_EXITCODE=1
npm run nightwatch_local_debugger || TEST_EXITCODE=1
npm run nightwatch_local_editor || TEST_EXITCODE=1
Expand Down
2 changes: 1 addition & 1 deletion ci/browser_tests_firefox_part2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ setupRemixd

sleep 5

npm run nightwatch_local_generalSettings_firefox || TEST_EXITCODE=1
npm run nightwatch_local_ballot_firefox || TEST_EXITCODE=1
npm run nightwatch_local_gist_firefox || TEST_EXITCODE=1
npm run nightwatch_local_workspace_firefox || TEST_EXITCODE=1
npm run nightwatch_local_defaultLayout_firefox || TEST_EXITCODE=1
npm run nightwatch_local_pluginManager_firefox || TEST_EXITCODE=1
npm run nightwatch_local_publishContract_firefox || TEST_EXITCODE=1
npm run nightwatch_local_generalSettings_firefox || TEST_EXITCODE=1
npm run nightwatch_local_fileExplorer_firefox || TEST_EXITCODE=1
npm run nightwatch_local_debugger_firefox || TEST_EXITCODE=1
npm run nightwatch_local_editor_firefox || TEST_EXITCODE=1
Expand Down
24 changes: 24 additions & 0 deletions test-browser/commands/waitForElementContainsText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const EventEmitter = require('events')

class WaitForElementContainsText extends EventEmitter {
command (id, value) {
let incr = 0
let runid = setInterval(() => {
this.api.getText(id, (result) => {
if (value.indexOf(result.value || '') !== -1) {
clearInterval(runid)
this.api.assert.ok(true, `WaitForElementContainsText ${id} contains ${value}`)
this.emit('complete')
} else incr++
if (incr > 50) {
clearInterval(runid)
this.api.assert.fail(`WaitForElementContainsText - expected ${value} but got ${result.value}`)
// throw new Error(`WaitForElementContainsText ${id} ${value}`)
}
})
}, 200)
return this
}
}

module.exports = WaitForElementContainsText
107 changes: 53 additions & 54 deletions test-browser/tests/generalSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,68 @@ module.exports = {

'Should display settings menu': function (browser) {
browser.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
.click('*[data-id="landingPageStartSolidity"]')
.clickElementAtPosition('*[data-id="landingPageStartSolidity"]')
.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.click('*[data-id="verticalIconsKindsettings"]')
.waitForElementVisible('*[data-id="settingsTabSettingsView"]')
.assert.containsText('h6[data-id="sidePanelSwapitTitle"]', 'SETTINGS')
.clickElementAtPosition('*[data-id="verticalIconsKindsettings"]')
.waitForElementContainsText('h6[data-id="sidePanelSwapitTitle"]', 'SETTINGS')
},

'Should open gitter channel in a new tab when `Gitter Channel Button` is clicked': function (browser) {
const runtimeBrowser = browser.capabilities.browserName

browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]')
.waitForElementVisible('*[data-id="settingsTabGitterChannelButton"]')
.click('*[data-id="settingsTabGitterChannelButton"]')
.waitForElementVisible('*[data-id="settingsTabGitterChannelButton"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabGitterChannelButton"]')
.pause(2000)
.perform((done) => { if (runtimeBrowser === 'chrome') { browser.switchBrowserTab(1).assert.urlContains('https://gitter.im/ethereum/remix') } done() })
},

'Should activate `generate contract metadata`': function (browser) {
browser.switchBrowserTab(0)
.waitForElementVisible('*[data-id="remixIdeSidePanel"]')
.waitForElementVisible('*[data-id="settingsTabGenerateContractMetadata"]')
.click('*[data-id="settingsTabGenerateContractMetadata"]')
.click('*[data-id="verticalIconsFileExplorerIcons"]')
.waitForElementVisible('*[data-id="remixIdeSidePanel"]', 5000)
.waitForElementVisible('*[data-id="settingsTabGenerateContractMetadata"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabGenerateContractMetadata"]')
.clickElementAtPosition('*[data-id="verticalIconsFileExplorerIcons"]')
.switchFile('browser/3_Ballot.sol')
.click('*[data-id="verticalIconsKindsolidity"]')
.clickElementAtPosition('*[data-id="verticalIconsKindsolidity"]')
.pause(2000)
.click('*[data-id="compilerContainerCompileBtn"]')
.clickElementAtPosition('*[data-id="compilerContainerCompileBtn"]')
.pause(3000)
.click('*[data-id="verticalIconsKindfileExplorers"]')
.clickElementAtPosition('*[data-id="verticalIconsKindfileExplorers"]')
.switchFile('browser/artifacts')
.switchFile('browser/artifacts/Ballot.json')
},

'Should add new github access token': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="verticalIconsKindsettings"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="verticalIconsKindsettings"]')
.setValue('*[data-id="settingsTabGistAccessToken"]', '**********')
.click('*[data-id="settingsTabSaveGistToken"]')
.waitForElementVisible('*[data-shared="tooltipPopup"]:nth-last-of-type(1)')
.clickElementAtPosition('*[data-id="settingsTabSaveGistToken"]')
.waitForElementVisible('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 5000)
.assert.containsText('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 'Access token saved')
.click('*[data-id="tooltipCloseButton"]')
.clickElementAtPosition('*[data-id="tooltipCloseButton"]')
},

'Should copy github access token to clipboard': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="copyToClipboardCopyIcon"]')
.waitForElementVisible('*[data-shared="tooltipPopup"]:nth-last-of-type(1)')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="copyToClipboardCopyIcon"]')
.waitForElementVisible('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 5000)
.assert.containsText('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 'Copied value to clipboard.')
.click('*[data-id="tooltipCloseButton"]')
.clickElementAtPosition('*[data-id="tooltipCloseButton"]')
},

'Should remove github access token': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabRemoveGistToken"]')
.waitForElementVisible('*[data-shared="tooltipPopup"]:nth-last-of-type(1)')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabRemoveGistToken"]')
.waitForElementVisible('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 5000)
.assert.containsText('*[data-shared="tooltipPopup"]:nth-last-of-type(1)', 'Access token removed')
.assert.containsText('*[data-id="settingsTabGistAccessToken"]', '')
.click('*[data-id="tooltipCloseButton"]')
.clickElementAtPosition('*[data-id="tooltipCloseButton"]')
},

'Should load dark theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeDark"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeDark"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.dark.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.dark.secondary)
Expand All @@ -82,8 +81,8 @@ module.exports = {
},

'Should load light theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeLight"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeLight"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.light.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.light.secondary)
Expand All @@ -94,8 +93,8 @@ module.exports = {
},

'Should load Cerulean theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeCerulean"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeCerulean"]')
.pause(5000)
.checkElementStyle(':root', '--primary', remixIdeThemes.curelean.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.curelean.secondary)
Expand All @@ -106,8 +105,8 @@ module.exports = {
},

'Should load Flatly theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeFlatly"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeFlatly"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.flatly.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.flatly.secondary)
Expand All @@ -118,8 +117,8 @@ module.exports = {
},

'Should load Lumen theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeLumen"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeLumen"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.lumen.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.lumen.secondary)
Expand All @@ -130,8 +129,8 @@ module.exports = {
},

'Should load Minty theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeMinty"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeMinty"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.minty.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.minty.secondary)
Expand All @@ -142,8 +141,8 @@ module.exports = {
},

'Should load Pulse theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemePulse"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemePulse"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.pulse.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.pulse.secondary)
Expand All @@ -154,8 +153,8 @@ module.exports = {
},

'Should load Sandstone theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeSandstone"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeSandstone"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.sandstone.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.sandstone.secondary)
Expand All @@ -166,8 +165,8 @@ module.exports = {
},

'Should load Spacelab theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeSpacelab"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeSpacelab"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.spacelab.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.spacelab.secondary)
Expand All @@ -178,8 +177,8 @@ module.exports = {
},

'Should load Yeti theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeYeti"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeYeti"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.yeti.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.yeti.secondary)
Expand All @@ -190,8 +189,8 @@ module.exports = {
},

'Should load Cyborg theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeCyborg"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeCyborg"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.cyborg.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.cyborg.secondary)
Expand All @@ -202,8 +201,8 @@ module.exports = {
},

'Should load Darkly theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeDarkly"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeDarkly"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.darkly.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.darkly.secondary)
Expand All @@ -214,8 +213,8 @@ module.exports = {
},

'Should load Slate theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeSlate"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeSlate"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.slate.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.slate.secondary)
Expand All @@ -226,8 +225,8 @@ module.exports = {
},

'Should load Superhero theme': function (browser) {
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]')
.click('*[data-id="settingsTabThemeSuperhero"]')
browser.waitForElementVisible('*[data-id="verticalIconsKindsettings"]', 5000)
.clickElementAtPosition('*[data-id="settingsTabThemeSuperhero"]')
.pause(2000)
.checkElementStyle(':root', '--primary', remixIdeThemes.superhero.primary)
.checkElementStyle(':root', '--secondary', remixIdeThemes.superhero.secondary)
Expand Down

0 comments on commit 43461cf

Please sign in to comment.