Files
hermes-ui/tests/e2e/cli-detection.spec.ts
toor a54913efd2
Build / build (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s
fix false missing Hermes CLI detection after deployment
2026-10-24 20:59:08 +08:00

34 lines
1.5 KiB
TypeScript

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)
})
}