Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(desktop): close the remaining 35 renderer typecheck entries

Alfredo Lopez25dcb57a57c7
diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
index 77fb57680..cebc7e2bb 100644
--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
@@ -757,9 +757,12 @@ describe('App deep-link orchestration', () => {
expect(sandboxUiPageHarness.props?.shortcutOpenRequestId).toBeGreaterThan(0)
})
const props = sandboxUiPageHarness.props
- if (!props?.shortcutOpenRequestId) throw new Error('Sandbox UI shortcut was not requested')
+ // Bound to its own const: TypeScript discards the narrowing of a property
+ // inside a callback, because the object could be mutated in between.
+ const requestId = props?.shortcutOpenRequestId
+ if (!props || !requestId) throw new Error('Sandbox UI shortcut was not requested')
await act(async () => {
- await props.onShortcutOpenResult?.(props.shortcutOpenRequestId, result)
+ await props.onShortcutOpenResult?.(requestId, result)
await Promise.resolve()
})
}
diff --git a/desktop-app/ui/src/__tests__/desktopShortcutLabels.test.tsx b/desktop-app/ui/src/__tests__/desktopShortcutLabels.test.tsx
index 374684dcf..e89d757c1 100644
--- a/desktop-app/ui/src/__tests__/desktopShortcutLabels.test.tsx
+++ b/desktop-app/ui/src/__tests__/desktopShortcutLabels.test.tsx
@@ -63,6 +63,7 @@ describe('Desktop shortcut labels', () => {
{
alt: false,
control: false,
+ isAutoRepeat: false,
isComposing: false,
key: 'f',
meta: true,
@@ -104,7 +105,7 @@ describe('Desktop shortcut labels', () => {
onNotify={vi.fn()}
onPlayNotificationSoundPreview={vi.fn()}
onSaveChannelNotificationPreferences={vi.fn(async () => undefined)}
- onSaveNotificationSettings={vi.fn(async () => 'default')}
+ onSaveNotificationSettings={vi.fn(async () => 'default' as const)}
onThemeModeChange={vi.fn()}
shortcutsFocusRequestId={1}
themeMode="dark"
diff --git a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
index 2b159ebce..f768ae63e 100644
--- a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
+++ b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
@@ -11,7 +11,10 @@ const notificationMocks = vi.hoisted(() => ({
notifications: [] as AppNotification[],
open: vi.fn(),
remove: vi.fn(),
- refresh: vi.fn(async () => undefined),
+ // Mirrors `handleRefreshPendingApprovals` in NotificationsContext, which
+ // resolves `void` — `async () => undefined` would pin it to `Promise<undefined>`
+ // and reject a `Promise<void>` handed to `mockReturnValueOnce`.
+ refresh: vi.fn(async (_options?: { silent?: boolean }): Promise<void> => undefined),
}))
// Rename propagation tests swap this catalog in; default null keeps the
diff --git a/desktop-app/ui/src/components/CommandPalette/CommandPalette.test.tsx b/desktop-app/ui/src/components/CommandPalette/CommandPalette.test.tsx
index e33baa962..babe22df7 100644
--- a/desktop-app/ui/src/components/CommandPalette/CommandPalette.test.tsx
+++ b/desktop-app/ui/src/components/CommandPalette/CommandPalette.test.tsx
@@ -74,7 +74,7 @@ describe('CommandPalette', () => {
const previous = document.createElement('button')
document.body.append(previous)
previous.focus()
- let close = () => undefined
+ let close: () => void = () => undefined
const rendered = render(
<CommandPalette
platform="darwin"
diff --git a/desktop-app/ui/src/components/GfsResourceMenu/GfsResourceMenu.test.tsx b/desktop-app/ui/src/components/GfsResourceMenu/GfsResourceMenu.test.tsx
index ddf0cafc0..5a7d8be1d 100644
--- a/desktop-app/ui/src/components/GfsResourceMenu/GfsResourceMenu.test.tsx
+++ b/desktop-app/ui/src/components/GfsResourceMenu/GfsResourceMenu.test.tsx
@@ -91,7 +91,9 @@ describe('GfsResourceMenu', () => {
vi.spyOn(window, 'innerWidth', 'get').mockReturnValue(918)
vi.spyOn(window, 'innerHeight', 'get').mockReturnValue(700)
- vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function () {
+ vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (
+ this: HTMLElement
+ ) {
if (this.classList.contains('da-gfs-drive')) {
const left = sidebarExpanded ? 304 : 74
return rect(left, 0, 918 - left, 700)
diff --git a/desktop-app/ui/src/gfs/__tests__/moveDialog.test.tsx b/desktop-app/ui/src/gfs/__tests__/moveDialog.test.tsx
index 05885915f..34cc89986 100644
--- a/desktop-app/ui/src/gfs/__tests__/moveDialog.test.tsx
+++ b/desktop-app/ui/src/gfs/__tests__/moveDialog.test.tsx
@@ -42,7 +42,10 @@ const parentCrumb: GfsCrumb = {
}
function renderDialog(
- producers: { listAccessible?: () => Promise<unknown>; listChildren?: () => Promise<unknown> },
+ producers: {
+ listAccessible?: () => Promise<unknown>
+ listChildren?: (resourceId: string) => Promise<unknown>
+ },
props: Partial<Parameters<typeof GfsMoveDialog>[0]> = {}
) {
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
diff --git a/desktop-app/ui/src/hooks/__tests__/useWindowFocusBridge.test.tsx b/desktop-app/ui/src/hooks/__tests__/useWindowFocusBridge.test.tsx
index b8ed68872..8c7ab6813 100644
--- a/desktop-app/ui/src/hooks/__tests__/useWindowFocusBridge.test.tsx
+++ b/desktop-app/ui/src/hooks/__tests__/useWindowFocusBridge.test.tsx
@@ -24,7 +24,7 @@ describe('useWindowFocusBridge', () => {
queryFn: fetcher,
refetchOnWindowFocus: 'always',
})
- return <div data-testid="fetches">{query.dataFetchStatus}</div>
+ return <div data-testid="fetches">{query.fetchStatus}</div>
}
const client = new QueryClient({ defaultOptions: desktopQueryDefaults })
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/mockClerum.ts b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/mockClerum.ts
index 2bd0f3e49..125bb9392 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/mockClerum.ts
+++ b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/mockClerum.ts
@@ -1,4 +1,4 @@
-import { vi } from 'vitest'
+import { type Mock, vi } from 'vitest'
/**
* D.0 characterization fixture — installs a fake `window.clerum` bridge.
@@ -11,7 +11,11 @@ import { vi } from 'vitest'
*/
type Handler = (event: unknown) => void
-type Fn = ReturnType<typeof vi.fn>
+// `ReturnType<typeof vi.fn>` resolves to `Mock<Procedure | Constructable>`, and
+// that union does not satisfy `(...args: any) => any`. Callers here write
+// `Awaited<ReturnType<typeof clerum.rpc.loadSessionMessages>>` to name a bridge
+// result type, which needs a member that is a call signature and nothing else.
+type Fn = Mock<(...args: any[]) => any>
interface ChatMock {
list: Fn
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
index 0ce218599..989612c7f 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
@@ -47,11 +47,15 @@ function authValue(me: AuthContextValue['me']): AuthContextValue {
password: '',
desktopSetupAuthorizationToken: '',
desktopSetupStarted: false,
+ desktopEnvironmentSetupComplete: true,
runtimeConfigSetupName: '',
runtimeConfigSetupExternalRestApiBaseUrl: '',
runtimeConfigSetupRpcProxyBaseUrl: '',
authTransitioning: false,
runtimeConfigState: null,
+ desktopReleaseStatus: null,
+ pendingDesktopEnvironmentSetup: null,
+ backendSwitchHint: null,
runtimeConfigMissing: false,
showRuntimeConfigSelector: false,
dependencyHealth: null,
@@ -60,17 +64,24 @@ function authValue(me: AuthContextValue['me']): AuthContextValue {
setEmail: vi.fn(),
setPassword: vi.fn(),
setDesktopSetupAuthorizationToken: vi.fn(),
+ setDesktopEnvironmentSetupComplete: vi.fn(),
+ setPendingDesktopEnvironmentSetup: vi.fn(),
setRuntimeConfigSetupName: vi.fn(),
setRuntimeConfigSetupExternalRestApiBaseUrl: vi.fn(),
setRuntimeConfigSetupRpcProxyBaseUrl: vi.fn(),
setStatus: vi.fn(),
loadSession: vi.fn(),
handlePasswordLogin: vi.fn(),
+ handleSwitchLoginBackend: vi.fn(),
handleStartDesktopSetup: vi.fn(),
handleCompleteDesktopSetup: vi.fn(),
handleSaveRuntimeConfig: vi.fn(),
handleDeleteRuntimeConfig: vi.fn(),
handleSelectRuntimeConfig: vi.fn(),
+ handleClearRuntimeConfigSelection: vi.fn(),
+ handleCancelDesktopEnvironmentSetup: vi.fn(),
+ handleConfirmDesktopEnvironmentSetup: vi.fn(),
+ handleOpenDesktopRelease: vi.fn(),
handleLogout: vi.fn(),
}
}
diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
index 8981c9566..083268fbb 100644
--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
@@ -254,7 +254,9 @@ describe('FilesPage', () => {
renderFilesPage()
- const row = screen.getByRole('button', { name: 'Open report.txt' }).closest('.da-grid__row')
+ const row = screen
+ .getByRole('button', { name: 'Open report.txt' })
+ .closest<HTMLElement>('.da-grid__row')
expect(row).not.toBeNull()
expect(within(row!).getByRole('button', { name: 'Share report.txt' })).toBeTruthy()
expect(within(row!).getByRole('button', { name: 'Download report.txt' })).toBeTruthy()
@@ -338,11 +340,15 @@ describe('FilesPage', () => {
renderFilesPage()
- const folderRow = screen.getByRole('button', { name: 'Open Assets' }).closest('.da-grid__row')
- const fileRow = screen.getByRole('button', { name: 'Open report.txt' }).closest('.da-grid__row')
+ const folderRow = screen
+ .getByRole('button', { name: 'Open Assets' })
+ .closest<HTMLElement>('.da-grid__row')
+ const fileRow = screen
+ .getByRole('button', { name: 'Open report.txt' })
+ .closest<HTMLElement>('.da-grid__row')
const readonlyRow = screen
.getByRole('button', { name: 'Open readonly.txt' })
- .closest('.da-grid__row')
+ .closest<HTMLElement>('.da-grid__row')
expect(folderRow).not.toBeNull()
expect(fileRow).not.toBeNull()
expect(readonlyRow).not.toBeNull()
@@ -778,7 +784,9 @@ describe('FilesPage', () => {
})
it('adds numbered suffixes for duplicate names in one dropped batch', async () => {
- const createFileFromPath = vi.fn(async () => undefined)
+ const createFileFromPath = vi.fn(
+ async (_parentResourceId: string, _name: string, _filePath: string) => undefined
+ )
const pushToast = vi.fn()
hookMock.useGfsBrowserController.mockReturnValue({
...baseController(),
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx
index f772995b9..500f509df 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.focus.test.tsx
@@ -134,7 +134,7 @@ describe('SandboxUiPage contextual-search focus ownership', () => {
render(
<SandboxUiPage
localSearchRequestId={1}
- shortcutApp={{ appRef: apps[0]!.appRef, defaultPath: '/', title: 'Sales CRM' }}
+ shortcutApp={{ appRef: apps[0]!.appRef, defaultPath: '/', label: 'Sales CRM' }}
shortcutOpenRequestId={1}
/>
)
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
index eacfed342..27928ea1e 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
@@ -23,19 +23,18 @@ const sandboxUi = {
findInPage: vi.fn(),
stopFindInPage: vi.fn(),
focusActive: vi.fn(),
- onFindResult: vi.fn(() => vi.fn()),
+ onFindResult: vi.fn((_callback: (result: FindResultPayload) => void) => vi.fn()),
onClosed: vi.fn(() => vi.fn()),
onRefreshError: vi.fn(() => vi.fn()),
}
-let emitFindResult:
- | ((result: {
- requestId: number
- clientRequestId: number
- activeMatchOrdinal: number
- matches: number
- finalUpdate: boolean
- }) => void)
- | null = null
+type FindResultPayload = {
+ requestId: number
+ clientRequestId: number
+ activeMatchOrdinal: number
+ matches: number
+ finalUpdate: boolean
+}
+let emitFindResult: ((result: FindResultPayload) => void) | null = null
function installClerumApi(): void {
;(window as unknown as { clerum: unknown }).clerum = { sandboxUi }
diff --git a/desktop-app/ui/src/pages/__tests__/SettingsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SettingsPage.test.tsx
index 138d6011e..324e6af00 100644
--- a/desktop-app/ui/src/pages/__tests__/SettingsPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SettingsPage.test.tsx
@@ -18,7 +18,15 @@ const makeAuthValue = (overrides: Partial<AuthContextValue> = {}): AuthContextVa
statusText: 'Ready.',
statusTone: 'info',
isAuthenticated: true,
- me: { email: '[email protected]', name: 'User' },
+ me: {
+ id: 'user-1',
+ email: '[email protected]',
+ name: 'User',
+ picture: null,
+ teamId: null,
+ teamName: null,
+ role: null,
+ },
password: '',
desktopSetupAuthorizationToken: '',
@@ -39,6 +47,7 @@ const makeAuthValue = (overrides: Partial<AuthContextValue> = {}): AuthContextVa
},
desktopReleaseStatus: null,
pendingDesktopEnvironmentSetup: null,
+ backendSwitchHint: null,
runtimeConfigMissing: true,
showRuntimeConfigSelector: true,
dependencyHealth: null,
@@ -55,6 +64,7 @@ const makeAuthValue = (overrides: Partial<AuthContextValue> = {}): AuthContextVa
setStatus: vi.fn(),
loadSession: vi.fn(),
handlePasswordLogin: vi.fn(),
+ handleSwitchLoginBackend: vi.fn(),
handleStartDesktopSetup: vi.fn(),
handleCompleteDesktopSetup: vi.fn(),
handleSaveRuntimeConfig: vi.fn(),
@@ -80,7 +90,7 @@ const defaultSettingsProps: SettingsPageProps = {
onThemeModeChange: vi.fn(),
onNotificationSoundVolumeChange: vi.fn(),
onPlayNotificationSoundPreview: vi.fn(),
- onSaveNotificationSettings: vi.fn(async () => 'default'),
+ onSaveNotificationSettings: vi.fn(async () => 'default' as const),
channelNotificationPreferences: {
preferredMedium: null,
channelFallbackEnabled: false,
@@ -175,9 +185,7 @@ describe('SettingsPage', () => {
expect(screen.getByText('http://127.0.0.1:8091')).toBeTruthy()
expect(screen.getByText('http://127.0.0.1:8094')).toBeTruthy()
- const auth = (window.clerum as { auth: { getDesktopReleaseStatus: ReturnType<typeof vi.fn> } })
- .auth
- expect(auth.getDesktopReleaseStatus).toHaveBeenCalledTimes(1)
+ expect(vi.mocked(window.clerum.auth.getDesktopReleaseStatus)).toHaveBeenCalledTimes(1)
})
it('renders the read-only Shortcuts tab from the authoritative registry', async () => {