experiments in a post-browser web
10
fork

Configure Feed

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

test: update smoke tests for v2 tile architecture (iframes → BrowserWindows)

+66 -100
+66 -100
tests/desktop/smoke.spec.ts
··· 1365 1365 1366 1366 test.describe('Core Functionality @desktop', () => { 1367 1367 test('app launches and extensions load', async () => { 1368 - // In hybrid mode: 1369 - // - Built-in extensions (groups, peeks, slides) are in extension host as iframes 1370 - // - External extensions (example) are in separate windows 1368 + // After v2 tile migration: 1369 + // - Legacy v1 extensions (cmd, hud, page) load as iframes in extension-host 1370 + // - V2 features load as separate background BrowserWindows (peek://{id}/background.html) 1371 + // - Eager v2 features (e.g. entities, peeks, slides) launch at startup; 1372 + // lazy v2 features (e.g. example) launch on first command/event 1371 1373 1372 - // Wait for extension windows to be available with retry 1373 - let windows = sharedApp.windows(); 1374 - let extWindows = sharedApp.getExtensionWindows(); 1375 - 1376 - // Retry logic for extension windows to be fully loaded 1377 - const start = Date.now(); 1378 - while (extWindows.length < 1 && Date.now() - start < 10000) { 1379 - await sleep(200); 1380 - windows = sharedApp.windows(); 1381 - extWindows = sharedApp.getExtensionWindows(); 1382 - } 1383 - 1384 - // Check extension host exists (for built-in extensions) 1385 - const hostWindow = windows.find(w => w.url().includes('extension-host.html')); 1374 + // Check extension host exists (still used for legacy v1 iframes including cmd) 1375 + const hostWindow = await waitForWindow( 1376 + () => sharedApp.windows(), 1377 + 'peek://app/extension-host.html', 1378 + 15000 1379 + ); 1386 1380 expect(hostWindow).toBeDefined(); 1387 1381 1388 - // Check external extension window exists (example) using waitForWindow for reliability 1389 - const exampleWindow = await waitForWindow( 1382 + // Check that at least one eager v2 background tile window exists. 1383 + // peeks and slides are eager v2 background tiles that launch at startup. 1384 + const v2BgWindow = await waitForWindow( 1390 1385 () => sharedApp.windows(), 1391 - 'peek://ext/example/background.html', 1386 + 'peek://peeks/background.html', 1392 1387 15000 1393 1388 ); 1394 - expect(exampleWindow).toBeDefined(); 1389 + expect(v2BgWindow).toBeDefined(); 1395 1390 }); 1396 1391 1397 1392 test('database is accessible', async () => { ··· 4178 4173 }); 4179 4174 4180 4175 test('built-in extensions load as iframes in extension host', async () => { 4181 - // Get the extension host window 4176 + // After v2 tile migration: 4177 + // - Only legacy v1 consolidated extensions (cmd, hud, page) load as iframes 4178 + // inside the extension-host window. cmd is loaded by cmd-glue.ts. 4179 + // - V2 features (peeks, slides, groups, editor, etc.) now launch as 4180 + // separate background BrowserWindows at peek://{id}/background.html and 4181 + // are NOT iframes in the host. See "v2 background tile windows" test below. 4182 4182 const windows = sharedApp.windows(); 4183 4183 const hostWindow = windows.find(w => w.url().includes('peek://app/extension-host.html')); 4184 4184 expect(hostWindow).toBeDefined(); ··· 4186 4186 // Wait for #extensions container to exist (it may be hidden, so use 'attached' state) 4187 4187 await hostWindow!.waitForSelector('#extensions', { timeout: 15000, state: 'attached' }); 4188 4188 4189 - // Wait for at least 4 eager iframes to load (cmd, groups, hud, websearch) 4190 - // Lazy extensions (editor, lists, windows, pagestream) load on first use 4189 + // Wait for at least the cmd iframe to load 4191 4190 await hostWindow!.waitForFunction( 4192 4191 () => { 4193 4192 const container = document.getElementById('extensions'); 4194 4193 const iframes = container ? container.querySelectorAll('iframe') : []; 4195 - return iframes.length >= 4; 4194 + return Array.from(iframes).some(f => (f as HTMLIFrameElement).src.includes('peek://cmd/')); 4196 4195 }, 4197 4196 { timeout: 15000 } 4198 4197 ); 4199 4198 4200 - // Now get the iframe data 4201 4199 const iframeData = await hostWindow!.evaluate(() => { 4202 4200 const container = document.getElementById('extensions'); 4203 4201 const iframes = container ? Array.from(container.querySelectorAll('iframe')) : []; ··· 4207 4205 }; 4208 4206 }); 4209 4207 4210 - // Eager extensions: cmd (EAGER_EXTENSION_IDS), hud (EAGER_EXTENSION_IDS), 4211 - // plus extensions without manifest commands (peeks, slides, page, files, etc.) 4212 - // Lazy extensions with manifest commands (editor, groups, lists, pagestream, 4213 - // websearch, windows) load on first use 4214 - expect(iframeData.count).toBeGreaterThanOrEqual(4); 4208 + // cmd is always loaded as an iframe in the extension host (via cmd-glue.ts) 4209 + expect(iframeData.count).toBeGreaterThanOrEqual(1); 4215 4210 expect(iframeData.srcs.some(s => s.includes('peek://cmd/'))).toBe(true); 4216 - expect(iframeData.srcs.some(s => s.includes('peek://peeks/'))).toBe(true); 4217 - expect(iframeData.srcs.some(s => s.includes('peek://slides/'))).toBe(true); 4218 4211 }); 4219 4212 4220 - test('example extension loads as separate window (external)', async () => { 4221 - // Example extension should load in its own window, not in extension host 4222 - // Use waitForWindow helper with retry logic 4223 - const exampleWindow = await waitForWindow( 4213 + test('v2 background tile windows exist as separate BrowserWindows', async () => { 4214 + // V2 background tiles (peeks, slides) launch as separate hidden BrowserWindows 4215 + // at peek://{id}/background.html — NOT as iframes in the extension host. 4216 + const peeksWin = await waitForWindow( 4224 4217 () => sharedApp.windows(), 4225 - 'peek://ext/example/background.html', 4218 + 'peek://peeks/background.html', 4226 4219 15000 4227 4220 ); 4228 - expect(exampleWindow).toBeDefined(); 4221 + expect(peeksWin).toBeDefined(); 4222 + 4223 + const slidesWin = await waitForWindow( 4224 + () => sharedApp.windows(), 4225 + 'peek://slides/background.html', 4226 + 15000 4227 + ); 4228 + expect(slidesWin).toBeDefined(); 4229 + }); 4230 + 4231 + test.skip('example extension loads as separate window (external)', async () => { 4232 + // SKIPPED: After v2 tile migration, the example extension is a v2 tile 4233 + // (manifestVersion: 2) with a lazy background tile. It no longer loads at 4234 + // startup as an "external" v1 window at peek://ext/example/background.html. 4235 + // Instead it launches at peek://example/background.html on first command 4236 + // invocation. See the "v2 background tile windows" test for eager v2 tiles. 4237 + // 4238 + // No extension currently uses the v1 external-window pattern after the 4239 + // v2 migration, so there is no equivalent to test here. 4229 4240 }); 4230 4241 4231 4242 test('api.extensions.reload() reloads external extension', async () => { ··· 5272 5283 { timeout: 10000 } 5273 5284 ); 5274 5285 5275 - // Find a frame for a consolidated extension (e.g., slides or groups) 5286 + // After v2 tile migration, slides/groups/peeks are now separate v2 background 5287 + // BrowserWindows — not iframes in the host. The remaining v1 iframes in the 5288 + // extension host are cmd (loaded by cmd-glue.ts) and hud (eager v1 consolidated). 5289 + // Use the cmd iframe since it is always loaded. 5276 5290 const frames = hostWindow!.frames(); 5277 5291 const extFrame = frames.find(f => 5278 - f.url().includes('peek://slides/') || f.url().includes('peek://groups/') 5292 + f.url().includes('peek://cmd/') || f.url().includes('peek://hud/') 5279 5293 ); 5280 5294 expect(extFrame).toBeDefined(); 5281 5295 ··· 5334 5348 const hostWindow = sharedApp.windows().find(w => w.url().includes('extension-host.html')); 5335 5349 expect(hostWindow).toBeDefined(); 5336 5350 5337 - // Find a frame for a consolidated extension 5351 + // After v2 tile migration, slides/groups/peeks are now separate v2 background 5352 + // BrowserWindows — not iframes in the host. Use a remaining v1 iframe (cmd or hud). 5338 5353 const frames = hostWindow!.frames(); 5339 5354 const extFrame = frames.find(f => 5340 - f.url().includes('peek://slides/') || f.url().includes('peek://groups/') 5355 + f.url().includes('peek://cmd/') || f.url().includes('peek://hud/') 5341 5356 ); 5342 5357 expect(extFrame).toBeDefined(); 5343 5358 ··· 5380 5395 }); 5381 5396 }); 5382 5397 5383 - test('shortcut from external extension window roundtrip', async () => { 5384 - // Register a local shortcut from the example extension (separate BrowserWindow), 5385 - // trigger it via handleLocalShortcut, verify callback fires. 5386 - // This tests the standard BrowserWindow path for comparison with the iframe path. 5387 - 5388 - // Find the example extension window 5389 - const exampleWindow = await waitForWindow( 5390 - () => sharedApp.windows(), 5391 - 'peek://ext/example/background.html', 5392 - 15000 5393 - ); 5394 - expect(exampleWindow).toBeDefined(); 5395 - 5396 - // Register a local shortcut from the example extension window 5397 - await exampleWindow.evaluate(() => { 5398 - (window as any).__extShortcutFired = false; 5399 - (window as any).app.shortcuts.register('Alt+F6', () => { 5400 - (window as any).__extShortcutFired = true; 5401 - }); 5402 - }); 5403 - 5404 - // Wait for IPC to propagate 5405 - await sleep(300); 5406 - 5407 - // Trigger the shortcut from the main process 5408 - const handled = await sharedApp.evaluateMain!(({ app }) => { 5409 - try { 5410 - const { handleLocalShortcut } = (globalThis as any).__peek_test; 5411 - return handleLocalShortcut({ 5412 - type: 'keyDown', 5413 - alt: true, 5414 - shift: false, 5415 - meta: false, 5416 - control: false, 5417 - code: 'F6' 5418 - }); 5419 - } catch (e: any) { 5420 - return 'peek_test-failed: ' + e.message; 5421 - } 5422 - }); 5423 - 5424 - expect(handled).toBe(true); 5425 - 5426 - // Wait for the callback to fire in the example extension window 5427 - await exampleWindow.waitForFunction( 5428 - () => (window as any).__extShortcutFired === true, 5429 - { timeout: 5000 } 5430 - ); 5431 - 5432 - const fired = await exampleWindow.evaluate(() => (window as any).__extShortcutFired); 5433 - expect(fired).toBe(true); 5434 - 5435 - // Clean up 5436 - await exampleWindow.evaluate(() => { 5437 - (window as any).app.shortcuts.unregister('Alt+F6'); 5438 - delete (window as any).__extShortcutFired; 5439 - }); 5398 + test.skip('shortcut from external extension window roundtrip', async () => { 5399 + // SKIPPED: After v2 tile migration, no extension uses the v1 external-window 5400 + // pattern (peek://ext/{id}/background.html). The example extension is now a 5401 + // v2 tile launched at peek://example/background.html. v2 tile windows use 5402 + // tile-preload.ts which does NOT expose api.shortcuts (capability-scoped API 5403 + // does not currently include shortcut registration), so this scenario can't 5404 + // be reproduced. The general BrowserWindow ev.reply roundtrip is still 5405 + // covered by "local shortcut from background window roundtrip" above. 5440 5406 }); 5441 5407 }); 5442 5408