From 4c911ab63ecde756c2d48f0b360f5cc274f3dea9 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 14 Jan 2021 15:25:04 +0100 Subject: [PATCH] Fix gist test --- .env | 2 +- apps/remix-ide-e2e/src/commands/addFile.ts | 15 ++++++++++----- apps/remix-ide-e2e/src/tests/gist.test.ts | 10 +++++----- apps/remix-ide-e2e/src/types/index.d.ts | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.env b/.env index 8db17993d7..e22d6a6ab8 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -gist_token= +gist_token=41ecc30018511d0eaecd7fa4bd479f3263b61a48 account_passphrase= account_password= NODE_OPTIONS=--max-old-space-size=2048 \ No newline at end of file diff --git a/apps/remix-ide-e2e/src/commands/addFile.ts b/apps/remix-ide-e2e/src/commands/addFile.ts index e3d8821a3c..07f0949ada 100644 --- a/apps/remix-ide-e2e/src/commands/addFile.ts +++ b/apps/remix-ide-e2e/src/commands/addFile.ts @@ -2,9 +2,9 @@ import { NightwatchBrowser, NightwatchContractContent } from 'nightwatch' import EventEmitter from "events" class AddFile extends EventEmitter { - command (this: NightwatchBrowser, name: string, content: NightwatchContractContent): NightwatchBrowser { + command (this: NightwatchBrowser, name: string, content: NightwatchContractContent, open = true): NightwatchBrowser { this.api.perform((done) => { - addFile(this.api, name, content, () => { + addFile(this.api, name, content, open, () => { done() this.emit('complete') }) @@ -13,13 +13,18 @@ class AddFile extends EventEmitter { } } -function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) { +function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, open: boolean, done: VoidFunction) { browser.clickLaunchIcon('udapp').clickLaunchIcon('fileExplorers').click('.newFile') .pause(2000) .keys(name) .keys(browser.Keys.ENTER) - .openFile('browser/' + name) - .setEditorValue(content.content) + .perform((done) => { + if (open) { + browser.openFile('browser/' + name) + .setEditorValue(content.content) + } + done() + }) .pause(1000) .perform(function () { done() diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index 5c4901f8a4..9d3e8bb1db 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -27,17 +27,17 @@ module.exports = { .refresh() .pause(10000) .waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) - .clickLaunchIcon('fileExplorers') .click('[data-id="fileExplorerNewFilecreateNewFolder"]') .pause(1000) .keys('Browser_Tests') .keys(browser.Keys.ENTER) - .waitForElementVisible('*[data-id="treeViewLibrowser/Browser_Tests"]') - .addFile('File.sol', { content: '' }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItembrowser/Browser_Tests"]') + .addFile('File.sol', { content: '' }, false) .click('*[data-id="fileExplorerNewFilepublishToGist"]') .waitForElementVisible('*[data-id="modalDialogContainer-react"]') .pause(2000) .click('.modal-ok') + .pause(10000) .getText('[data-id="modalDialogModalBody-react"]', (result) => { console.log(result) const value = typeof result.value === 'string' ? result.value : null @@ -53,8 +53,8 @@ module.exports = { .click('[data-id="modal-footer-cancel-react"]') .executeScript(`remix.loadgist('${gistid}')`) .perform((done) => { if (runtimeBrowser === 'chrome') { browser.openFile('browser/gists') } done() }) - .waitForElementVisible(`li[key="browser/gists/${gistid}"]`) - .click(`li[key="browser/gists/${gistid}"]`) + .waitForElementVisible(`[data-id="treeViewLitreeViewItembrowser/gists/${gistid}"]`) + .click(`[data-id="treeViewLitreeViewItembrowser/gists/${gistid}"]`) .openFile(`browser/gists/${gistid}/README.txt`) } }) diff --git a/apps/remix-ide-e2e/src/types/index.d.ts b/apps/remix-ide-e2e/src/types/index.d.ts index 320cee78a4..3490e90ade 100644 --- a/apps/remix-ide-e2e/src/types/index.d.ts +++ b/apps/remix-ide-e2e/src/types/index.d.ts @@ -10,7 +10,7 @@ declare module "nightwatch" { scrollInto(target: string): NightwatchBrowser, testContracts(fileName: string, contractCode: NightwatchContractContent, compiledContractNames: string[]): NightwatchBrowser, setEditorValue(value: string, callback?: () => void): NightwatchBrowser, - addFile(name: string, content: NightwatchContractContent): NightwatchBrowser, + addFile(name: string, content: NightwatchContractContent, open?: boolean): NightwatchBrowser, verifyContracts(compiledContractNames: string[], opts?: { wait: number, version?: string }): NightwatchBrowser, selectAccount(account?: string): NightwatchBrowser, clickFunction(fnFullName: string, expectedInput?: NightwatchClickFunctionExpectedInput): NightwatchBrowser,