feature: Improve dashboard functionality

This commit is contained in:
voltsrage
2026-06-23 20:19:32 +08:00
parent dd0fd88731
commit 79b6d9d85e
60 changed files with 2857 additions and 164 deletions
@@ -0,0 +1,54 @@
import { describe, it, expect, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
import DepartmentOverviewView from '@/views/DepartmentOverviewView.vue'
const { mockPush } = vi.hoisted(() => ({
mockPush: vi.fn(),
}))
vi.mock('vue-router', () => ({
useRouter: () => ({ push: mockPush }),
}))
vi.mock('@/composables/usePolling', () => ({
usePolling: (fn) => {
fn()
},
}))
vi.mock('@/api/encounters', () => ({
fetchAllActiveEncounters: vi.fn(() => Promise.resolve([
{
department: 'ICU',
news2Score: 8,
openAlertCount: 2,
sepsisActive: true,
sepsisBundleStatus: 'IN_PROGRESS',
},
{
department: 'GENERAL_MEDICINE',
news2Score: 3,
openAlertCount: 0,
sepsisActive: false,
},
])),
}))
vi.mock('@/api/analytics', () => ({
fetchAlertSummary: vi.fn(() => Promise.resolve({
summary: [{ department: 'ICU', total: 5 }],
})),
}))
describe('DepartmentOverviewView', () => {
it('rendersDepartmentCardsAndTotals', async () => {
setActivePinia(createPinia())
const wrapper = mount(DepartmentOverviewView)
await vi.waitFor(() => expect(wrapper.text()).toContain('1 active patient'))
expect(wrapper.text()).toContain('Department Overview')
expect(wrapper.text()).toContain('Critical (NEWS2 ≥ 7)')
expect(wrapper.text()).toContain('Alert volume')
})
})