Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
69e9acf
WIP Electron
EWhite613 Jul 20, 2017
8045a28
Living that electron life
EWhite613 Jul 21, 2017
757cbba
electron working ish
EWhite613 Jul 21, 2017
1521c87
Electron - still minimal; difference in from capture - capture
EWhite613 Jul 21, 2017
4b13435
Electron working
EWhite613 Jul 24, 2017
f372355
Set show to false (so big images don't get distorted)
EWhite613 Jul 24, 2017
6afbd72
cleanup electron logs
EWhite613 Jul 24, 2017
53d9641
fix testem
EWhite613 Jul 26, 2017
c1ccba0
testem after tests exit
EWhite613 Jul 26, 2017
d6e3def
add electron
EWhite613 Jul 26, 2017
c6fd2f5
code downgrade for phantom
EWhite613 Jul 26, 2017
cd25b2b
Remove Electron folder. Renamed to NightmareJS
EWhite613 Jul 26, 2017
fdcb375
lint
EWhite613 Jul 26, 2017
20422ea
linting
EWhite613 Jul 26, 2017
4c6667d
increase timeouts
EWhite613 Jul 26, 2017
d7d7f20
increase timeout
EWhite613 Jul 26, 2017
c6cb895
remove fs
EWhite613 Jul 27, 2017
06ac59d
remove electron from deps
EWhite613 Jul 27, 2017
0779f87
disable coverage
EWhite613 Jul 27, 2017
98beb0b
fix nightmare report
EWhite613 Jul 27, 2017
76de7a5
Merge branch 'electron' of https://github.com/EWhite613/ember-cli-vis…
EWhite613 Jul 27, 2017
007788b
blueprints
EWhite613 Jul 27, 2017
edb3778
update travis to ensure trusty
EWhite613 Jul 27, 2017
cf7023e
use precise
EWhite613 Jul 27, 2017
7c51062
trusty
EWhite613 Jul 27, 2017
5261ace
get electron working on travis again
EWhite613 Jul 27, 2017
84ee3fe
before install start xvfb
EWhite613 Jul 27, 2017
d264b0d
fix url
EWhite613 Jul 28, 2017
adf0d84
revert travis
EWhite613 Jul 28, 2017
64f672d
update blueprint
EWhite613 Jul 28, 2017
42ec41a
electron 1st
EWhite613 Jul 28, 2017
c679837
revert travis
EWhite613 Jul 28, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pr-bumper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"coverage": {
"enabled": false
}
}
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
language: node_js
sudo: true
dist: trusty
node_js:
- '5.3'
branches:
except:
- /^v[0-9\.]+/
before_install:
- npm install -g coveralls pr-bumper@^1.0.0 slimerjs phantomjs
- npm install -g coveralls pr-bumper@^1.0.0 slimerjs phantomjs electron
- pr-bumper check
- slimerjs -v
before_script:
Expand Down Expand Up @@ -54,4 +55,4 @@ after_deploy:
- .travis/publish-gh-pages.sh
notifications:
slack:
secure: Jj9cqqMQBfw4uCTPvjBOpeE956bz8oRlXJk2um/rMrfN5CC/n+gYgf8jwa3f1e7JuxaEiWf9+zmKJe73nhte4tA08W3+PmN+OWnojRR0bxxJG4Momp+23u0Cjlg2dRO7v+anEgkIcwPYicE0gyMIzW8PQzbZRNphcVstWHcGse7BI0hQ80YKxrCiuiTcQohnKvczPfsSCRlLdY+3JJlMzLnvksEmZU4JdcoegK57DOoGkXVQLPRuYTsIvuRtF8LI0wD6xi1be7LDrK6PSpP9x+Ga1Wh5u++27apjsLTxjnJ57DjOGDpQ8iFJUVMr/pc6iy1QHHdFo356YQZrLDP5EVLBE47DQuTXGH0CUtXy2oz5hoX44Tmw52BFlOoedjDmuuOy24CzAONqceTyJEruTlGn2HTQVVoRX7ScscV9Bs9gfYqSfw0KvjTN0mb2a6vUCEBA2ldo8yoneJl4upms+lffZQsNCHIdA8btOf4ucCevJXJfxiOZpq9nHgwu7GdbqdT8Toh4cqiMzP6XgE4TpUJHUpJo4KmgfSDfc8JcQ8egPY7e7UvFZqWMCNGs9EFQt40iGD+KrzidhZRq6MsA1qZWC96n6JX4/kvPpr/1aiS7OkFkmC4E9aBExnVwDYAIoTwv2+Rh7KY0eZGcTcrzNTPdHdaCVUDFnWdQ9NrqjBI=
secure: Jj9cqqMQBfw4uCTPvjBOpeE956bz8oRlXJk2um/rMrfN5CC/n+gYgf8jwa3f1e7JuxaEiWf9+zmKJe73nhte4tA08W3+PmN+OWnojRR0bxxJG4Momp+23u0Cjlg2dRO7v+anEgkIcwPYicE0gyMIzW8PQzbZRNphcVstWHcGse7BI0hQ80YKxrCiuiTcQohnKvczPfsSCRlLdY+3JJlMzLnvksEmZU4JdcoegK57DOoGkXVQLPRuYTsIvuRtF8LI0wD6xi1be7LDrK6PSpP9x+Ga1Wh5u++27apjsLTxjnJ57DjOGDpQ8iFJUVMr/pc6iy1QHHdFo356YQZrLDP5EVLBE47DQuTXGH0CUtXy2oz5hoX44Tmw52BFlOoedjDmuuOy24CzAONqceTyJEruTlGn2HTQVVoRX7ScscV9Bs9gfYqSfw0KvjTN0mb2a6vUCEBA2ldo8yoneJl4upms+lffZQsNCHIdA8btOf4ucCevJXJfxiOZpq9nHgwu7GdbqdT8Toh4cqiMzP6XgE4TpUJHUpJo4KmgfSDfc8JcQ8egPY7e7UvFZqWMCNGs9EFQt40iGD+KrzidhZRq6MsA1qZWC96n6JX4/kvPpr/1aiS7OkFkmC4E9aBExnVwDYAIoTwv2+Rh7KY0eZGcTcrzNTPdHdaCVUDFnWdQ9NrqjBI=
4 changes: 4 additions & 0 deletions blueprints/ember-cli-visual-acceptance/files/testem.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"NightmareJsVisualAcceptance": {
"command": "node vendor/nightmarejs-launcher.js <url>",
"protocol": "browser"
},
"Electron": {
"command": "electron vendor/electron-launcher.js <url>",
"protocol": "browser"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* eslint-disable max-len */
const electron = require('electron')
const app = electron.app // Module to control application life.
const BrowserWindow = electron.BrowserWindow // Module to create native browser window.
const ipcMain = electron.ipcMain
const timeoutFromResize = 1500
var url = process.argv[2]

// var url = process.argv[2]
// Report crashes to our server.
// electron.crashReporter.start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null

// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
// if (process.platform !== 'darwin') {
app.quit()
// }
})

function sendImage (win, image) {
win.webContents.send('return-image-event', {
image: image
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function () {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 800,
offscreen: true,
show: false,
'enable-larger-than-screen': true,
useContentSize: true
})
console.log('Setting ipcMain')
mainWindow.webContents.executeJavaScript(`
const ipcRenderer = window.nodeRequire('electron').ipcRenderer
Testem.afterTests(
// Asynchronously
function (config, data, callback) {
callback(null)
// Set time to wait for callback to finish its work. Then close launcher (Issue Testem: fails to close custom launcher on Linux) https://github.com/testem/testem/issues/915
setTimeout(function (params) {
ipcRenderer.send('exit-event', {
exit: true
})
}, 2000)
// Set time to wait for callback to finish its work. Then close launcher (Issue Testem: fails to close custom launcher on Linux) https://github.com/testem/testem/issues/915
}
)
`)
ipcMain.on('capture-event', function (event, data) {
mainWindow.webContents.executeJavaScript(
"[document.getElementById('ember-testing-container').scrollWidth, document.getElementById('ember-testing-container').scrollHeight]",
false, result => {
mainWindow.setContentSize(result[0] + 200, result[1] + 200)

setTimeout(() => {
mainWindow.webContents.executeJavaScript(`[window.scrollTo(0,0), JSON.stringify(document.getElementById('${data.targetId}').getBoundingClientRect(), ["top", "left", "width",
"height"])]`, false, res => {
let rect = JSON.parse(res[1])
var clip = {
x: rect.left,
y: rect.top,
width: rect.width,
height: rect.height
}

mainWindow.capturePage(clip, function (imageResult) {
// fs.writeFileSync('/Users/ewhite/workspace/ember-cli-visual-acceptance/electron-images/' + uuidv4() + '-image.png', imageResult.toPNG())
var image = Buffer.from(imageResult.toPNG()).toString('base64')
sendImage(mainWindow, image)
})
})
}, timeoutFromResize)
}
)
})

ipcMain.on('exit-event', function () {
app.exit()
})

// and load the index.html of the app.
mainWindow.loadURL(url)

// Open the DevTools.
// mainWindow.webContents.openDevTools({mode: 'detach'})

// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
})

