Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop-ui): r5-l2 observe stale spinner completion
Josuéfae005b1e74f
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/controllerHarness.tsx b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/controllerHarness.tsxindex dd5a1e50f..26b1587cf 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/controllerHarness.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/controllerHarness.tsx@@ -109,7 +109,12 @@ export function renderController(} as ControllerParams)useLayoutEffect(() => {options.onLayoutCommit?.(controller)- }, [controller.activeChatId, controller.chatMessages, options.onLayoutCommit])+ }, [+ controller.activeChatId,+ controller.chatMessages,+ controller.chatMessagesLoading,+ options.onLayoutCommit,+ ])return controller},{diff --git a/desktop-app/ui/src/hooks/domain/__tests__/selectionGuardCoverage.characterization.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/selectionGuardCoverage.characterization.test.tsxindex 369179139..d0a72f740 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/selectionGuardCoverage.characterization.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/selectionGuardCoverage.characterization.test.tsx@@ -7,8 +7,9 @@ import {setComposerDraft,} from '@lib/composerDraftStore'import { parseSessionsListResult } from '../../../../../src/rpcProxyClient'+import { makeTaskKey } from '../../../contexts/AgentTaskTrackerContext/types'import type { ComposerImageAttachment } from '../../../uiTypes'-import { deferred } from './__fixtures__/catalogFixtures'+import { deferred, serverSessionMessages } from './__fixtures__/catalogFixtures'import { renderController } from './__fixtures__/controllerHarness'import { type MockClerum, installMockClerum, uninstallMockClerum } from './__fixtures__/mockClerum'@@ -80,6 +81,27 @@ async function startSpecificIndexLoad(return { heldIndex, chatIndex: await clerum.readIndex('agent-x') }}+function holdSessionMessages(chatId: string) {+ const original = clerum.rpc.loadSessionMessages.getMockImplementation()+ if (!original) throw new Error('Expected the loadSessionMessages test mock implementation')+ const entered = deferred<void>()+ const release = deferred<void>()+ const returned = deferred<void>()+ let held = false+ clerum.rpc.loadSessionMessages.mockImplementation(async (...args) => {+ const requestedChatId = args[2]+ if (requestedChatId === chatId && !held) {+ held = true+ entered.resolve()+ await release.promise+ }+ const result = await original(...args)+ if (held && requestedChatId === chatId) returned.resolve()+ return result+ })+ return { entered, release, returned }+}+function holdLastActive(chatId: string) {const original = clerum.chat.setLastActive.getMockImplementation()if (!original) throw new Error('Expected the ChatStore setLastActive producer')@@ -201,11 +223,18 @@ describe('selection intent and continuation guards', () => {'does not let an older %s completion clear a newer selection spinner',async mode => {clerum.rpc.listSessions.mockResolvedValue(remoteCatalog())- const heldLastActive = holdLastActive('catalog-latest')- const controller = renderController({- navItem: mode === 'latest' ? 'agents' : 'chat',- loadMenuData: false,- })+ clerum.rpc.loadSessionMessages.mockResolvedValue(+ await serverSessionMessages('agent-x', 'catalog-latest')+ )+ const heldSession = holdSessionMessages('catalog-latest')+ const observedLoading: boolean[] = []+ const controller = renderController(+ {+ navItem: mode === 'latest' ? 'agents' : 'chat',+ loadMenuData: false,+ },+ { onLayoutCommit: view => observedLoading.push(view.chatMessagesLoading) }+ )if (mode === 'latest') {await waitForListIdle(controller)await act(async () => {@@ -216,24 +245,33 @@ describe('selection intent and continuation guards', () => {})}try {- await heldLastActive.entered.promise+ await heldSession.entered.promise+ const latestKey = makeTaskKey('agent-x', 'catalog-latest')+ expect(controller.result.current.sessionStateByChatKey[latestKey]?.syncing).toBe(true)expect(controller.result.current.activeChatId).toBe('catalog-latest')- expect(controller.result.current.chatMessagesLoading).toBe(true)+ expect(controller.result.current.chatMessagesLoading).toBe(false)+ const loadingObservationStart = observedLoading.lengthact(() => controller.result.current.setPendingChatSelection('agent-x', 'newer-chat'))expect(controller.result.current.activeChatId).toBe('newer-chat')expect(controller.result.current.chatMessagesLoading).toBe(true)await act(async () => {- heldLastActive.release.resolve()- await heldLastActive.returned.promise+ heldSession.release.resolve()+ await heldSession.returned.promise+ })+ await waitFor(() =>+ expect(controller.result.current.sessionStateByChatKey[latestKey]?.syncing).toBe(false)+ )+ await act(async () => {await new Promise(resolve => setTimeout(resolve, 0))})expect(controller.result.current.activeChatId).toBe('newer-chat')expect(controller.result.current.chatMessages).toEqual([])expect(controller.result.current.chatMessagesLoading).toBe(true)+ expect(observedLoading.slice(loadingObservationStart)).not.toContain(false)} finally {- heldLastActive.release.resolve()+ heldSession.release.resolve()controller.unmount()}}