systemOverviewPanel.test.ts 1.4 KB

12345678910111213141516171819202122232425
  1. import { flushPromises, mount } from '@vue/test-utils'
  2. import { describe, expect, it, vi } from 'vitest'
  3. import SystemOverviewPanel from '@/components/app/SystemOverviewPanel.vue'
  4. vi.mock('@/api/admin', () => ({ listUsers: vi.fn(async () => []) }))
  5. vi.mock('@/api/push', () => ({ getPushSystemStatus: vi.fn(async () => ({ configured: false })) }))
  6. vi.mock('@/api/pairing', () => ({ pairedDevices: vi.fn(() => new Promise(() => {})) }))
  7. vi.mock('@/api/agentManagement', () => ({ getDuplexVoiceSettings: vi.fn(() => new Promise(() => {})) }))
  8. vi.mock('@/api/systemUpdate', () => ({ systemUpdateStatus: vi.fn(async () => ({
  9. current: { webVersion: '0.2.29', pluginVersion: '1.7.3' }, versionsMatch: false, updateAvailable: false,
  10. })) }))
  11. describe('SystemOverviewPanel offline updates', () => {
  12. it('shows Web status and allows update navigation while upstream panels are stalled', async () => {
  13. const wrapper = mount(SystemOverviewPanel, { props: { upstreamReady: false }, global: { stubs: { AppIcon: true } } })
  14. await flushPromises()
  15. expect(wrapper.text()).toContain('Web 0.2.29 · 可独立升级与回滚')
  16. expect(wrapper.text()).not.toContain('已是最新版本')
  17. expect(wrapper.text()).not.toContain('插件 1.7.3')
  18. const update = wrapper.findAll('button').find(button => button.text().includes('更新与回滚'))!
  19. await update.trigger('click')
  20. expect(wrapper.emitted('navigate')).toEqual([['system-update']])
  21. wrapper.unmount()
  22. })
  23. })