mirror of https://github.com/TriliumNext/Notes
e2e(desktop): fix process leak
parent
a7091779b7
commit
ff917e93c9
@ -1,13 +1,34 @@
|
||||
import { test, expect, _electron as electron } from '@playwright/test';
|
||||
import { test, expect, _electron as electron, type ElectronApplication } from '@playwright/test';
|
||||
import { join } from 'path';
|
||||
|
||||
test('Electron app should display correct title', async () => {
|
||||
// Launch Electron app
|
||||
const distPath = join(__dirname, '../../desktop/dist/main.cjs');
|
||||
const app = await electron.launch({ args: [ distPath ] });
|
||||
let app: ElectronApplication;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
const distPath = join(__dirname, '../../desktop/dist/main.cjs');
|
||||
app = await electron.launch({ args: [ distPath ] });
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
try {
|
||||
const pid = app.process().pid;
|
||||
await app.close();
|
||||
|
||||
if (pid) {
|
||||
// Double-check process is dead
|
||||
try {
|
||||
process.kill(pid, 0); // throws if process doesn't exist
|
||||
process.kill(pid, 'SIGKILL'); // force kill if still alive
|
||||
} catch (e) {
|
||||
// Process already dead
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Failed to close Electron app cleanly:', err);
|
||||
}
|
||||
});
|
||||
|
||||
test('Electron app should display correct title', async () => {
|
||||
// Get the main window
|
||||
const window = await app.firstWindow();
|
||||
await expect(window).toHaveTitle("Setup");
|
||||
await app.close();
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue