1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Chore: Desktop: Wait for plugins to load before running certain plugin-related tests (#11224)

This commit is contained in:
Henry Heino 2024-10-26 12:58:54 -07:00 committed by GitHub
parent c364fd087f
commit 08f29b7866
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 9 deletions

View File

@ -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);

View File

@ -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>({
@ -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,
};
});
@ -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) => {