You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Chore: Desktop: Fix tests in IPC pull request (#12004)
This commit is contained in:
@@ -36,12 +36,21 @@ interface SecondaryWindowData {
|
|||||||
electronId: number;
|
electronId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Options {
|
||||||
|
env: string;
|
||||||
|
profilePath: string|null;
|
||||||
|
isDebugMode: boolean;
|
||||||
|
isEndToEndTesting: boolean;
|
||||||
|
initialCallbackUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default class ElectronAppWrapper {
|
export default class ElectronAppWrapper {
|
||||||
private logger_: Logger = null;
|
private logger_: Logger = null;
|
||||||
private electronApp_: App;
|
private electronApp_: App;
|
||||||
private env_: string;
|
private env_: string;
|
||||||
private isDebugMode_: boolean;
|
private isDebugMode_: boolean;
|
||||||
private profilePath_: string;
|
private profilePath_: string;
|
||||||
|
private isEndToEndTesting_: boolean;
|
||||||
|
|
||||||
private win_: BrowserWindow = null;
|
private win_: BrowserWindow = null;
|
||||||
private mainWindowHidden_ = true;
|
private mainWindowHidden_ = true;
|
||||||
@@ -65,12 +74,13 @@ export default class ElectronAppWrapper {
|
|||||||
|
|
||||||
private ipcLogger_: Logger;
|
private ipcLogger_: Logger;
|
||||||
|
|
||||||
public constructor(electronApp: App, env: string, profilePath: string|null, isDebugMode: boolean, initialCallbackUrl: string) {
|
public constructor(electronApp: App, { env, profilePath, isDebugMode, initialCallbackUrl, isEndToEndTesting }: Options) {
|
||||||
this.electronApp_ = electronApp;
|
this.electronApp_ = electronApp;
|
||||||
this.env_ = env;
|
this.env_ = env;
|
||||||
this.isDebugMode_ = isDebugMode;
|
this.isDebugMode_ = isDebugMode;
|
||||||
this.profilePath_ = profilePath;
|
this.profilePath_ = profilePath;
|
||||||
this.initialCallbackUrl_ = initialCallbackUrl;
|
this.initialCallbackUrl_ = initialCallbackUrl;
|
||||||
|
this.isEndToEndTesting_ = isEndToEndTesting;
|
||||||
|
|
||||||
this.profileLocker_ = new FileLocker(`${this.profilePath_}/lock`);
|
this.profileLocker_ = new FileLocker(`${this.profilePath_}/lock`);
|
||||||
|
|
||||||
@@ -576,7 +586,9 @@ export default class ElectronAppWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async ensureSingleInstance() {
|
public async ensureSingleInstance() {
|
||||||
// if (this.env_ === 'dev') return false;
|
// When end-to-end testing, multiple instances of Joplin are intentionally created at the same time,
|
||||||
|
// or very close to one another. The single instance handling logic can interfere with this, so disable it.
|
||||||
|
if (this.isEndToEndTesting_) return false;
|
||||||
|
|
||||||
interface OnSecondInstanceMessageData {
|
interface OnSecondInstanceMessageData {
|
||||||
profilePath: string;
|
profilePath: string;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const createStartupArgs = (profileDirectory: string) => {
|
|||||||
|
|
||||||
// We need to run with --env dev to disable the single instance check.
|
// We need to run with --env dev to disable the single instance check.
|
||||||
return [
|
return [
|
||||||
mainPath, '--env', 'dev', '--no-welcome', '--profile', resolve(profileDirectory),
|
mainPath, '--env', 'dev', '--no-welcome', '--running-tests', '--profile', resolve(profileDirectory),
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ Logger.fsDriver_ = new FsDriverNode();
|
|||||||
const env = envFromArgs(process.argv);
|
const env = envFromArgs(process.argv);
|
||||||
const profileFromArgs = getFlagValueFromArgs(process.argv, '--profile', null);
|
const profileFromArgs = getFlagValueFromArgs(process.argv, '--profile', null);
|
||||||
const isDebugMode = !!process.argv && process.argv.indexOf('--debug') >= 0;
|
const isDebugMode = !!process.argv && process.argv.indexOf('--debug') >= 0;
|
||||||
|
const isEndToEndTesting = !!process.argv?.includes('--running-tests');
|
||||||
const altInstanceId = getFlagValueFromArgs(process.argv, '--alt-instance-id', '');
|
const altInstanceId = getFlagValueFromArgs(process.argv, '--alt-instance-id', '');
|
||||||
|
|
||||||
// We initialize all these variables here because they are needed from the main process. They are
|
// We initialize all these variables here because they are needed from the main process. They are
|
||||||
@@ -64,7 +65,9 @@ void registerCustomProtocols();
|
|||||||
|
|
||||||
const initialCallbackUrl = process.argv.find((arg) => isCallbackUrl(arg));
|
const initialCallbackUrl = process.argv.find((arg) => isCallbackUrl(arg));
|
||||||
|
|
||||||
const wrapper = new ElectronAppWrapper(electronApp, env, rootProfileDir, isDebugMode, initialCallbackUrl);
|
const wrapper = new ElectronAppWrapper(electronApp, {
|
||||||
|
env, profilePath: rootProfileDir, isDebugMode, initialCallbackUrl, isEndToEndTesting,
|
||||||
|
});
|
||||||
|
|
||||||
initBridge(wrapper, appId, appName, rootProfileDir, autoUploadCrashDumps, altInstanceId);
|
initBridge(wrapper, appId, appName, rootProfileDir, autoUploadCrashDumps, altInstanceId);
|
||||||
|
|
||||||
|
|||||||
@@ -188,6 +188,12 @@ const processStartFlags = async (argv: string[], setDefaults = true) => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg === '--running-tests') {
|
||||||
|
// Used by the desktop app to indicate that the app is running end-to-end tests.
|
||||||
|
argv.splice(0, 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (arg.length && arg[0] === '-') {
|
if (arg.length && arg[0] === '-') {
|
||||||
throw new JoplinError(_('Unknown flag: %s', arg), 'flagError');
|
throw new JoplinError(_('Unknown flag: %s', arg), 'flagError');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user