fix(e2e): address review feedback and window-managerless Linux CI

- Skip the three window-manager-dependent E2E assertions (maximize
  toggle, main-process state sync, minimize) on Linux CI: GitHub's
  ubuntu runners drive Electron under xvfb without a window manager, so
  maximize/minimize state never materializes there. Windows CI and
  local Linux/macOS runs keep the coverage.
- WINDOW:TOGGLE_MAXIMIZE now returns the requested state instead of
  re-reading isMaximized() right after the call, which races on Linux
  window managers where maximize()/unmaximize() complete
  asynchronously; the WINDOW:STATE_CHANGED push stays authoritative.
- Skip attaching window-state push listeners on macOS, where the
  custom controls never mount and the IPC traffic had no subscriber.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Fable 5 committed 2026-06-10 21:35:19 +02:00
1 parent 4a82eebabd
commit 315d11cc6a
3 files changed
+44 -7

No files matched your search

@@ -7,6 +7,13 @@ import {
// Custom window controls are only rendered on Windows/Linux; macOS keeps
// the native traffic lights.
//
// Linux CI runs Electron under xvfb, which has no window manager, so
// maximize/minimize never take effect there — those tests are skipped and
// rely on Windows CI plus local Linux/macOS runs for coverage.
const isWindowManagerlessCi =
process.platform === 'linux' && !!process.env['CI'];
test.describe('Custom window controls', () => {
test.skip(
process.platform === 'darwin',
@@ -39,6 +46,10 @@ test.describe('Custom window controls', () => {
test('@electron maximize button toggles the native window state', async ({
dataDir,
}) => {
test.skip(
isWindowManagerlessCi,
'xvfb on Linux CI has no window manager'
);
const app = await launchElectronApp(dataDir);
try {
@@ -67,6 +78,10 @@ test.describe('Custom window controls', () => {
test('@electron reflects window state changes triggered from the main process', async ({
dataDir,
}) => {
test.skip(
isWindowManagerlessCi,
'xvfb on Linux CI has no window manager'
);
const app = await launchElectronApp(dataDir);
try {
@@ -91,6 +106,10 @@ test.describe('Custom window controls', () => {
test('@electron minimize button minimizes the window', async ({
dataDir,
}) => {
test.skip(
isWindowManagerlessCi,
'xvfb on Linux CI has no window manager'
);
const app = await launchElectronApp(dataDir);
try {
+7
View File
@@ -258,6 +258,13 @@ export default class App {
}
private static attachWindowStateEvents(win: Electron.BrowserWindow): void {
// Only Windows/Linux render custom window controls that subscribe
// to these pushes; macOS keeps the native traffic lights, so
// sending state updates there would be dead IPC traffic.
if (process.platform === 'darwin') {
return;
}
const sendWindowState = () => {
if (win.isDestroyed()) {
return;
@@ -45,15 +45,26 @@ ipcMain.handle(WINDOW_MINIMIZE, (event) => {
ipcMain.handle(WINDOW_TOGGLE_MAXIMIZE, (event): WindowState => {
const win = getSenderWindow(event);
if (win) {
if (win.isMaximized()) {
win.unmaximize();
} else {
win.maximize();
}
if (!win) {
return getWindowState(win);
}
return getWindowState(win);
// maximize()/unmaximize() complete asynchronously on Linux window
// managers, so re-reading isMaximized() here would race. Report the
// requested state instead; the WINDOW:STATE_CHANGED push stays the
// authoritative update once the window manager has acted.
const shouldMaximize = !win.isMaximized();
if (shouldMaximize) {
win.maximize();
} else {
win.unmaximize();
}
return {
isMaximized: shouldMaximize,
isFullScreen: win.isFullScreen(),
};
});
// win.close() (instead of app.quit()) so the window's 'close' handler still