process.on('SIGTERM', function () {
mainWindow = null
})
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "ember build",
"start": "ember server",
"test": "npm run lint && ember test",
"lint": "eslint *.js addon app blueprints config tests"
"lint": "eslint *.js addon app blueprints config tests vendor/VisualAcceptance.js vendor/*-launcher.js"
},
"repository": "https://github.com/ciena-blueplanet/ember-cli-visual-acceptance.git",
"engines": {
Expand All @@ -19,6 +19,7 @@
"author": "",
"license": "MIT",
"devDependencies": {
"babel-eslint": "^7.2.3",
"broccoli-asset-rev": "^2.4.2",
"ember-ajax": "0.7.1",
"ember-cli": "2.4.3",
Expand All @@ -45,17 +46,17 @@
"ember-addon"
],
"dependencies": {
"body-parser": "^1.15.1",
"chalk": "^1.1.3",
"ember-cli-babel": "^5.1.6",
"ember-cli-node-assets": "^0.1.4",
"es6-promise": "^3.2.2",
"nightmare": "^2.10.0",
"nightmare-custom-event": "^0.2.0",
"resemblejs": "2.2.0",
"sync-request": "^3.0.1",
"body-parser": "^1.15.1",
"chalk": "^1.1.3",
"ember-cli-babel": "^5.1.6",
"ember-cli-node-assets": "^0.1.4"
"sync-request": "^3.0.1"
},
"ember-addon": {
"configPath": "tests/dummy/config"
}
}
}
7 changes: 6 additions & 1 deletion testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ module.exports = {
'test_page': 'tests/index.html?hidepassed',
'disable_watching': true,
'launch_in_ci': [
'Electron',
'Firefox',
'NightmareJsVisualAcceptance',
'PhantomJsVisualAcceptance',
'SlimerJsVisualAcceptance',
'Chromium'
],
'launch_in_dev': [
'NightmareJsVisualAcceptance'
'Electron'
],

'launchers': {
Expand All @@ -25,6 +26,10 @@ module.exports = {
'NightmareJsVisualAcceptance': {
'command': 'DEBUG=nightmare* node vendor/nightmarejs-launcher.js <url>',
'protocol': 'browser'
},
'Electron': {
'command': 'electron vendor/electron-launcher.js <url>',
'protocol': 'browser'
}
}
}
6 changes: 5 additions & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<title>Dummy Tests</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<script>
window.nodeRequire = require;
delete window.require;
delete window.exports; delete window.module;
</script>
{{content-for "head"}}
{{content-for "test-head"}}

Expand Down
14 changes: 7 additions & 7 deletions tests/integration/simple-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ describeComponent(
},
function () {
it('renders', function (done) {
this.timeout(30000)
this.timeout(50000)
this.render(hbs `<div id='test'>Test</div>`)
expect(this.$()).to.have.length(1)
capture('Simple', done)
})
it('renders something else', function (done) {
this.timeout(30000)
this.timeout(50000)
this.render(hbs `<div id='test'>Test Else</div>`)
expect(this.$()).to.have.length(1)
capture('Error', done)
})
it('renders svg', function (done) {
this.timeout(30000)
this.timeout(50000)
/* eslint-disable max-len */
this.render(hbs `<svg id="mySVG"xmlns="http://www.w3.org/2000/svg" viewBox="-350 -250 700 500">
<style type="text/css" media="screen">
Expand All @@ -45,7 +45,7 @@ describeComponent(
})

it('renders svg experimental', function (done) {
this.timeout(30000)
this.timeout(50000)
/* eslint-disable max-len */
this.render(hbs `<svg id="mySVG"xmlns="http://www.w3.org/2000/svg" viewBox="-350 -250 700 500">
<style type="text/css" media="screen">
Expand All @@ -62,7 +62,7 @@ describeComponent(
})

it('captures target', function (done) {
this.timeout(30000)
this.timeout(50000)
/* eslint-disable max-len */
this.render(hbs `<div class="outer">
<div class="innerdivs left">
Expand All @@ -80,13 +80,13 @@ describeComponent(
})

it('fixed div', function (done) {
this.timeout(30000)
this.timeout(50000)
this.render(hbs `<div class="fixed">Wherever you go, I will find you!</div>`)
capture('fixed', done)
})

it('more fixed', function (done) {
this.timeout(10000)
this.timeout(50000)
this.render(hbs `<div id="left">Side menu</div>
<div id="right">Top Menu
<br />Top Menu
Expand Down
Loading