experiments in a post-browser web
10
fork

Configure Feed

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

test(pubsub): migrate tests off deleted api.scopes surface

+92 -107
+3 -3
tests/desktop-serial/websearch-cmd.spec.ts
··· 88 88 } 89 89 90 90 // Trigger lazy load via a non-hanging command 91 - api.publish('cmd:execute:open web search', {}, api.scopes.GLOBAL); 91 + api.publish('cmd:execute:open web search', {}); 92 92 93 93 // Wait for it to be running 94 94 const start = Date.now(); ··· 292 292 if (settled) return; 293 293 settled = true; 294 294 resolve({ success: true, result }); 295 - }, api.scopes.GLOBAL); 295 + }); 296 296 297 297 api.publish('cmd:execute:kagi', { 298 298 typed: 'kagi test', ··· 301 301 search: 'test', 302 302 expectResult: true, 303 303 resultTopic, 304 - }, api.scopes.GLOBAL); 304 + }); 305 305 306 306 setTimeout(() => { 307 307 if (settled) return;
+4 -4
tests/desktop/cmd-execute-twice.spec.ts
··· 52 52 unsubscribe?.(); 53 53 const cmds = (msg as { commands?: Array<{ name: string }> })?.commands || []; 54 54 resolve(cmds.some(c => c.name === 'hello')); 55 - }, api.scopes.GLOBAL); 56 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 55 + }); 56 + api.publish('cmd:query-commands', {}); 57 57 setTimeout(() => { unsubscribe?.(); resolve(false); }, 200); 58 58 }); 59 59 }, null, { timeout: 15000 }); ··· 79 79 settled = true; 80 80 unsubscribe?.(); 81 81 resolve(result); 82 - }, api.scopes.GLOBAL); 83 - api.publish(`cmd:execute:${cmdName}`, { expectResult: true, resultTopic }, api.scopes.GLOBAL); 82 + }); 83 + api.publish(`cmd:execute:${cmdName}`, { expectResult: true, resultTopic }); 84 84 setTimeout(() => { 85 85 if (settled) return; 86 86 settled = true;
+18 -18
tests/desktop/command-execution.spec.ts
··· 61 61 const resultTopic = `cmd:execute:${args.name}:result`; 62 62 api.subscribe(resultTopic, (result: any) => { 63 63 resolve(result); 64 - }, api.scopes.GLOBAL); 64 + }); 65 65 66 66 api.publish(`cmd:execute:${args.name}`, { 67 67 search: args.search, 68 68 params: [], 69 69 expectResult: true, 70 70 resultTopic 71 - }, api.scopes.GLOBAL); 71 + }); 72 72 73 73 setTimeout(() => resolve({ error: 'timeout' }), 10000); 74 74 }); ··· 106 106 const resultTopic = `cmd:execute:${args.name}:result`; 107 107 api.subscribe(resultTopic, (result: any) => { 108 108 resolve(result); 109 - }, api.scopes.GLOBAL); 109 + }); 110 110 111 111 api.publish(`cmd:execute:${args.name}`, { 112 112 search: args.search, 113 113 params: [], 114 114 expectResult: true, 115 115 resultTopic 116 - }, api.scopes.GLOBAL); 116 + }); 117 117 118 118 setTimeout(() => resolve({ error: 'timeout' }), 10000); 119 119 }); ··· 160 160 const resultTopic = `cmd:execute:${args.name}:result`; 161 161 api.subscribe(resultTopic, (result: any) => { 162 162 resolve(result); 163 - }, api.scopes.GLOBAL); 163 + }); 164 164 165 165 api.publish(`cmd:execute:${args.name}`, { 166 166 search: args.search, 167 167 params: [], 168 168 expectResult: true, 169 169 resultTopic 170 - }, api.scopes.GLOBAL); 170 + }); 171 171 172 172 setTimeout(() => resolve({ error: 'timeout' }), 10000); 173 173 }); ··· 220 220 const resultTopic = `cmd:execute:${args.name}:result`; 221 221 api.subscribe(resultTopic, (result: any) => { 222 222 resolve(result); 223 - }, api.scopes.GLOBAL); 223 + }); 224 224 225 225 api.publish(`cmd:execute:${args.name}`, { 226 226 search: args.search, 227 227 params: [], 228 228 expectResult: true, 229 229 resultTopic 230 - }, api.scopes.GLOBAL); 230 + }); 231 231 232 232 setTimeout(() => resolve({ error: 'timeout' }), 10000); 233 233 }); ··· 254 254 const resultTopic = `cmd:execute:${args.name}:result`; 255 255 api.subscribe(resultTopic, (result: any) => { 256 256 resolve(result); 257 - }, api.scopes.GLOBAL); 257 + }); 258 258 259 259 api.publish(`cmd:execute:${args.name}`, { 260 260 search: args.search, 261 261 params: [], 262 262 expectResult: true, 263 263 resultTopic 264 - }, api.scopes.GLOBAL); 264 + }); 265 265 266 266 setTimeout(() => resolve({ error: 'timeout' }), 10000); 267 267 }); ··· 329 329 const resultTopic = `cmd:execute:${args.name}:result`; 330 330 api.subscribe(resultTopic, (result: any) => { 331 331 resolve(result); 332 - }, api.scopes.GLOBAL); 332 + }); 333 333 api.publish(`cmd:execute:${args.name}`, { 334 334 search: args.search, 335 335 params: [], 336 336 expectResult: true, 337 337 resultTopic 338 - }, api.scopes.GLOBAL); 338 + }); 339 339 setTimeout(() => resolve({ error: 'timeout' }), 10000); 340 340 }); 341 341 }, { name: 'tag', search: tag }); ··· 448 448 const resultTopic = `cmd:execute:${args.name}:result`; 449 449 api.subscribe(resultTopic, (result: any) => { 450 450 resolve(result); 451 - }, api.scopes.GLOBAL); 451 + }); 452 452 453 453 api.publish(`cmd:execute:${args.name}`, { 454 454 search: args.search, 455 455 params: [], 456 456 expectResult: true, 457 457 resultTopic 458 - }, api.scopes.GLOBAL); 458 + }); 459 459 460 460 setTimeout(() => resolve({ error: 'timeout' }), 10000); 461 461 }); ··· 470 470 const resultTopic = `cmd:execute:${args.name}:result`; 471 471 api.subscribe(resultTopic, (result: any) => { 472 472 resolve(result); 473 - }, api.scopes.GLOBAL); 473 + }); 474 474 475 475 api.publish(`cmd:execute:${args.name}`, { 476 476 search: '', 477 477 params: [], 478 478 expectResult: true, 479 479 resultTopic 480 - }, api.scopes.GLOBAL); 480 + }); 481 481 482 482 setTimeout(() => resolve({ error: 'timeout' }), 10000); 483 483 }); ··· 503 503 const resultTopic = `cmd:execute:${args.name}:result`; 504 504 api.subscribe(resultTopic, (result: any) => { 505 505 resolve(result); 506 - }, api.scopes.GLOBAL); 506 + }); 507 507 508 508 api.publish(`cmd:execute:${args.name}`, { 509 509 search: args.search, 510 510 params: [], 511 511 expectResult: true, 512 512 resultTopic 513 - }, api.scopes.GLOBAL); 513 + }); 514 514 515 515 setTimeout(() => resolve({ error: 'timeout' }), 10000); 516 516 });
+3 -3
tests/desktop/command-registration.spec.ts
··· 29 29 { name: 'test-batch-cmd-2', description: 'Test batch command 2', source: 'test' }, 30 30 { name: 'test-batch-cmd-3', description: 'Test batch command 3', source: 'test' } 31 31 ] 32 - }, api.scopes.GLOBAL); 32 + }); 33 33 34 34 // Poll for commands to appear (deterministic retry instead of fixed timeout) 35 35 const maxAttempts = 20; ··· 42 42 const unsub = api.subscribe('cmd:query-commands-response', (msg: any) => { 43 43 unsub?.(); 44 44 resolve(msg.commands || []); 45 - }, api.scopes.GLOBAL); 46 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 45 + }); 46 + api.publish('cmd:query-commands', {}); 47 47 setTimeout(() => resolve([]), 500); 48 48 }); 49 49
+6 -6
tests/desktop/core.spec.ts
··· 48 48 const queryCommands = () => new Promise((resolve) => { 49 49 api.subscribe('cmd:query-commands-response', (msg: any) => { 50 50 resolve(msg.commands || []); 51 - }, api.scopes.GLOBAL); 52 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 51 + }); 52 + api.publish('cmd:query-commands', {}); 53 53 setTimeout(() => resolve([]), 1000); 54 54 }); 55 55 ··· 90 90 quitCmd: commands.find((c: any) => c.name === 'quit'), 91 91 restartCmd: commands.find((c: any) => c.name === 'restart') 92 92 }); 93 - }, api.scopes.GLOBAL); 94 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 93 + }); 94 + api.publish('cmd:query-commands', {}); 95 95 setTimeout(() => resolve({ hasQuit: false, hasRestart: false }), 2000); 96 96 }); 97 97 }); ··· 114 114 hasReloadExtension: !!reloadCmd, 115 115 description: reloadCmd?.description 116 116 }); 117 - }, api.scopes.GLOBAL); 118 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 117 + }); 118 + api.publish('cmd:query-commands', {}); 119 119 setTimeout(() => resolve({ hasReloadExtension: false }), 2000); 120 120 }); 121 121 });
+2 -2
tests/desktop/external-url.spec.ts
··· 297 297 if (msg?.url && (msg.url.includes(url) || msg.url.includes(encodeURIComponent(url)))) { 298 298 (window as any).__externalUrlWindowOpened = msg; 299 299 } 300 - }, api.scopes.GLOBAL); 300 + }); 301 301 }, testUrl); 302 302 303 303 // Trigger external:open-url event directly (simulates what handleExternalUrl does) ··· 311 311 trackingSource: 'external', 312 312 trackingSourceId: 'os', 313 313 timestamp: Date.now() 314 - }, api.scopes.GLOBAL); 314 + }); 315 315 }, testUrl); 316 316 317 317 // Wait for the window:opened event for our URL — deterministic.
+4 -4
tests/desktop/hybrid-extension.spec.ts
··· 79 79 // settings comes from core (via consolidated cmd) 80 80 hasSettingsCommand: msg.commands?.some((c: any) => c.name === 'settings') 81 81 }); 82 - }, api.scopes.GLOBAL); 82 + }); 83 83 84 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 84 + api.publish('cmd:query-commands', {}); 85 85 }); 86 86 }); 87 87 ··· 110 110 received: true, 111 111 commandCount: msg.commands?.length || 0 112 112 }); 113 - }, api.scopes.GLOBAL); 113 + }); 114 114 115 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 115 + api.publish('cmd:query-commands', {}); 116 116 }); 117 117 }); 118 118
+6 -6
tests/desktop/hybrid-settings.spec.ts
··· 44 44 shortcutKey: msg?.prefs?.shortcutKey, 45 45 isDefault: msg?.prefs?.shortcutKey === defaultShortcut 46 46 }); 47 - }, api.scopes.GLOBAL); 47 + }); 48 48 49 49 // Poke cmd to report its settings - use the default to not change it 50 50 api.publish('cmd:settings-update', { 51 51 data: { prefs: { shortcutKey: defaultShortcut } } 52 - }, api.scopes.GLOBAL); 52 + }); 53 53 }); 54 54 }); 55 55 ··· 90 90 receivedShortcut: msg?.prefs?.shortcutKey, 91 91 matchesExpected: msg?.prefs?.shortcutKey === shortcut 92 92 }); 93 - }, api.scopes.GLOBAL); 93 + }); 94 94 95 95 // Update cmd settings via pubsub (this is how Settings UI does it) 96 96 api.publish('cmd:settings-update', { 97 97 data: { prefs: { shortcutKey: shortcut } } 98 - }, api.scopes.GLOBAL); 98 + }); 99 99 }); 100 100 }, customShortcut); 101 101 ··· 193 193 // Check if it's NOT the default (Option+Space) 194 194 isNotDefault: msg?.prefs?.shortcutKey !== 'Option+Space' 195 195 }); 196 - }, api.scopes.GLOBAL); 196 + }); 197 197 198 198 // Poke cmd to report its current settings (update with same value) 199 199 api.publish('cmd:settings-update', { 200 200 data: { prefs: { shortcutKey: expectedShortcut } } 201 - }, api.scopes.GLOBAL); 201 + }); 202 202 }); 203 203 }, customShortcut); 204 204
+3 -3
tests/desktop/item-events.spec.ts
··· 36 36 content: msg.content 37 37 }); 38 38 } 39 - }, api.scopes.GLOBAL); 39 + }); 40 40 41 41 // Create item to trigger the event 42 42 api.datastore.addItem('url', { ··· 82 82 itemType: msg.itemType 83 83 }); 84 84 } 85 - }, api.scopes.GLOBAL); 85 + }); 86 86 87 87 // Update item to trigger the event 88 88 api.datastore.updateItem(itemId, { ··· 126 126 itemType: msg.itemType 127 127 }); 128 128 } 129 - }, api.scopes.GLOBAL); 129 + }); 130 130 131 131 // Delete item to trigger the event 132 132 api.datastore.deleteItem(itemId);
+1 -1
tests/desktop/izui-behavior.spec.ts
··· 191 191 content: msg.content 192 192 }); 193 193 } 194 - }, api.scopes.GLOBAL); 194 + }); 195 195 196 196 // Open a window with an external URL - this triggers trackWindowLoad 197 197 // which emits item:created if the URL is new
+13 -13
tests/desktop/page-widgets.spec.ts
··· 116 116 widgetId: 'test-widget', 117 117 title: 'Test Widget', 118 118 position: 'right', 119 - }, api.scopes.GLOBAL); 119 + }); 120 120 }); 121 121 122 122 // Verify registration ··· 144 144 extensionId: 'test-ext', 145 145 widgetId: 'render-test', 146 146 title: 'Render Test', 147 - }, api.scopes.GLOBAL); 147 + }); 148 148 149 149 api.publish('widget:render', { 150 150 extensionId: 'test-ext', 151 151 widgetId: 'render-test', 152 152 title: 'Rendered Widget', 153 153 html: '<p class="test-content">Widget content here</p>', 154 - }, api.scopes.GLOBAL); 154 + }); 155 155 }); 156 156 157 157 // Verify widget DOM was created ··· 193 193 api.publish('widget:register', { 194 194 extensionId: 'test-ext', 195 195 widgetId: 'update-test', 196 - }, api.scopes.GLOBAL); 196 + }); 197 197 198 198 api.publish('widget:render', { 199 199 extensionId: 'test-ext', 200 200 widgetId: 'update-test', 201 201 html: '<p>Original</p>', 202 - }, api.scopes.GLOBAL); 202 + }); 203 203 }); 204 204 205 205 // Wait for initial render ··· 217 217 widgetId: 'update-test', 218 218 html: '<p>Updated content</p>', 219 219 title: 'New Title', 220 - }, api.scopes.GLOBAL); 220 + }); 221 221 }); 222 222 223 223 // Verify update ··· 246 246 api.publish('widget:register', { 247 247 extensionId: 'test-ext', 248 248 widgetId: 'close-test', 249 - }, api.scopes.GLOBAL); 249 + }); 250 250 251 251 api.publish('widget:render', { 252 252 extensionId: 'test-ext', 253 253 widgetId: 'close-test', 254 254 html: '<p>To be closed</p>', 255 - }, api.scopes.GLOBAL); 255 + }); 256 256 }); 257 257 258 258 // Wait for render ··· 268 268 api.publish('widget:close', { 269 269 extensionId: 'test-ext', 270 270 widgetId: 'close-test', 271 - }, api.scopes.GLOBAL); 271 + }); 272 272 }); 273 273 274 274 // Wait for removal (animation takes 300ms) ··· 324 324 if (msg.requestId !== rid) return; 325 325 clearTimeout(timer); 326 326 resolve(msg); 327 - }, api.scopes.GLOBAL); 327 + }); 328 328 }); 329 329 }, requestId); 330 330 ··· 335 335 extensionId: 'test-ext', 336 336 requestId: rid, 337 337 script: 'document.title', 338 - }, api.scopes.GLOBAL); 338 + }); 339 339 }, requestId); 340 340 341 341 const result = await resultPromise; ··· 374 374 if (msg.requestId !== rid) return; 375 375 clearTimeout(timer); 376 376 resolve(msg); 377 - }, api.scopes.GLOBAL); 377 + }); 378 378 }); 379 379 }, requestId); 380 380 ··· 385 385 extensionId: 'test-ext', 386 386 requestId: rid, 387 387 script: 'throw new Error("intentional test error")', 388 - }, api.scopes.GLOBAL); 388 + }); 389 389 }, requestId); 390 390 391 391 const result = await resultPromise;
+1 -1
tests/desktop/pubsub-repro.spec.ts
··· 39 39 // Mirrors the websearch pattern at websearch.spec.ts:91-126. 40 40 const extensionLoaded = await sharedBgWindow.evaluate(async () => { 41 41 const api = (window as any).app; 42 - api.publish('cmd:execute:pubsub repro', {}, api.scopes.GLOBAL); 42 + api.publish('cmd:execute:pubsub repro', {}); 43 43 const start = Date.now(); 44 44 while (Date.now() - start < 15000) { 45 45 const result = await api.extensions.list();
+3 -3
tests/desktop/startup-events.spec.ts
··· 27 27 // Subscribe to startup phase events 28 28 api.subscribe('ext:startup:phase', (msg: any) => { 29 29 received = true; 30 - }, api.scopes.GLOBAL); 30 + }); 31 31 32 32 // The subscription should be set up without error 33 33 return { subscriptionCreated: true }; ··· 66 66 const queryCommands = () => new Promise((resolve) => { 67 67 api.subscribe('cmd:query-commands-response', (msg: any) => { 68 68 resolve(msg.commands || []); 69 - }, api.scopes.GLOBAL); 70 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 69 + }); 70 + api.publish('cmd:query-commands', {}); 71 71 setTimeout(() => resolve([]), 1000); 72 72 }); 73 73
+4 -4
tests/desktop/tag-events.spec.ts
··· 35 35 tagName: msg.tagName 36 36 }); 37 37 } 38 - }, api.scopes.GLOBAL); 38 + }); 39 39 40 40 // Create new tag to trigger the event 41 41 api.datastore.getOrCreateTag(name); ··· 86 86 itemType: msg.itemType 87 87 }); 88 88 } 89 - }, api.scopes.GLOBAL); 89 + }); 90 90 91 91 // Tag the item to trigger the event 92 92 api.datastore.tagItem(itemId, tagId); ··· 142 142 itemId: msg.itemId 143 143 }); 144 144 } 145 - }, api.scopes.GLOBAL); 145 + }); 146 146 147 147 // Untag the item to trigger the event 148 148 api.datastore.untagItem(itemId, tagId); ··· 196 196 clearTimeout(timeout); 197 197 resolve({ received: true }); // This would be unexpected 198 198 } 199 - }, api.scopes.GLOBAL); 199 + }); 200 200 201 201 // Try to tag the same item with the same tag again 202 202 api.datastore.tagItem(itemId, tagId);
+4 -7
tests/desktop/v2-pubsub-reproducer.spec.ts
··· 68 68 (window as any).__reproDiag = { 69 69 apiExists: !!api, 70 70 hasSubscribe: !!(api && api.subscribe), 71 - hasScopes: !!(api && api.scopes), 72 - scopeGlobal: api && api.scopes && api.scopes.GLOBAL, 73 71 }; 74 - if (api && api.subscribe && api.scopes) { 72 + if (api && api.subscribe) { 75 73 api.subscribe('repro:v2-v2-hello', (msg: unknown) => { 76 74 (window as any).__reproReceived = msg; 77 - }, api.scopes.GLOBAL); 75 + }); 78 76 (window as any).__reproDiag.subscribed = true; 79 77 } 80 78 }); ··· 88 86 const diag: any = { 89 87 apiExists: !!api, 90 88 hasPublish: !!(api && api.publish), 91 - scopeGlobal: api && api.scopes && api.scopes.GLOBAL, 92 89 }; 93 - if (api && api.publish && api.scopes) { 94 - api.publish('repro:v2-v2-hello', { from: 'core', ts: Date.now() }, api.scopes.GLOBAL); 90 + if (api && api.publish) { 91 + api.publish('repro:v2-v2-hello', { from: 'core', ts: Date.now() }); 95 92 diag.published = true; 96 93 } 97 94 return diag;
+1 -1
tests/desktop/websearch.spec.ts
··· 93 93 const extensionLoaded = await sharedBgWindow.evaluate(async () => { 94 94 const api = (window as any).app; 95 95 // Trigger the lazy stub — this loads the extension 96 - api.publish('cmd:execute:open web search', {}, api.scopes.GLOBAL); 96 + api.publish('cmd:execute:open web search', {}); 97 97 98 98 // Wait for the extension to be running 99 99 const start = Date.now();
+7 -13
tests/helpers/window-utils.ts
··· 225 225 extensions: { 226 226 list(): Promise<ExtensionListResult>; 227 227 }; 228 - subscribe(event: string, callback: (msg: unknown) => void, scope: unknown): () => void; 229 - publish(event: string, data: unknown, scope: unknown): void; 230 - scopes: { 231 - GLOBAL: unknown; 232 - }; 228 + subscribe(event: string, callback: (msg: unknown) => void): () => void; 229 + publish(event: string, data: unknown): void; 233 230 } 234 231 235 232 interface WindowWithApp extends Window { ··· 290 287 resolved = true; 291 288 clearTimeout(t); 292 289 resolve(msg); 293 - }, 294 - api.scopes.GLOBAL 290 + } 295 291 ); 296 292 }); 297 293 }, ··· 328 324 resolved = true; 329 325 const response = msg as QueryCommandsResponse; 330 326 resolve(response.commands?.some((c) => c.name === cmd) || false); 331 - }, 332 - api.scopes.GLOBAL 327 + } 333 328 ); 334 329 335 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 330 + api.publish('cmd:query-commands', {}); 336 331 setTimeout(() => { if (!resolved) { resolved = true; resolve(false); } }, 500); 337 332 }); 338 333 }, commandName); ··· 365 360 resolved = true; 366 361 const response = msg as QueryCommandsResponse; 367 362 resolve((response.commands as CommandInfo[]) || []); 368 - }, 369 - api.scopes.GLOBAL 363 + } 370 364 ); 371 365 372 - api.publish('cmd:query-commands', {}, api.scopes.GLOBAL); 366 + api.publish('cmd:query-commands', {}); 373 367 setTimeout(() => { if (!resolved) { resolved = true; resolve(null); } }, 1000); 374 368 }); 375 369
+2 -8
tests/mocks/tauri-backend.js
··· 52 52 api.debugLevels = { BASIC: 1, FIRST_RUN: 2 }; 53 53 api.debugLevel = 1; 54 54 55 - api.scopes = { 56 - SYSTEM: 1, 57 - SELF: 2, 58 - GLOBAL: 3 59 - }; 60 - 61 55 // ==================== Shortcuts ==================== 62 56 63 57 api.shortcuts = { ··· 169 163 170 164 // ==================== PubSub ==================== 171 165 172 - api.publish = (topic, msg, scope = api.scopes.SELF) => { 166 + api.publish = (topic, msg) => { 173 167 console.log('[mock] publish:', topic); 174 168 const callbacks = store.subscriptions.get(topic) || []; 175 169 callbacks.forEach(cb => { ··· 181 175 }); 182 176 }; 183 177 184 - api.subscribe = (topic, callback, scope = api.scopes.SELF) => { 178 + api.subscribe = (topic, callback) => { 185 179 console.log('[mock] subscribe:', topic); 186 180 if (!store.subscriptions.has(topic)) { 187 181 store.subscriptions.set(topic, []);
+7 -7
tests/unit/page-widgets.test.js
··· 538 538 extensionId: 'ext-pubsub', 539 539 widgetId: 'w-pubsub', 540 540 title: 'Pubsub Widget', 541 - }, api.scopes.GLOBAL); 541 + }); 542 542 543 543 assert.equal(host.getWidgets().size, 1); 544 544 assert.ok(host.getWidgets().has('ext-pubsub:w-pubsub')); ··· 551 551 api.publish('widget:register', { 552 552 extensionId: 'ext1', 553 553 widgetId: 'w1', 554 - }, api.scopes.GLOBAL); 554 + }); 555 555 556 556 api.publish('widget:render', { 557 557 extensionId: 'ext1', 558 558 widgetId: 'w1', 559 559 html: '<p>Pubsub rendered</p>', 560 - }, api.scopes.GLOBAL); 560 + }); 561 561 562 562 assert.equal(widgetFns._added.length, 1); 563 563 }); ··· 569 569 // Register 570 570 api.publish('widget:register', { 571 571 extensionId: 'ext1', widgetId: 'w1', title: 'Lifecycle' 572 - }, api.scopes.GLOBAL); 572 + }); 573 573 assert.equal(host.getWidgets().size, 1); 574 574 575 575 // Render 576 576 api.publish('widget:render', { 577 577 extensionId: 'ext1', widgetId: 'w1', html: '<p>V1</p>' 578 - }, api.scopes.GLOBAL); 578 + }); 579 579 assert.equal(widgetFns._added.length, 1); 580 580 assert.equal(host.getActiveWidgets().size, 1); 581 581 582 582 // Update 583 583 api.publish('widget:update', { 584 584 extensionId: 'ext1', widgetId: 'w1', html: '<p>V2</p>', title: 'Updated' 585 - }, api.scopes.GLOBAL); 585 + }); 586 586 assert.equal(widgetFns._updated.length, 1); 587 587 588 588 // Close 589 589 api.publish('widget:close', { 590 590 extensionId: 'ext1', widgetId: 'w1' 591 - }, api.scopes.GLOBAL); 591 + }); 592 592 assert.equal(host.getActiveWidgets().size, 0); 593 593 }); 594 594 });