Editor scroll

pull/262/head
ioedeveloper 5 years ago committed by yann300
parent 3373887f61
commit 6b5dd74755
  1. 21
      test-browser/commands/editorScroll.js
  2. 25
      test-browser/commands/scrollUp.js
  3. 6
      test-browser/tests/editor.test.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<numberOfTimes; i++){
if (direction.toLowerCase() === 'up') browser.sendKeys('.ace_text-input', browser.Keys.ARROW_UP)
if (direction.toLowerCase() === 'down') browser.sendKeys('.ace_text-input', browser.Keys.ARROW_DOWN)
}
browser.perform((done) => {
done()
this.emit('complete')
})
return this
}
}
module.exports = ScrollEditor

@ -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

@ -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()
},

Loading…
Cancel
Save