Files
hermes-ui/tests/e2e/profile-selector.spec.ts
T
toor 421ffa0714
Build / build (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s
增加一键重启所有网关按钮
2026-10-21 17:21:11 +08:00

46 lines
2.1 KiB
TypeScript

import { expect, test } from '@playwright/test'
import { authenticate, mockChatSocket, mockHermesApi, TEST_ACCESS_KEY } from './fixtures'
test('profile manager modal fills its width and offers bulk restarts', async ({ page }) => {
await authenticate(page, TEST_ACCESS_KEY, 'research')
const api = await mockHermesApi(page)
await mockChatSocket(page)
await page.goto('/#/hermes/models')
await page.locator('[data-testid="profile-selector-select"]').click()
const modal = page.locator('.profile-manager-modal')
await expect(modal).toBeVisible()
// The profile list must fill the modal body. Arco's .arco-spin is
// inline-block and collapses to its content width otherwise, which leaves a
// wide empty gutter next to the cards.
const widths = await page.evaluate(() => {
const list = document.querySelector('.profile-runtime-list') as HTMLElement
const body = document.querySelector('.profile-manager-modal .arco-modal-body') as HTMLElement
return {
list: Math.round(list.getBoundingClientRect().width),
bodyContent: Math.round(body.getBoundingClientRect().width - 40),
}
})
// The list scrolls, so it may be a scrollbar narrower than the body.
expect(widths.bodyContent - widths.list).toBeLessThanOrEqual(20)
expect(widths.list).toBeGreaterThan(widths.bodyContent * 0.9)
const restartGateways = page.getByRole('button', { name: 'Restart All Gateways' })
const restartProfiles = page.getByRole('button', { name: 'Restart All Profiles' })
await expect(restartGateways).toBeVisible()
await expect(restartProfiles).toBeVisible()
await restartGateways.click()
await restartProfiles.click()
const gatewayCalls = api.requests.filter((request) => request.pathname === '/api/hermes/profiles/gateways/restart-all')
const profileCalls = api.requests.filter((request) => request.pathname === '/api/hermes/profiles/restart-all')
expect(gatewayCalls).toHaveLength(1)
expect(gatewayCalls[0]?.method).toBe('POST')
expect(profileCalls).toHaveLength(1)
expect(profileCalls[0]?.method).toBe('POST')
expect(api.unexpectedRequests).toEqual([])
})