feat(self-operated): add charts and continuous collection status
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
vi.mock('vue-echarts', () => ({ default: { name: 'VChart', props: ['option'], template: '<div />' } }))
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import CollectionAccountMonitor from './CollectionAccountMonitor.vue'
|
||||
import CollectionTaskProgress from './CollectionTaskProgress.vue'
|
||||
import type { Overview, Task, WarehouseOverview } from '../types'
|
||||
@@ -12,6 +13,27 @@ function overview(account: Task | null = source): Overview {
|
||||
}
|
||||
const options = { global: { stubs: { 'el-button': true } } }
|
||||
describe('single account collection monitor', () => {
|
||||
it('shows server schedules once per family and time, excluding disabled scopes', async () => {
|
||||
const data = overview()
|
||||
data.warehouses.forEach(row => { row.executionEnabled = true; row.nextScheduledAt = '2026-10-13T16:05:00Z' })
|
||||
const w = mount(CollectionAccountMonitor, { ...options, props: { overview: data } })
|
||||
expect(w.find('.account-schedules').text()).toContain('US01 / US02')
|
||||
expect(w.find('.account-schedules').text()).toContain('2026/10/14 00:05:00')
|
||||
expect(w.find('.account-schedules').text()).toContain('计划时间不代表当前任务完成时间')
|
||||
await w.setProps({ stale: true })
|
||||
expect(w.find('.account-schedules').text()).toContain('上次自动采集计划')
|
||||
await w.setProps({ overview: { ...data, warehouses: data.warehouses.map(row => ({ ...row, executionEnabled: false })) } })
|
||||
expect(w.find('.account-schedules').exists()).toBe(false)
|
||||
w.unmount()
|
||||
})
|
||||
it('keeps the account snapshot when warehouse references contain older unknown counts', () => {
|
||||
const data = overview()
|
||||
data.warehouses[1]!.sharedUpstream = { ...source, progress: { ...source.progress!, phase: 'DIRECTORY', totalKnown: false, total: null, completed: 0 } }
|
||||
const w = mount(CollectionAccountMonitor, { ...options, props: { overview: data } })
|
||||
expect(w.findComponent(CollectionTaskProgress).props('task')).toEqual(source)
|
||||
expect(w.text()).toContain('12.1%')
|
||||
w.unmount()
|
||||
})
|
||||
it('does not claim idle or an empty queue when the first status read fails', () => {
|
||||
const w = mount(CollectionAccountMonitor, { ...options, props: { overview: null, stale: true } })
|
||||
expect(w.text()).toContain('暂未取得账号状态')
|
||||
|
||||
Reference in New Issue
Block a user