From cc6abca223df6cb35759ce002676c442683c7f30 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 7 May 2020 03:28:59 +0000 Subject: [PATCH] Editor scroll --- test-browser/commands/editorScroll.js | 21 +++++++++++++++++++++ test-browser/commands/scrollUp.js | 25 ------------------------- test-browser/tests/editor.test.js | 6 +++--- 3 files changed, 24 insertions(+), 28 deletions(-) create mode 100644 test-browser/commands/editorScroll.js delete mode 100644 test-browser/commands/scrollUp.js diff --git a/test-browser/commands/editorScroll.js b/test-browser/commands/editorScroll.js new file mode 100644 index 0000000000..7dd060d9c4 --- /dev/null +++ b/test-browser/commands/editorScroll.js @@ -0,0 +1,21 @@ +const EventEmitter = require('events') + +// fix for editor scroll +class ScrollEditor extends EventEmitter { + command (direction, numberOfTimes) { + const browser = this.api + + browser.waitForElementPresent('.ace_text-input') + for (let i=0; i { + done() + this.emit('complete') + }) + return this + } +} + +module.exports = ScrollEditor diff --git a/test-browser/commands/scrollUp.js b/test-browser/commands/scrollUp.js deleted file mode 100644 index 28d5be2db2..0000000000 --- a/test-browser/commands/scrollUp.js +++ /dev/null @@ -1,25 +0,0 @@ -const EventEmitter = require('events') - -class ScrollUp extends EventEmitter { - command (target, height) { - this.api.perform((done) => { - _scrollUp(this.api, target, height, () => { - done() - this.emit('complete') - }) - }) - return this - } -} - -function _scrollUp (browser, target, height, cb) { - browser.execute(function (target, height) { - const element = document.querySelector(target) - - element.scrollTop = element.scrollHeight - height - }, [target, height], function () { - cb() - }) -} - -module.exports = ScrollUp diff --git a/test-browser/tests/editor.test.js b/test-browser/tests/editor.test.js index 47ddd6e34c..dc16f464dd 100644 --- a/test-browser/tests/editor.test.js +++ b/test-browser/tests/editor.test.js @@ -76,13 +76,13 @@ module.exports = { browser.addFile('sourcehighlight.js', sourcehighlightScript) .switchFile('browser/sourcehighlight.js') .executeScript('remix.exeCurrent()') - .scrollUp('*[data-id="editorInput"]', 100) - .pause(5000) - .scrollUp('.ace_scroller', 100) + .editorScroll('down', 60) .waitForElementPresent('.highlightLine32') .checkElementStyle('.highlightLine32', 'background-color', 'rgb(8, 108, 181)') .waitForElementPresent('.highlightLine40') .checkElementStyle('.highlightLine40', 'background-color', 'rgb(8, 108, 181)') + .waitForElementPresent('.highlightLine50') + .checkElementStyle('.highlightLine50', 'background-color', 'rgb(8, 108, 181)') .end() },