Files
Ettore Di Giacinto 6983477a71 fix(agent-ui): keep chat open for status
Agent Status replaced the chat route and unmounted its EventSource. Any response still in flight could then disappear from the conversation.\n\nOpen status in a separate tab so the chat keeps its live connection until the response completes.\n\nAssisted-by: Codex:gpt-5 [eslint]

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-09-11 21:56:08 +00:00

51 lines
2.2 KiB
JavaScript

import { test, expect } from './coverage-fixtures.js'
// Agents feature page (src/pages/Agents.jsx).
test.describe('Agents page', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/app/agents')
})
test('renders the agents list and empty state', async ({ page }) => {
await expect(page).toHaveURL(/\/app\/agents$/)
await expect(page.getByRole('heading', { name: 'Agents', exact: true })).toBeVisible()
await expect(page.getByText(/No agents configured/i)).toBeVisible()
await expect(page.getByRole('button', { name: 'Create Agent' }).first()).toBeVisible()
})
test('keeps Import Agent visible when agents exist', async ({ page }) => {
await page.route('**/api/agents', route => route.fulfill({
json: { agents: ['existing-agent'], statuses: { 'existing-agent': true } },
}))
await page.route('**/api/agents/existing-agent/observables', route => route.fulfill({
json: { History: [] },
}))
await page.reload()
await expect(page.locator('.header-actions label', { hasText: 'Import' })).toBeVisible()
})
test('Create Agent navigates to the agent creation form', async ({ page }) => {
const create = page.getByRole('button', { name: 'Create Agent' }).last()
await create.scrollIntoViewIfNeeded()
await Promise.all([
page.waitForURL(/\/app\/agents\/new$/),
create.click(),
])
// Wait for AgentCreate.jsx to actually render, not just for the URL to
// change. Ending the test the instant the route matched let the component
// mount race the coverage teardown — its ~400 lines were collected only
// when the render won, swinging total UI coverage ~1pp run-to-run.
await expect(page.getByRole('heading', { name: 'Create Agent' })).toBeVisible()
})
test('opens agent status without leaving an active chat', async ({ page }) => {
await page.goto('/app/agents/demo/chat?user_id=test-user')
const status = page.getByRole('link', { name: 'Status' })
await expect(status).toHaveAttribute('href', '/app/agents/demo/status?user_id=test-user')
await expect(status).toHaveAttribute('target', '_blank')
await expect(page).toHaveURL(/\/app\/agents\/demo\/chat\?user_id=test-user$/)
})
})