Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop): fix desktop-app CI — unmount leaky hook + cwd-independent styles read
Alfredo Lopez262a0cd05e9a
diff --git a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsxindex 6d2ab7427..2e96a508e 100644--- a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx@@ -2,9 +2,14 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { cleanup, fireEvent, render, screen } from '@testing-library/react'import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'import { ComposerPanel } from '../ComposerPanel'-const composerStyles = readFileSync('ui/src/styles.css', 'utf8')+// Resolve the stylesheet relative to THIS test file (not process.cwd()) so the+// test passes regardless of the directory vitest is launched from. CI runs it+// from desktop-app/ui, where the old cwd-relative 'ui/src/styles.css' resolved+// to desktop-app/ui/ui/src/styles.css and failed with ENOENT.+const composerStyles = readFileSync(resolve(__dirname, '../../../styles.css'), 'utf8')const composerState = {composerImageAttachments: [],diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useActivityController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useActivityController.test.tsxindex e35201294..1ae6c0256 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useActivityController.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useActivityController.test.tsx@@ -1,6 +1,6 @@// @vitest-environment jsdomimport { afterEach, describe, expect, it, vi } from 'vitest'-import { renderHook, waitFor } from '@testing-library/react'+import { cleanup, renderHook, waitFor } from '@testing-library/react'import { useActivityController } from '../useActivityController'const AGENT_A = ['agent-a']@@ -34,6 +34,14 @@ function installChatIndexMock() {describe('useActivityController', () => {afterEach(() => {+ // Unmount the rendered hook so useActivityController's effect cleanup runs+ // (cancelled = true) BEFORE the jsdom environment is torn down. Several tests+ // render the hook without awaiting its async index/message reads; without an+ // unmount those promises resolve post-teardown and setState on a live tree,+ // which React flushes via the scheduler after `window` is gone —+ // "ReferenceError: window is not defined" as an unhandled error that fails+ // the whole run even though every assertion passed.+ cleanup()vi.restoreAllMocks()delete (window as { clerum?: unknown }).clerum})