experiments in a post-browser web
10
fork

Configure Feed

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

test(smoke): delete v1 api.commands.flush batching tests (no-op in v2)

+14 -94
-1
.yarn/releases
··· 1 - /Users/dietrich/misc/mpeek/.yarn/releases
+14
backend/electron/tile-preload.cts
··· 474 474 }, 3000); 475 475 }); 476 476 }, 477 + 478 + /** 479 + * Flush any pending command registrations immediately. 480 + * 481 + * In the v2 tile path, commands are published synchronously via 482 + * ipcRenderer.send() in register() — there is no batch queue. 483 + * This method exists for API compatibility with v1 callers that 484 + * called flush() after a burst of register() calls; it is a no-op. 485 + */ 486 + flush: (): Promise<{ success: true }> => { 487 + // No-op: register() already sends each cmd:register publish 488 + // synchronously, so nothing to drain. 489 + return Promise.resolve({ success: true }); 490 + }, 477 491 }; 478 492 479 493 // ── Window ────────────────────────────────────────────────────────
-1
node_modules
··· 1 - /Users/dietrich/misc/mpeek/node_modules
-92
tests/desktop/smoke.spec.ts
··· 3953 3953 expect(result.batchCommandNames).toContain('test-batch-cmd-3'); 3954 3954 }); 3955 3955 3956 - test('api.commands.flush() sends pending registrations immediately', async () => { 3957 - // Test that flush() can be called to send batched commands immediately 3958 - const result = await bgWindow.evaluate(async () => { 3959 - const api = (window as any).app; 3960 - 3961 - // Register a command (it will be batched) 3962 - api.commands.register({ 3963 - name: 'test-flush-cmd', 3964 - description: 'Test flush command', 3965 - execute: () => {} 3966 - }); 3967 - 3968 - // Immediately flush 3969 - api.commands.flush(); 3970 - 3971 - // Poll for command to appear (deterministic retry) 3972 - const maxAttempts = 20; 3973 - const pollInterval = 100; 3974 - 3975 - for (let attempt = 0; attempt < maxAttempts; attempt++) { 3976 - await new Promise(r => setTimeout(r, pollInterval)); 3977 - 3978 - const commands = await new Promise<any[]>((resolve) => { 3979 - const unsub = api.subscribe('cmd:query-commands-response', (msg: any) => { 3980 - unsub?.(); 3981 - resolve(msg.commands || []); 3982 - }, api.scopes.GLOBAL); 3983 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 3984 - setTimeout(() => resolve([]), 500); 3985 - }); 3986 - 3987 - const flushCmd = commands.find((c: any) => c.name === 'test-flush-cmd'); 3988 - if (flushCmd) { 3989 - return { found: true, commandName: flushCmd.name }; 3990 - } 3991 - } 3992 - 3993 - return { found: false }; 3994 - }); 3995 - 3996 - expect(result.found).toBe(true); 3997 - expect(result.commandName).toBe('test-flush-cmd'); 3998 - }); 3999 - 4000 - test('commands registered via api.commands.register are batched', async () => { 4001 - // Test that multiple rapid registrations are batched (not sent individually) 4002 - const result = await bgWindow.evaluate(async () => { 4003 - const api = (window as any).app; 4004 - 4005 - // Register multiple commands rapidly 4006 - for (let i = 0; i < 5; i++) { 4007 - api.commands.register({ 4008 - name: `test-rapid-cmd-${i}`, 4009 - description: `Rapid command ${i}`, 4010 - execute: () => {} 4011 - }); 4012 - } 4013 - 4014 - // Flush to ensure they're sent 4015 - api.commands.flush(); 4016 - 4017 - // Poll for all 5 commands to appear (deterministic retry) 4018 - const maxAttempts = 20; 4019 - const pollInterval = 100; 4020 - 4021 - for (let attempt = 0; attempt < maxAttempts; attempt++) { 4022 - await new Promise(r => setTimeout(r, pollInterval)); 4023 - 4024 - const commands = await new Promise<any[]>((resolve) => { 4025 - const unsub = api.subscribe('cmd:query-commands-response', (msg: any) => { 4026 - unsub?.(); 4027 - resolve(msg.commands || []); 4028 - }, api.scopes.GLOBAL); 4029 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 4030 - setTimeout(() => resolve([]), 500); 4031 - }); 4032 - 4033 - const rapidCmds = commands.filter((c: any) => c.name.startsWith('test-rapid-cmd-')); 4034 - if (rapidCmds.length === 5) { 4035 - return { 4036 - commandsRegistered: rapidCmds.length, 4037 - allCommandsPresent: true 4038 - }; 4039 - } 4040 - } 4041 - 4042 - return { commandsRegistered: 0, allCommandsPresent: false }; 4043 - }); 4044 - 4045 - expect(result.commandsRegistered).toBe(5); 4046 - expect(result.allCommandsPresent).toBe(true); 4047 - }); 4048 3956 }); 4049 3957 4050 3958 // ============================================================================