-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathapp.spec.ts
More file actions
48 lines (40 loc) 路 1.27 KB
/
Copy pathapp.spec.ts
File metadata and controls
48 lines (40 loc) 路 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { ElectronApplication, Page, _electron as electron, expect, test } from '@playwright/test';
let appWindow: Page;
let appElectron: ElectronApplication;
function existElementByTestId(selector: string, waitingMilliseconds = 100) {
return new Promise((resolve) => {
setTimeout(async () => {
await expect(
appWindow.getByTestId(selector).first(),
`Confirm selector '${selector}' is visible`,
).toBeVisible();
resolve(true);
}, waitingMilliseconds);
});
}
test.beforeAll(async () => {
// Open Electron app from build directory
appElectron = await electron.launch({
args: ['dist/main/index.js'],
locale: 'en-US',
colorScheme: 'light',
env: {
...process.env,
E2E: 'yes',
NODE_ENV: 'production',
},
});
appWindow = await appElectron.firstWindow();
await appWindow.waitForEvent('domcontentloaded');
});
test('Environment check', async () => {
const isPackaged = await appElectron.evaluate(async ({ app }) => app.isPackaged);
expect(isPackaged, 'Confirm that is in development mode').toBe(false);
});
test('Document element check', async () => {
await existElementByTestId('uiFileOpen');
});
test.afterAll(async () => {
await appWindow.waitForTimeout(2000);
await appElectron.close();
});