Editor scroll

pull/5370/head
ioedeveloper 5 years ago committed by yann300
parent e3d2e24d67
commit cc6abca223
  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) browser.addFile('sourcehighlight.js', sourcehighlightScript)
.switchFile('browser/sourcehighlight.js') .switchFile('browser/sourcehighlight.js')
.executeScript('remix.exeCurrent()') .executeScript('remix.exeCurrent()')
.scrollUp('*[data-id="editorInput"]', 100) .editorScroll('down', 60)
.pause(5000)
.scrollUp('.ace_scroller', 100)
.waitForElementPresent('.highlightLine32') .waitForElementPresent('.highlightLine32')
.checkElementStyle('.highlightLine32', 'background-color', 'rgb(8, 108, 181)') .checkElementStyle('.highlightLine32', 'background-color', 'rgb(8, 108, 181)')
.waitForElementPresent('.highlightLine40') .waitForElementPresent('.highlightLine40')
.checkElementStyle('.highlightLine40', 'background-color', 'rgb(8, 108, 181)') .checkElementStyle('.highlightLine40', 'background-color', 'rgb(8, 108, 181)')
.waitForElementPresent('.highlightLine50')
.checkElementStyle('.highlightLine50', 'background-color', 'rgb(8, 108, 181)')
.end() .end()
}, },

Loading…
Cancel
Save