Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/app-desktop/integration-tests/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import MainScreen from './models/MainScreen';
import SettingsScreen from './models/SettingsScreen';

test.describe('settings', () => {
test('should be possible to remove sort order buttons in settings', async ({ electronApp, mainWindow }) => {
test('should be possible to remove sort order buttons in settings', async ({ electronApp, mainWindow, startupPluginsLoaded }) => {
const mainScreen = new MainScreen(mainWindow);
await mainScreen.waitFor();
await startupPluginsLoaded;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to correct test!


// Sort order buttons should be visible by default
const sortOrderLocator = mainScreen.noteList.sortOrderButton;
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
Loading