experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: auto-commit for deploy

+27 -34
+27 -34
tests/desktop/smoke.spec.ts
··· 505 505 test('active mode: ESC at root does NOT close window', async () => { 506 506 const bgWindow = sharedBgWindow; 507 507 508 - // Open a content window first to establish active mode 509 - // (visible content window = user has active Peek context) 510 - const contentResult = await bgWindow.evaluate(async () => { 511 - return await (window as any).app.window.open('peek://ext/settings/settings.html', { 512 - width: 400, 513 - height: 300, 514 - }); 515 - }); 516 - expect(contentResult.success).toBe(true); 517 - const contentWindow = await sharedApp.getWindow('settings/settings.html', 5000); 518 - expect(contentWindow).toBeTruthy(); 519 - await contentWindow.waitForLoadState('domcontentloaded'); 520 - 521 - // Open groups window - should be in active mode because settings is visible 508 + // Open groups window with role: 'workspace' (like the real groups extension does) 509 + // In headless/test mode, appFocused defaults to true → session is 'active' 522 510 const groupsResult = await bgWindow.evaluate(async () => { 523 511 return await (window as any).app.window.open('peek://ext/groups/home.html', { 512 + role: 'workspace', 524 513 width: 400, 525 514 height: 300, 526 - escapeMode: 'navigate' 527 515 }); 528 516 }); 529 517 expect(groupsResult.success).toBe(true); ··· 532 520 await groupsWindow.waitForLoadState('domcontentloaded'); 533 521 await groupsWindow.waitForSelector('.cards', { timeout: 5000 }); 534 522 535 - // Trigger ESC at root in active mode - renderer returns { handled: false } 536 - // Backend applies IZUI policy: active root window does NOT close 537 - const escResult = await groupsWindow.evaluate(async () => { 538 - return await (window as any).app.escape.trigger(); 523 + // Verify the window's role is 'workspace' and session is 'active' 524 + const izuiState = await bgWindow.evaluate(async () => { 525 + return await (window as any).app.izui.getState(); 539 526 }); 540 - // trigger() calls handler directly - at root, groups returns { handled: false } 541 - expect(escResult.handled).toBe(false); 527 + expect(izuiState).toBe('active'); 528 + 529 + // Press ESC via keyboard — goes through full backend path: 530 + // before-input-event → handleEscapeForWindow → askRendererToHandleEscape → 531 + // renderer returns { handled: false } at root → escPolicy('active', 'workspace') → 'nothing' 532 + await groupsWindow.keyboard.press('Escape'); 542 533 543 - // Wait a moment - window should still be open (trigger doesn't go through backend) 544 - await new Promise(resolve => setTimeout(resolve, 500)); 534 + // Wait for the async ESC handling to complete 535 + await new Promise(resolve => setTimeout(resolve, 600)); 545 536 546 - // Verify window is still alive (can still evaluate JS) 537 + // Verify window is still alive — if escPolicy is wrong, the window would be closed 547 538 const stillAlive = await groupsWindow.evaluate(() => true).catch(() => false); 548 539 expect(stillAlive).toBe(true); 549 540 550 - // Clean up both windows 551 - for (const id of [groupsResult.id, contentResult.id]) { 552 - if (id) { 553 - try { 554 - await bgWindow.evaluate(async (wid: number) => { 555 - return await (window as any).app.window.close(wid); 556 - }, id); 557 - } catch { 558 - // Window may already be closed 559 - } 541 + // Also verify the view is still at root (groups list) 542 + const view = await groupsWindow.evaluate(() => (window as any)._groupsState?.view); 543 + expect(view).toBe('groups'); 544 + 545 + // Clean up 546 + if (groupsResult.id) { 547 + try { 548 + await bgWindow.evaluate(async (wid: number) => { 549 + return await (window as any).app.window.close(wid); 550 + }, groupsResult.id); 551 + } catch { 552 + // Window may already be closed 560 553 } 561 554 } 562 555 });