Skip to content

Commit

Permalink
initial failing e2e tests using wdio
Browse files Browse the repository at this point in the history
can't read preload.js
  • Loading branch information
Mattk70 committed Oct 25, 2023
1 parent 60eb8cc commit e79ad6b
Show file tree
Hide file tree
Showing 9 changed files with 1,107 additions and 827 deletions.
3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

</head>

<body>

<body class="records">

<!-- The modal for the tour -->
<div class="modal modal-fade" id="tourModal" tabindex="-1" aria-labelledby="tourModalLabel" aria-hidden="true">
Expand Down
102 changes: 53 additions & 49 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const isTest = process.env.NODE_ENV === 'test'
if (isTest) {
require('wdio-electron-service/main');
console.log('test environment')
}

const { app, dialog, ipcMain, MessageChannelMain, BrowserWindow, globalShortcut } = require('electron');
const { autoUpdater } = require("electron-updater")

const { autoUpdater } = require("electron-updater")
const log = require('electron-log');
//app.commandLine.appendSwitch('js-flags', '--max-old-space-size=4096');
const fs = require("fs");
Expand All @@ -9,13 +16,9 @@ const settings = require('electron-settings');
const axios = require('axios');
//require('update-electron-app')();
let files = [];
let DEBUG = false;
let DEBUG = true;
let unsavedRecords = false;
const isTest = process.env.NODE_ENV === 'test'
//if (isTest) {
require('wdio-electron-service/main');
console.log('test environment')
//}


//-------------------------------------------------------------------
// Logging
Expand Down Expand Up @@ -50,48 +53,49 @@ async function fetchReleaseNotes(version) {
log.transports.file.resolvePathFn = () => path.join(APP_DATA, 'logs/main.log');
log.info('App starting...');


autoUpdater.on('checking-for-update', function () {
logUpdateStatus('Checking for update...');
});

autoUpdater.on('update-available', async function (info) {
autoUpdater.downloadUpdate();
});

autoUpdater.on('update-not-available', function (info) {
logUpdateStatus('Update not available.');
});

autoUpdater.on('error', function (err) {
logUpdateStatus('Error in auto-updater:' + err);
});

autoUpdater.on('download-progress', function (progressObj) {
mainWindow.webContents.send('download-progress', progressObj);
});


autoUpdater.on('update-downloaded', async function (info) {
// Fetch release notes from GitHub API
const releaseNotes = await fetchReleaseNotes(info.version);
log.info(JSON.stringify(info))
// Display dialog to the user with release notes
dialog.showMessageBox({
type: 'info',
title: 'Update Available',
message: `A new version (${info.version}) is available.\n\nRelease Notes:\n${releaseNotes}\n\nDo you want to install it now?`,
buttons: ['Quit and Install', 'Install after Exit'],
defaultId: 1,
noLink: true
}).then((result) => {
if (result.response === 0) {
// User clicked 'Yes', start the download
autoUpdater.quitAndInstall();
}
if (!isTest){
console.log('istest:', isTest)
autoUpdater.on('checking-for-update', function () {
logUpdateStatus('Checking for update...');
});
});


autoUpdater.on('update-available', async function (info) {
autoUpdater.downloadUpdate();
});

autoUpdater.on('update-not-available', function (info) {
logUpdateStatus('Update not available.');
});

autoUpdater.on('error', function (err) {
logUpdateStatus('Error in auto-updater:' + err);
});

autoUpdater.on('download-progress', function (progressObj) {
mainWindow.webContents.send('download-progress', progressObj);
});


autoUpdater.on('update-downloaded', async function (info) {
// Fetch release notes from GitHub API
const releaseNotes = await fetchReleaseNotes(info.version);
log.info(JSON.stringify(info))
// Display dialog to the user with release notes
dialog.showMessageBox({
type: 'info',
title: 'Update Available',
message: `A new version (${info.version}) is available.\n\nRelease Notes:\n${releaseNotes}\n\nDo you want to install it now?`,
buttons: ['Quit and Install', 'Install after Exit'],
defaultId: 1,
noLink: true
}).then((result) => {
if (result.response === 0) {
// User clicked 'Yes', start the download
autoUpdater.quitAndInstall();
}
});
});
}
function logUpdateStatus(message) {
console.log(message);
}
Expand Down Expand Up @@ -244,7 +248,7 @@ async function createWindow() {
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
contextIsolation: true,
contextIsolation: !isTest,
backgroundThrottling: false
}
});
Expand Down
Loading

0 comments on commit e79ad6b

Please sign in to comment.