Skip to content

Commit

Permalink
feat: test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
rortan134 committed Sep 4, 2022
1 parent 68a8696 commit 8943bcd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ElectronApplication } from '@playwright/test';

/**
* Get a given attribute the MenuItem with the given id.
*
* @category Menu
*
* @param electronApp {ElectronApplication} - the Electron application object (from Playwright)
* @param menuId {string} - the id of the MenuItem to retrieve the attribute from
* @param attribute {string} - the attribute to retrieve
* @returns {Promise<string>}
* @fulfil {string} resolves with the attribute value
*/
export default function clickMenuItemById(
electronApp: ElectronApplication,
id: string
): Promise<unknown> {
return electronApp.evaluate(({ Menu }, menuId) => {
const menu = Menu.getApplicationMenu();
if (!menu) {
throw new Error('No application menu found');
}
const menuItem = menu.getMenuItemById(menuId);
if (menuItem) {
return menuItem.click();
}
throw new Error(`Menu item with id ${menuId} not found`);
}, id);
}
4 changes: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
testDir: './e2e',
/* Maximum time one test can run for. */
timeout: 30 * 3000,
timeout: 10 * 14400,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
timeout: 3000,
},
/* Run tests in files in parallel */
fullyParallel: true,
Expand Down

0 comments on commit 8943bcd

Please sign in to comment.