Skip to content

Commit

Permalink
Chore: Desktop: Wait for plugins to load before running certain plugi…
Browse files Browse the repository at this point in the history
…n-related tests (#11224)
  • Loading branch information
personalizedrefrigerator authored Oct 26, 2024
1 parent c364fd0 commit 08f29b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion packages/app-desktop/integration-tests/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ test.describe('settings', () => {
await expect(mainScreen.dialog).toBeVisible();
});

test('should be possible to navigate settings screen tabs with the arrow keys', async ({ electronApp, mainWindow }) => {
test('should be possible to navigate settings screen tabs with the arrow keys', async ({ electronApp, mainWindow, startupPluginsLoaded }) => {
const mainScreen = new MainScreen(mainWindow);
await startupPluginsLoaded;

await mainScreen.waitFor();
await mainScreen.openSettings(electronApp);

Expand Down
20 changes: 12 additions & 8 deletions packages/app-desktop/integration-tests/util/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ const getAndResizeMainWindow = async (electronApp: ElectronApplication) => {
return mainWindow;
};

const waitForStartupPlugins = async (electronApp: ElectronApplication) => {
return electronApp.evaluate(({ ipcMain }) => {
return new Promise<void>(resolve => {
ipcMain.once('startup-plugins-loaded', () => resolve());
});
});
};

const testDir = dirname(__dirname);

export const test = base.extend<JoplinFixtures>({
Expand Down Expand Up @@ -75,10 +83,12 @@ export const test = base.extend<JoplinFixtures>({
pluginPaths.map(path => resolve(testDir, path)).join(','),
],
});
const mainWindowPromise = getAndResizeMainWindow(electronApp);
await waitForStartupPlugins(electronApp);

return {
app: electronApp,
mainWindow: await getAndResizeMainWindow(electronApp),
mainWindow: await mainWindowPromise,
};
});

Expand All @@ -89,13 +99,7 @@ export const test = base.extend<JoplinFixtures>({
},

startupPluginsLoaded: async ({ electronApp }, use) => {
const startupPluginsLoadedPromise = electronApp.evaluate(({ ipcMain }) => {
return new Promise<void>(resolve => {
ipcMain.once('startup-plugins-loaded', () => resolve());
});
});

await use(startupPluginsLoadedPromise);
await use(waitForStartupPlugins(electronApp));
},

mainWindow: async ({ electronApp }, use) => {
Expand Down

0 comments on commit 08f29b7

Please sign in to comment.