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,39 @@
import { describe, it, expect, beforeEach, vi } from 'vitest'
import { createPinia, setActivePinia } from 'pinia'
import { useAlertStore } from '@/stores/alerts'
describe('alert store notifications', () => {
beforeEach(() => {
setActivePinia(createPinia())
})
it('queuesBannerAlertsForNewCriticalItems', () => {
const store = useAlertStore()
const critical = {
id: 'alert-1',
severity: 'Critical',
status: 'Open',
alertType: 'SofaSepsis',
}
expect(store.applyPollResults([critical])).toEqual([])
expect(store.bannerAlerts).toEqual([])
const next = {
id: 'alert-2',
severity: 'Critical',
status: 'Open',
alertType: 'GcsCritical',
}
const newAlerts = store.applyPollResults([critical, next])
expect(newAlerts.map(alert => alert.id)).toEqual(['alert-2'])
expect(store.bannerAlerts.map(alert => alert.id)).toEqual(['alert-2'])
})
it('dismissesBannerAlert', () => {
const store = useAlertStore()
store.bannerAlerts = [{ id: 'alert-1' }]
store.dismissBannerAlert('alert-1')
expect(store.bannerAlerts).toEqual([])
})
})