| ... | @@ -21,7 +21,7 @@ import { render } from "vitest-browser-react"; | ... | @@ -21,7 +21,7 @@ import { render } from "vitest-browser-react"; |
| 21 | import { useComposerDraftStore } from "../composerDraftStore"; | 21 | import { useComposerDraftStore } from "../composerDraftStore"; |
| 22 | import { __resetLocalApiForTests } from "../localApi"; | 22 | import { __resetLocalApiForTests } from "../localApi"; |
| 23 | import { AppAtomRegistryProvider } from "../rpc/atomRegistry"; | 23 | import { AppAtomRegistryProvider } from "../rpc/atomRegistry"; |
| 24 | import { getServerConfig } from "../rpc/serverState"; | 24 | import { getServerConfig, getServerConfigUpdatedNotification } from "../rpc/serverState"; |
| 25 | import { getWsConnectionStatus } from "../rpc/wsConnectionState"; | 25 | import { getWsConnectionStatus } from "../rpc/wsConnectionState"; |
| 26 | import { getRouter } from "../router"; | 26 | import { getRouter } from "../router"; |
| 27 | import { useStore } from "../store"; | 27 | import { useStore } from "../store"; |
| ... | @@ -303,11 +303,6 @@ async function waitForNoToasts(): Promise<void> { | ... | @@ -303,11 +303,6 @@ async function waitForNoToasts(): Promise<void> { |
| 303 | ); | 303 | ); |
| 304 | } | 304 | } |
| 305 | | 305 | |
| 306 | async function warmServerConfigUpdateStream(): Promise<void> { | | |
| 307 | sendServerConfigUpdatedPush([]); | | |
| 308 | await new Promise((resolve) => setTimeout(resolve, 50)); | | |
| 309 | } | | |
| 310 | | | |
| 311 | async function waitForInitialWsSubscriptions(): Promise<void> { | 306 | async function waitForInitialWsSubscriptions(): Promise<void> { |
| 312 | await vi.waitFor( | 307 | await vi.waitFor( |
| 313 | () => { | 308 | () => { |
| ... | @@ -331,6 +326,33 @@ async function waitForServerConfigSnapshot(): Promise<void> { | ... | @@ -331,6 +326,33 @@ async function waitForServerConfigSnapshot(): Promise<void> { |
| 331 | ); | 326 | ); |
| 332 | } | 327 | } |
| 333 | | 328 | |
| | 329 | async function waitForServerConfigStreamReady(): Promise<void> { |
| | 330 | const previousNotificationId = getServerConfigUpdatedNotification()?.id ?? 0; |
| | 331 | for (let attempt = 0; attempt < 20; attempt += 1) { |
| | 332 | rpcHarness.emitStreamValue(WS_METHODS.subscribeServerConfig, { |
| | 333 | version: 1, |
| | 334 | type: "settingsUpdated", |
| | 335 | payload: { settings: fixture.serverConfig.settings }, |
| | 336 | }); |
| | 337 | |
| | 338 | try { |
| | 339 | await vi.waitFor( |
| | 340 | () => { |
| | 341 | const notification = getServerConfigUpdatedNotification(); |
| | 342 | expect(notification?.id).toBeGreaterThan(previousNotificationId); |
| | 343 | expect(notification?.source).toBe("settingsUpdated"); |
| | 344 | }, |
| | 345 | { timeout: 200, interval: 16 }, |
| | 346 | ); |
| | 347 | return; |
| | 348 | } catch { |
| | 349 | await new Promise((resolve) => setTimeout(resolve, 25)); |
| | 350 | } |
| | 351 | } |
| | 352 | |
| | 353 | throw new Error("Timed out waiting for the server config stream to deliver updates."); |
| | 354 | } |
| | 355 | |
| 334 | async function mountApp(): Promise<{ cleanup: () => Promise<void> }> { | 356 | async function mountApp(): Promise<{ cleanup: () => Promise<void> }> { |
| 335 | const host = document.createElement("div"); | 357 | const host = document.createElement("div"); |
| 336 | host.style.position = "fixed"; | 358 | host.style.position = "fixed"; |
| ... | @@ -356,6 +378,7 @@ async function mountApp(): Promise<{ cleanup: () => Promise<void> }> { | ... | @@ -356,6 +378,7 @@ async function mountApp(): Promise<{ cleanup: () => Promise<void> }> { |
| 356 | await waitForInitialWsSubscriptions(); | 378 | await waitForInitialWsSubscriptions(); |
| 357 | await waitForWsConnection(); | 379 | await waitForWsConnection(); |
| 358 | await waitForServerConfigSnapshot(); | 380 | await waitForServerConfigSnapshot(); |
| | 381 | await waitForServerConfigStreamReady(); |
| 359 | await waitForNoToasts(); | 382 | await waitForNoToasts(); |
| 360 | | 383 | |
| 361 | return { | 384 | return { |
| ... | @@ -429,8 +452,6 @@ describe("Keybindings update toast", () => { | ... | @@ -429,8 +452,6 @@ describe("Keybindings update toast", () => { |
| 429 | const mounted = await mountApp(); | 452 | const mounted = await mountApp(); |
| 430 | | 453 | |
| 431 | try { | 454 | try { |
| 432 | await warmServerConfigUpdateStream(); | | |
| 433 | | | |
| 434 | sendServerConfigUpdatedPush([]); | 455 | sendServerConfigUpdatedPush([]); |
| 435 | await waitForToast("Keybindings updated", 1); | 456 | await waitForToast("Keybindings updated", 1); |
| 436 | | 457 | |