增加一键重启所有网关按钮
This commit is contained in:
@@ -250,6 +250,32 @@ export async function mockHermesApi(page: Page, options: MockHermesApiOptions =
|
||||
return
|
||||
}
|
||||
|
||||
if (pathname === '/api/hermes/profiles/gateways/restart-all') {
|
||||
if (request.method() !== 'POST') {
|
||||
await route.fulfill(jsonResponse({ error: 'Method not allowed' }, 405))
|
||||
return
|
||||
}
|
||||
await route.fulfill(jsonResponse({
|
||||
success: true,
|
||||
restarted: ['default', 'research'],
|
||||
failed: [],
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
if (pathname === '/api/hermes/profiles/restart-all') {
|
||||
if (request.method() !== 'POST') {
|
||||
await route.fulfill(jsonResponse({ error: 'Method not allowed' }, 405))
|
||||
return
|
||||
}
|
||||
await route.fulfill(jsonResponse({
|
||||
success: true,
|
||||
restarted: ['default', 'research'],
|
||||
failed: [],
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
if (pathname === '/api/hermes/profiles/active') {
|
||||
if (request.method() !== 'PUT') {
|
||||
await route.fulfill(jsonResponse({ error: 'Method not allowed' }, 405))
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
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([])
|
||||
})
|
||||
Reference in New Issue
Block a user