test(frontend): mock getLiveCapability and align rollback timeout

Stub GroupsView live capability API in unit tests and expect the longer
system rollback request timeout; refresh pnpm-lock after dependency resolve.
This commit is contained in:
IanShaw027
2026-08-08 08:48:38 +08:00
parent 6345b048d1
commit 85fb776151
4 changed files with 724 additions and 735 deletions
+705 -733
View File
File diff suppressed because it is too large Load Diff
@@ -41,7 +41,11 @@ describe('admin system rollback API', () => {
const result = await rollback('0.1.146')
expect(post).toHaveBeenCalledWith('/admin/system/rollback', { version: '0.1.146' })
expect(post).toHaveBeenCalledWith(
'/admin/system/rollback',
{ version: '0.1.146' },
{ timeout: 15 * 60 * 1000 }
)
expect(result.need_restart).toBe(true)
})
@@ -50,6 +54,10 @@ describe('admin system rollback API', () => {
await rollback()
expect(post).toHaveBeenCalledWith('/admin/system/rollback', undefined)
expect(post).toHaveBeenCalledWith(
'/admin/system/rollback',
undefined,
{ timeout: 15 * 60 * 1000 }
)
})
})
@@ -10,6 +10,7 @@ const {
getModelsListCandidates,
getUsageSummary,
getCapacitySummary,
getLiveCapability,
listAccounts,
showError,
showSuccess,
@@ -21,6 +22,7 @@ const {
getModelsListCandidates: vi.fn(),
getUsageSummary: vi.fn(),
getCapacitySummary: vi.fn(),
getLiveCapability: vi.fn(),
listAccounts: vi.fn(),
showError: vi.fn(),
showSuccess: vi.fn(),
@@ -51,6 +53,7 @@ vi.mock('@/api/admin', () => ({
getModelsListCandidates,
getUsageSummary,
getCapacitySummary,
getLiveCapability,
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
@@ -244,6 +247,7 @@ describe('admin GroupsView column settings', () => {
getModelsListCandidates.mockResolvedValue([])
getUsageSummary.mockResolvedValue([])
getCapacitySummary.mockResolvedValue([])
getLiveCapability.mockResolvedValue({ supported: false })
listAccounts.mockResolvedValue({ items: [], total: 0, page: 1, page_size: 20, pages: 0 })
isCurrentStep.mockReturnValue(false)
})
@@ -11,6 +11,7 @@ const {
getModelsListCandidates,
getUsageSummary,
getCapacitySummary,
getLiveCapability,
showSuccess,
showError
} = vi.hoisted(() => ({
@@ -19,6 +20,7 @@ const {
getModelsListCandidates: vi.fn(),
getUsageSummary: vi.fn(),
getCapacitySummary: vi.fn(),
getLiveCapability: vi.fn(),
showSuccess: vi.fn(),
showError: vi.fn()
}))
@@ -31,6 +33,7 @@ vi.mock('@/api/admin', () => ({
getModelsListCandidates,
getUsageSummary,
getCapacitySummary,
getLiveCapability,
getAll: vi.fn(),
create: vi.fn(),
update: vi.fn(),
@@ -166,6 +169,7 @@ describe('GroupsView duplicate action', () => {
getModelsListCandidates,
getUsageSummary,
getCapacitySummary,
getLiveCapability,
showSuccess,
showError
]) {
@@ -188,6 +192,7 @@ describe('GroupsView duplicate action', () => {
getModelsListCandidates.mockResolvedValue([])
getUsageSummary.mockResolvedValue([])
getCapacitySummary.mockResolvedValue([])
getLiveCapability.mockResolvedValue({ supported: false })
})
afterEach(() => {