From f0050e37e5ffbf81eb00425caa67da2681fea96a Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Fri, 5 Jan 2024 12:26:14 +0100 Subject: [PATCH] drag drop --- .../tests/file_explorer_context_menu.test.ts | 1 + .../src/tests/file_explorer_dragdrop.test.ts | 125 ++++++++++-------- 2 files changed, 71 insertions(+), 55 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/file_explorer_context_menu.test.ts b/apps/remix-ide-e2e/src/tests/file_explorer_context_menu.test.ts index 8077b5700d..3671e4a01b 100644 --- a/apps/remix-ide-e2e/src/tests/file_explorer_context_menu.test.ts +++ b/apps/remix-ide-e2e/src/tests/file_explorer_context_menu.test.ts @@ -91,6 +91,7 @@ module.exports = { .waitForElementPresent('[data-id="contextMenuItemcopy') .click('[data-id="contextMenuItemcopy"]') .rightClick('*[data-id="treeViewUltreeViewMenu"]') + .saveScreenshot('./reports/screenshot/file_explorer_context_menu.png') .click('*[data-id="contextMenuItempaste"]') .waitForElementVisible('*[data-id="treeViewLitreeViewItemCopy_README.txt"]', 7000) }, diff --git a/apps/remix-ide-e2e/src/tests/file_explorer_dragdrop.test.ts b/apps/remix-ide-e2e/src/tests/file_explorer_dragdrop.test.ts index 07a8142dc8..76e6ed446f 100644 --- a/apps/remix-ide-e2e/src/tests/file_explorer_dragdrop.test.ts +++ b/apps/remix-ide-e2e/src/tests/file_explorer_dragdrop.test.ts @@ -2,85 +2,100 @@ import { NightwatchBrowser } from 'nightwatch' import init from '../helpers/init' +const checkBrowserIsChrome = function (browser: NightwatchBrowser) { + return browser.browserName.indexOf('chrome') > -1 +} + + module.exports = { '@disabled': true, before: function (browser: NightwatchBrowser, done: VoidFunction) { init(browser, done) }, 'drag and drop file from root to contracts #group1 #flaky': function (browser: NightwatchBrowser) { - browser - .clickLaunchIcon('filePanel') - .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]') - .findElement('*[data-id="treeViewLitreeViewItemcontracts"]', (el) => { - console.log((el as any).value.getId()) - const id = (el as any).value.getId() - browser - .waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') - .dragAndDrop('li[data-id="treeViewLitreeViewItemREADME.txt"]', id) - .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') - .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]') - }) + if (checkBrowserIsChrome(browser)) { + browser + .clickLaunchIcon('filePanel') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]') + .findElement('*[data-id="treeViewLitreeViewItemcontracts"]', (el) => { + console.log((el as any).value.getId()) + const id = (el as any).value.getId() + browser + .waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') + .dragAndDrop('li[data-id="treeViewLitreeViewItemREADME.txt"]', id) + .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') + .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) + .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]') + }) + } }, 'drag and drop file from contracts to root #group1': function (browser: NightwatchBrowser) { - browser.findElement('*[data-id="treeViewUltreeViewMenu"]', (el) => { - console.log((el as any).value.getId()) - const id = (el as any).value.getId() - browser - .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]') - .dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]', id) - .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') - .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - }) - browser.pause(1000) - .waitForElementVisible('li[data-id="treeViewLitreeViewItem1_Storage.sol"]') - }, - 'drag and drop scripts from root to contracts #group1': function (browser: NightwatchBrowser) { - browser - .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]') - .findElement('*[data-id="treeViewLitreeViewItemcontracts"]', (el) => { + if (checkBrowserIsChrome(browser)) { + browser.findElement('*[data-id="treeViewUltreeViewMenu"]', (el) => { console.log((el as any).value.getId()) const id = (el as any).value.getId() browser - .waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') - .dragAndDrop('li[data-id="treeViewLitreeViewItemscripts"]', id) + .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]') + .dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]', id) .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/scripts"]') }) + browser.pause(1000) + .waitForElementVisible('li[data-id="treeViewLitreeViewItem1_Storage.sol"]') + } }, - 'drag scripts from contracts to root #group1': function (browser: NightwatchBrowser) { - browser.findElement('*[data-id="treeViewUltreeViewMenu"]', (el) => { - console.log((el as any).value.getId()) - const id = (el as any).value.getId() + 'drag and drop scripts from root to contracts #group1': function (browser: NightwatchBrowser) { + if (checkBrowserIsChrome(browser)) { browser - .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/scripts"]') - .dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/scripts"]', id) - .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') - .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - }) - browser.pause(1000) - .waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]') + .findElement('*[data-id="treeViewLitreeViewItemcontracts"]', (el) => { + console.log((el as any).value.getId()) + const id = (el as any).value.getId() + browser + .waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') + .dragAndDrop('li[data-id="treeViewLitreeViewItemscripts"]', id) + .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') + .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) + .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/scripts"]') + }) + } }, - 'drag into nested folder': function (browser: NightwatchBrowser) { - browser.waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') - .rightClick('li[data-id="treeViewLitreeViewItemscripts"]') - .waitForElementPresent('[data-id="contextMenuItemnewFolder') - .click('[data-id="contextMenuItemnewFolder') - .waitForElementVisible('*[data-id$="/blank"] .remixui_items') - .sendKeys('*[data-id$="/blank"] .remixui_items', 'nested') - .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) - .findElement('*[data-id="treeViewLitreeViewItemscripts/nested"]', (el) => { + 'drag scripts from contracts to root #group1': function (browser: NightwatchBrowser) { + if (checkBrowserIsChrome(browser)) { + browser.findElement('*[data-id="treeViewUltreeViewMenu"]', (el) => { console.log((el as any).value.getId()) const id = (el as any).value.getId() browser - .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]') - .dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]', id) + .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/scripts"]') + .dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/scripts"]', id) .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - .waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts/nested/README.txt"]') }) + browser.pause(1000) + .waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') + } + }, + 'drag into nested folder': function (browser: NightwatchBrowser) { + if (checkBrowserIsChrome(browser)) { + browser.waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts"]') + .rightClick('li[data-id="treeViewLitreeViewItemscripts"]') + .waitForElementPresent('[data-id="contextMenuItemnewFolder') + .click('[data-id="contextMenuItemnewFolder') + .waitForElementVisible('*[data-id$="/blank"] .remixui_items') + .sendKeys('*[data-id$="/blank"] .remixui_items', 'nested') + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .findElement('*[data-id="treeViewLitreeViewItemscripts/nested"]', (el) => { + console.log((el as any).value.getId()) + const id = (el as any).value.getId() + browser + .waitForElementVisible('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]') + .dragAndDrop('li[data-id="treeViewLitreeViewItemcontracts/README.txt"]', id) + .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') + .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) + .waitForElementVisible('li[data-id="treeViewLitreeViewItemscripts/nested/README.txt"]') + }) + } }