import { expect, test } from '@playwright/test' import { mockHermesApi } from './fixtures' test('a CLI timeout does not redirect to the installation guide', async ({ page }) => { await mockHermesApi(page) await page.route(url => url.pathname === '/api/hermes/cli-status', route => route.fulfill({ json: { available: false, reason: 'timeout', bin: '/opt/hermes/bin/hermes' }, })) await page.goto('/') await expect(page.getByPlaceholder('Username')).toBeVisible() await expect(page.getByText('pip install hermes-agent')).toHaveCount(0) }) for (const [reason, title] of [ ['permission_denied', 'Hermes CLI cannot be executed'], ['failed', 'Hermes CLI failed to start'], ['missing', 'Hermes CLI not detected'], ]) { test(`explains ${reason} and retries without waiting for the server cache`, async ({ page }) => { await mockHermesApi(page) let forced = false await page.route(url => url.pathname === '/api/hermes/cli-status', async route => { forced = new URL(route.request().url()).searchParams.get('refresh') === '1' await route.fulfill({ json: { available: forced, reason: forced ? 'ready' : reason, bin: '/opt/hermes/bin/hermes' } }) }) await page.goto('/') await expect(page.getByRole('heading', { name: title, exact: true })).toBeVisible() if (reason !== 'missing') await expect(page.getByText('pip install hermes-agent')).toHaveCount(0) await page.getByRole('button', { name: 'Re-check' }).click() await expect(page.getByPlaceholder('Username')).toBeVisible() expect(forced).toBe(true) }) }