Skip to content

Commit 09e4ac4

Browse files
committed
build: upgrade electron and related dep, update tests
1 parent 64dc25b commit 09e4ac4

22 files changed

+1232
-1086
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"clsx": "1.1.1",
8282
"connected-react-router": "6.8.0",
8383
"download": "8.0.0",
84-
"electron-devtools-installer": "2.2.4",
84+
"electron-devtools-installer": "3.1.1",
8585
"electron-is-dev": "1.2.0",
8686
"electron-log": "4.2.4",
8787
"electron-publisher-s3": "20.17.2",
@@ -100,7 +100,7 @@
100100
"md5": "2.3.0",
101101
"mime-types": "2.1.27",
102102
"mkdirp": "1.0.4",
103-
"mocha": "7.1.0",
103+
"mocha": "8.1.3",
104104
"node-machine-id": "1.1.12",
105105
"prop-types": "15.7.2",
106106
"qs": "6.9.4",
@@ -142,20 +142,20 @@
142142
"codacy-coverage": "3.4.0",
143143
"concurrently": "5.3.0",
144144
"cross-env": "7.0.2",
145-
"electron": "8.2.4",
145+
"electron": "10.1.3",
146146
"electron-builder": "22.8.1",
147147
"env-cmd": "10.1.0",
148148
"enzyme-to-json": "3.6.1",
149149
"eslint-config-airbnb": "18.2.0",
150150
"eslint-config-prettier": "6.12.0",
151-
"eslint-plugin-mocha": "6.3.0",
151+
"eslint-plugin-mocha": "8.0.0",
152152
"husky": "4.3.0",
153153
"npm-run-all": "4.1.5",
154154
"prettier": "2.1.2",
155155
"pretty-quick": "3.0.2",
156156
"react-scripts": "3.4.3",
157157
"redux-mock-store": "1.5.4",
158-
"spectron": "10.0.1",
158+
"spectron": "12.0.0",
159159
"standard-version": "9.0.0",
160160
"wait-on": "5.2.0"
161161
},

public/electron.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
ipcMain,
66
Menu,
77
dialog,
8+
protocol,
89
// eslint-disable-next-line import/no-extraneous-dependencies
910
} = require('electron');
1011
const path = require('path');
@@ -137,7 +138,7 @@ const {
137138
const isMac = require('./app/utils/isMac');
138139

139140
// add keys to process
140-
Object.keys(env).forEach(key => {
141+
Object.keys(env).forEach((key) => {
141142
process.env[key] = env[key];
142143
});
143144

@@ -199,25 +200,25 @@ const createWindow = () => {
199200

200201
if (isDev) {
201202
const {
202-
default: installExtension,
203+
default: loadExtension,
203204
REACT_DEVELOPER_TOOLS,
204205
REDUX_DEVTOOLS,
205206
// eslint-disable-next-line global-require
206207
} = require('electron-devtools-installer');
207208

208-
installExtension(REACT_DEVELOPER_TOOLS)
209-
.then(name => {
209+
loadExtension(REACT_DEVELOPER_TOOLS)
210+
.then((name) => {
210211
logger.info(`added extension: ${name}`);
211212
})
212-
.catch(err => {
213+
.catch((err) => {
213214
logger.error(err);
214215
});
215216

216-
installExtension(REDUX_DEVTOOLS)
217-
.then(name => {
217+
loadExtension(REDUX_DEVTOOLS)
218+
.then((name) => {
218219
logger.info(`added extension: ${name}`);
219220
})
220-
.catch(err => {
221+
.catch((err) => {
221222
logger.error(err);
222223
});
223224
}
@@ -373,7 +374,7 @@ app.on('ready', async () => {
373374
autoUpdater
374375
.checkForUpdatesAndNotify()
375376
.then()
376-
.catch(err => logger.error(err));
377+
.catch((err) => logger.error(err));
377378

378379
await ensureDatabaseExists(DATABASE_PATH);
379380
const db = bootstrapDatabase(DATABASE_PATH);
@@ -632,3 +633,12 @@ app.on('activate', () => {
632633
ipcMain.on('load-page', (event, arg) => {
633634
mainWindow.loadURL(arg);
634635
});
636+
637+
// enable file:// url scheme
638+
// solution from https://github.com/electron/electron/issues/23757
639+
app.whenReady().then(() => {
640+
protocol.registerFileProtocol('file', (request, callback) => {
641+
const pathname = decodeURI(request.url.replace('file:///', ''));
642+
callback(pathname);
643+
});
644+
});

src/utils/syncSpace.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('syncSpace', () => {
7979
describe('createDiffElements', () => {
8080
// build classes from existing changes
8181
const classes = {};
82-
Object.values(SYNC_CHANGES).forEach(change => {
82+
Object.values(SYNC_CHANGES).forEach((change) => {
8383
classes[change] = change;
8484
});
8585

test/application.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const createApplication = async (
5555
return app;
5656
};
5757

58-
const closeApplication = app => {
58+
const closeApplication = (app) => {
5959
if (app && app.isRunning()) {
6060
return app.stop();
6161
}

test/apps/textInputApp.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,27 @@ const INPUT_TEXT_FIELD_SELECTOR = '#inputTextField';
66
const SAVE_BUTTON_SELECTOR = 'button';
77

88
export const typeInTextInputApp = async (client, id, text) => {
9-
await client.frame(buildPhaseAppName(id));
10-
await client.setValue(INPUT_TEXT_FIELD_SELECTOR, text);
9+
await client.switchToFrame(
10+
await client.$(`[name="${buildPhaseAppName(id)}"]`)
11+
);
12+
await (await client.$(INPUT_TEXT_FIELD_SELECTOR)).setValue(text);
1113
await client.pause(INPUT_TYPE_PAUSE);
1214

1315
// click on save button
14-
await client.click(SAVE_BUTTON_SELECTOR);
16+
await (await client.$(SAVE_BUTTON_SELECTOR)).click();
1517
await client.pause(SAVE_USER_INPUT_PAUSE);
1618

1719
// reset client on parent frame
18-
await client.frame(null);
20+
await client.switchToFrame(null);
1921
};
2022

2123
export const checkTextInputAppContainsText = async (client, id, text) => {
22-
await client.frame(buildPhaseAppName(id));
23-
const inputText = await client.getText(INPUT_TEXT_FIELD_SELECTOR);
24+
await client.switchToFrame(
25+
await client.$(`[name="${buildPhaseAppName(id)}"]`)
26+
);
27+
const inputText = await (await client.$(INPUT_TEXT_FIELD_SELECTOR)).getText();
2428

2529
expect(inputText).to.equal(text);
2630
// reset client on parent frame
27-
await client.frame(null);
31+
await client.switchToFrame(null);
2832
};

0 commit comments

Comments
 (0)