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 test failures due to race condition (#11417)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
@@ -32,12 +32,20 @@ const getAndResizeMainWindow = async (electronApp: ElectronApplication) => {
|
||||
return mainWindow;
|
||||
};
|
||||
|
||||
const waitForStartupPlugins = async (electronApp: ElectronApplication) => {
|
||||
return electronApp.evaluate(({ ipcMain }) => {
|
||||
const waitForMainMessage = (electronApp: ElectronApplication, messageId: string) => {
|
||||
return electronApp.evaluate(({ ipcMain }, messageId) => {
|
||||
return new Promise<void>(resolve => {
|
||||
ipcMain.once('startup-plugins-loaded', () => resolve());
|
||||
ipcMain.once(messageId, () => resolve());
|
||||
});
|
||||
});
|
||||
}, messageId);
|
||||
};
|
||||
|
||||
const waitForAppLoaded = async (electronApp: ElectronApplication) => {
|
||||
await waitForMainMessage(electronApp, 'startup-finished');
|
||||
};
|
||||
|
||||
const waitForStartupPlugins = async (electronApp: ElectronApplication) => {
|
||||
await waitForMainMessage(electronApp, 'startup-plugins-loaded');
|
||||
};
|
||||
|
||||
const testDir = dirname(__dirname);
|
||||
@@ -62,7 +70,9 @@ export const test = base.extend<JoplinFixtures>({
|
||||
electronApp: async ({ profileDirectory }, use) => {
|
||||
const startupArgs = createStartupArgs(profileDirectory);
|
||||
const electronApp = await electron.launch({ args: startupArgs });
|
||||
const startupPromise = waitForAppLoaded(electronApp);
|
||||
await setDarkMode(electronApp, false);
|
||||
await startupPromise;
|
||||
|
||||
await use(electronApp);
|
||||
|
||||
@@ -85,8 +95,10 @@ export const test = base.extend<JoplinFixtures>({
|
||||
pluginPaths.map(path => resolve(testDir, path)).join(','),
|
||||
],
|
||||
});
|
||||
const startupPromise = waitForAppLoaded(electronApp);
|
||||
const mainWindowPromise = getAndResizeMainWindow(electronApp);
|
||||
await waitForStartupPlugins(electronApp);
|
||||
await startupPromise;
|
||||
|
||||
return {
|
||||
app: electronApp,
|
||||
|
||||
Reference in New Issue
Block a user