fix: address Copilot review - main window lookup and comment clarity

- tidgiMiniWindow.ts: use index.html URL pattern to find main window
  (consistent with other step defs, avoids matching preferences window)
- ui.ts: clarify networkidle timeout comment
This commit is contained in:
linonetwo 2026-04-02 18:41:53 +08:00
parent c82bded055
commit 6b010fdde2
2 changed files with 4 additions and 3 deletions

View file

@ -105,8 +105,8 @@ When('I toggle tidgi mini window via IPC', async function(this: ApplicationWorld
throw new Error('Application not launched');
}
await this.app.evaluate(async ({ BrowserWindow }) => {
// Find the main window and call toggleTidgiMiniWindow via the service proxy
const mainWindow = BrowserWindow.getAllWindows().find(w => !w.isDestroyed() && w.webContents?.getType() === 'window');
// Find the main window by URL (consistent with other step defs)
const mainWindow = BrowserWindow.getAllWindows().find(w => !w.isDestroyed() && w.webContents?.getURL().includes('index.html'));
if (!mainWindow) throw new Error('Main window not found');
await mainWindow.webContents.executeJavaScript('window.service.window.toggleTidgiMiniWindow()');
});

View file

@ -45,7 +45,8 @@ When('I wait for the page to load completely', async function(this: ApplicationW
}
await currentWindow?.waitForLoadState('domcontentloaded', { timeout: PLAYWRIGHT_TIMEOUT });
// Short networkidle gives workspace-creation and other startup IPC time to finish
// without blocking on long-lived connections. 3s is enough for the initial burst.
// without blocking on long-lived connections. 3s is intentionally different from
// PLAYWRIGHT_TIMEOUT — this is just a grace period, not a hard requirement.
try {
await currentWindow?.waitForLoadState('networkidle', { timeout: 3000 });
} catch {