mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 19:46:16 -08:00
- 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>
129 lines
4.3 KiB
TypeScript
129 lines
4.3 KiB
TypeScript
import {
|
|
closeElectronApp,
|
|
expect,
|
|
launchElectronApp,
|
|
test,
|
|
} from './electron-test-fixtures';
|
|
|
|
// 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',
|
|
'macOS uses native traffic lights instead of custom controls'
|
|
);
|
|
|
|
test('@electron renders the window control buttons', async ({
|
|
dataDir,
|
|
}) => {
|
|
const app = await launchElectronApp(dataDir);
|
|
|
|
try {
|
|
await expect(
|
|
app.mainWindow.getByTestId('window-minimize')
|
|
).toBeVisible();
|
|
await expect(
|
|
app.mainWindow.getByTestId('window-maximize')
|
|
).toBeVisible();
|
|
await expect(
|
|
app.mainWindow.getByTestId('window-close')
|
|
).toBeVisible();
|
|
await expect(
|
|
app.mainWindow.getByTestId('window-maximize-glyph')
|
|
).toBeVisible();
|
|
} finally {
|
|
await closeElectronApp(app);
|
|
}
|
|
});
|
|
|
|
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 {
|
|
const isMaximized = () =>
|
|
app.electronApp.evaluate(({ BrowserWindow }) => {
|
|
const mainWindow = BrowserWindow.getAllWindows()[0];
|
|
return mainWindow ? mainWindow.isMaximized() : false;
|
|
});
|
|
|
|
await app.mainWindow.getByTestId('window-maximize').click();
|
|
await expect.poll(isMaximized, { timeout: 10_000 }).toBe(true);
|
|
await expect(
|
|
app.mainWindow.getByTestId('window-restore-glyph')
|
|
).toBeVisible();
|
|
|
|
await app.mainWindow.getByTestId('window-maximize').click();
|
|
await expect.poll(isMaximized, { timeout: 10_000 }).toBe(false);
|
|
await expect(
|
|
app.mainWindow.getByTestId('window-maximize-glyph')
|
|
).toBeVisible();
|
|
} finally {
|
|
await closeElectronApp(app);
|
|
}
|
|
});
|
|
|
|
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 {
|
|
await app.electronApp.evaluate(({ BrowserWindow }) => {
|
|
BrowserWindow.getAllWindows()[0]?.maximize();
|
|
});
|
|
await expect(
|
|
app.mainWindow.getByTestId('window-restore-glyph')
|
|
).toBeVisible({ timeout: 10_000 });
|
|
|
|
await app.electronApp.evaluate(({ BrowserWindow }) => {
|
|
BrowserWindow.getAllWindows()[0]?.unmaximize();
|
|
});
|
|
await expect(
|
|
app.mainWindow.getByTestId('window-maximize-glyph')
|
|
).toBeVisible({ timeout: 10_000 });
|
|
} finally {
|
|
await closeElectronApp(app);
|
|
}
|
|
});
|
|
|
|
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 {
|
|
const isMinimized = () =>
|
|
app.electronApp.evaluate(({ BrowserWindow }) => {
|
|
const mainWindow = BrowserWindow.getAllWindows()[0];
|
|
return mainWindow ? mainWindow.isMinimized() : false;
|
|
});
|
|
|
|
await app.mainWindow.getByTestId('window-minimize').click();
|
|
await expect.poll(isMinimized, { timeout: 10_000 }).toBe(true);
|
|
} finally {
|
|
await closeElectronApp(app);
|
|
}
|
|
});
|
|
});
|