Skip to content

Commit

Permalink
(#5) Added E2E test subpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
s1hofmann committed Aug 12, 2020
1 parent 981ddbb commit 82c6e20
Show file tree
Hide file tree
Showing 12 changed files with 30,546 additions and 0 deletions.
6 changes: 6 additions & 0 deletions e2e/tests/lerna.json
@@ -0,0 +1,6 @@
{
"packages": [
"packages/*"
],
"version": "1.4.2"
}
24,804 changes: 24,804 additions & 0 deletions e2e/tests/package-lock.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions e2e/tests/package.json
@@ -0,0 +1,34 @@
{
"name": "e2e-tests",
"version": "1.4.2",
"description": "nut.js E2E tests",
"main": "index.js",
"scripts": {
"test": "lerna run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nut-tree/nut.js.git"
},
"keywords": [
"nut.js",
"e2e",
"tests"
],
"author": "Simon Hofmann <dev@simon-hofmann.org>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/nut-tree/nut.js/issues"
},
"homepage": "https://github.com/nut-tree/nut.js#readme",
"devDependencies": {
"electron": "9.1.2",
"jest": "26.2.2",
"lerna": "3.22.1",
"spectron": "11.1.0",
"@nut-tree/nut-js": "file:../../"
},
"dependencies": {
"window-integration-tests": "file:packages/window-integration-tests"
}
}
13 changes: 13 additions & 0 deletions e2e/tests/packages/window-integration-tests/constants.js
@@ -0,0 +1,13 @@
const POS_X = 50;
const POS_Y = 100;
const WIDTH = 800;
const HEIGTH = 600;
const TITLE = "libnut window test";

module.exports = {
POS_X,
POS_Y,
WIDTH,
HEIGTH,
TITLE
};
19 changes: 19 additions & 0 deletions e2e/tests/packages/window-integration-tests/index.css
@@ -0,0 +1,19 @@
body {
width: 100vw;
height: 100vh;
}

#content {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
height: 100vh;
width: 100vw;
}

#exit {
color: white;
font-size: 1.5rem;
background: darkblue;
}
16 changes: 16 additions & 0 deletions e2e/tests/packages/window-integration-tests/index.html
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<link href="index.css" rel="stylesheet"/>
<title>libnut window test</title>
</head>
<body style="width: 100%; height: 100%">
<div id="content">
<button id="exit">Click me!</button>
</div>
<script src="renderer.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions e2e/tests/packages/window-integration-tests/main.js
@@ -0,0 +1,37 @@
const {app, ipcMain, BrowserWindow} = require('electron')
const path = require('path');
const { POS_X, POS_Y, WIDTH, HEIGTH } = require("./constants");

function createWindow() {
const mainWindow = new BrowserWindow({
width: WIDTH,
height: HEIGTH,
alwaysOnTop: true,
webPreferences: {
nodeIntegration: true,
preload: path.join(__dirname, 'preload.js')
}
});
mainWindow.loadFile(path.join(__dirname, "index.html"));
mainWindow.setPosition(POS_X, POS_Y);
}

ipcMain.on("main", (event, args) => {
if (args === "quit") {
app.quit();
}
});

app.whenReady().then(() => {
setTimeout(() => app.exit(1), 15000);
createWindow()

app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})

app.on('window-all-closed', function () {
console.log("Bye!");
app.quit();
})

0 comments on commit 82c6e20

Please sign in to comment.