gongxiangp2/components/board/__tests__/SystemPerformanceCard.test.tsx
chenpei e864fc3249 fix: 系统性能面板改回浅色,并纠正内存和队列口径
内存改读应用容器上限,不再把整机 90% 当成素材服务快满了。
转码队列改看素材状态和租约,上传停住的会话单独标出。
2026-08-17 13:35:09 +08:00

41 lines
1.5 KiB
TypeScript

import { render, screen } from '@testing-library/react'
import SystemPerformanceCard from '../SystemPerformanceCard'
describe('SystemPerformanceCard', () => {
test('用容器口径显示内存,并在空闲时不假装还有排队', () => {
render(
<SystemPerformanceCard
loading={false}
error={null}
data={{
cpu: { usage: 2, loadAverage: [2.23, 1.51, 1.33], cores: 36 },
memory: {
used: 155,
total: 6144,
percentage: 3,
usedBytes: 162_533_376,
totalBytes: 6_442_450_944,
source: 'container',
hostUsedBytes: 14_342_000_000,
hostTotalBytes: 15_900_000_000,
hostPercentage: 90,
},
network: { uploadSpeed: 5700, downloadSpeed: 4500 },
uploadQueue: { total: 0, processing: [], waiting: [] },
transcodeQueue: { total: 0, maxConcurrent: 1, processing: [], waiting: [] },
}}
/>,
)
expect(screen.getByText('系统性能')).toBeInTheDocument()
expect(screen.getByText('36 核 · 1/5/15 分钟负载')).toBeInTheDocument()
expect(screen.getByText(/155 MB \/ 6 GB/)).toBeInTheDocument()
expect(screen.getByText(/整台机器大约用了 90%/)).toBeInTheDocument()
expect(screen.queryByText(/14342/)).not.toBeInTheDocument()
expect(screen.getAllByText('空闲')).toHaveLength(2)
expect(screen.getByText('本应用,不是整台机器')).toBeInTheDocument()
expect(screen.queryByText('加载中...')).not.toBeInTheDocument()
})
})