feature: Improve dashboard functionality
This commit is contained in:
@@ -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([])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user