Skip to content

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

TypeScript

test(desktop-e2e): read the hostRef of FleetBoard rows whose display name equals it

Alfredo Lopez5cb639706846
diff --git a/desktop-app/test/e2e-playwright/helpers/fleetRowHostRefs.ts b/desktop-app/test/e2e-playwright/helpers/fleetRowHostRefs.ts
new file mode 100644
index 000000000..2747c793d
--- /dev/null
+++ b/desktop-app/test/e2e-playwright/helpers/fleetRowHostRefs.ts
@@ -0,0 +1,24 @@
+/**
+ * Reads the hostRef of every FleetBoard row (`.agents-table-row-clickable`).
+ *
+ * The row's <strong> is the agent's display name (e.g. "chatLLM"), which is
+ * not a hostRef: an RPC token requested for it is refused, and that refusal
+ * fails the status read of every Host in the same request. Every row ends with
+ * a mock description in `.agent-row-description`; FleetBoard renders the
+ * hostRef in an earlier `.agent-row-description` only when it differs from the
+ * display name. So the hostRef is the first description when the row has two,
+ * and the <strong> otherwise.
+ *
+ * Self-contained: Playwright serializes it into the renderer through
+ * `locator.evaluateAll(fleetRowHostRefs)`, so it must not reference anything
+ * outside its own body.
+ */
+export function fleetRowHostRefs(rows: Element[]): string[] {
+ return rows
+ .map(row => {
+ const descriptions = row.querySelectorAll('.agent-row-description')
+ const hostRef = descriptions.length === 2 ? descriptions[0] : row.querySelector('strong')
+ return (hostRef?.textContent ?? '').trim()
+ })
+ .filter(Boolean)
+}
diff --git a/desktop-app/test/e2e-playwright/stateless-wake.test.ts b/desktop-app/test/e2e-playwright/stateless-wake.test.ts
index 1384168ce..c23aa4440 100644
--- a/desktop-app/test/e2e-playwright/stateless-wake.test.ts
+++ b/desktop-app/test/e2e-playwright/stateless-wake.test.ts
@@ -58,6 +58,7 @@
// contract this tree actually exposes.
// ─────────────────────────────────────────────────────────────────────────────
import { expect, loginAs, test } from './fixtures.js'
+import { fleetRowHostRefs } from './helpers/fleetRowHostRefs.js'
import { openAgentsPage } from './navigationHelpers.js'
const HOST_REF =
@@ -168,24 +169,8 @@ function requireSuspendPrecondition(): void {
}
}
-// The row's <strong> is the agent's display name (e.g. "chatLLM"), which is not a
-// hostRef: an RPC token requested for it is refused, and that refusal fails the
-// status read of every Host in the same request. FleetBoard renders the hostRef
-// in `.agent-row-description` whenever it differs from the display name.
async function visibleAgentHostRefs(appPage: import('@playwright/test').Page): Promise<string[]> {
- return appPage
- .locator('.agents-table-row-clickable')
- .evaluateAll(rows =>
- rows
- .map(row =>
- (
- row.querySelector('.agent-row-description')?.textContent ||
- row.querySelector('strong')?.textContent ||
- ''
- ).trim()
- )
- .filter(Boolean)
- )
+ return appPage.locator('.agents-table-row-clickable').evaluateAll(fleetRowHostRefs)
}
async function readHostRuntimeSignal(
diff --git a/desktop-app/ui/src/components/agents/__tests__/FleetBoard.hostRef.test.tsx b/desktop-app/ui/src/components/agents/__tests__/FleetBoard.hostRef.test.tsx
new file mode 100644
index 000000000..8a7f3e538
--- /dev/null
+++ b/desktop-app/ui/src/components/agents/__tests__/FleetBoard.hostRef.test.tsx
@@ -0,0 +1,63 @@
+// @vitest-environment jsdom
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, render } from '@testing-library/react'
+import { fleetRowHostRefs } from '../../../../../test/e2e-playwright/helpers/fleetRowHostRefs'
+import { FleetBoard } from '../FleetBoard'
+
+// The stateless-wake spec reads hostRefs from the rendered FleetBoard rows.
+// Both row shapes are rendered here: one whose display name differs from its
+// hostRef, and one whose display name equals it.
+
+vi.mock('@contexts/NavigationContext', () => ({
+ useNavigationContext: () => ({
+ handleOpenAgentWorkspace: vi.fn(),
+ handleSelectChatAgent: vi.fn(),
+ selectedAgent: null,
+ }),
+}))
+vi.mock('@contexts/AgentActivityContext', () => ({
+ useAgentActivityContext: () => ({ agentLastActiveByAgent: {} }),
+}))
+vi.mock('@contexts/AgentChatActionsContext', () => ({
+ useAgentChatActionsContext: () => ({ handleCreateChat: vi.fn() }),
+}))
+vi.mock('@hooks/domain/useAgentsDataController', () => ({
+ useAgentsDataController: () => ({
+ agentNames: ['chatllm-stateless', 'researcher'],
+ agentDisplayByName: { 'chatllm-stateless': 'chatLLM', researcher: 'researcher' },
+ userAgentNames: ['chatllm-stateless', 'researcher'],
+ teamAgentNames: [],
+ }),
+}))
+vi.mock('@hooks/domain/useTeamsDataController', () => ({
+ useTeamsDataController: () => ({
+ teams: [],
+ currentTeamId: '',
+ teamDirectory: {},
+ ensureHydrated: vi.fn(async () => undefined),
+ }),
+}))
+vi.mock('@hooks/domain/useMcpServersDataController', () => ({
+ useMcpServersDataController: () => ({
+ agentMcpServerCountByAgent: {},
+ agentMcpServersByAgent: {},
+ mcpServerMappingUnavailableMessage: 'unavailable',
+ }),
+}))
+
+describe('fleetRowHostRefs on rendered FleetBoard rows', () => {
+ afterEach(() => {
+ cleanup()
+ })
+
+ it('reads the hostRef of a row whose display name differs and of one whose display name equals it', () => {
+ const { container } = render(<FleetBoard />)
+ const rows = Array.from(container.querySelectorAll('.agents-table-row-clickable'))
+ // Witness: both row shapes rendered; the second has a single description.
+ expect(rows).toHaveLength(2)
+ expect(rows.map(r => r.querySelectorAll('.agent-row-description').length).sort()).toEqual([
+ 1, 2,
+ ])
+ expect(fleetRowHostRefs(rows).sort()).toEqual(['chatllm-stateless', 'researcher'])
+ })
+})