Skip to content

Commit

Permalink
tests(front): cover NotificationsPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
rezib committed Nov 15, 2024
1 parent cff14ea commit 7562336
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions frontend/tests/components/NotificationsPanel.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { describe, test, beforeEach, expect, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { useRuntimeStore } from '@/stores/runtime'
import { init_plugins } from '../views/common'
import NotificationsPanel from '@/components/notifications/NotificationsPanel.vue'
import Notification from '@/components/notifications/Notification.vue'
import ChartResourcesHistogram from '@/components/dashboard/ChartResourcesHistogram.vue'
import { nextTick } from 'vue'

describe('DashboardCharts.vue', () => {
beforeEach(() => {
init_plugins()
const cluster = {
name: 'foo',
permissions: { roles: ['admin'], actions: ['view-nodes', 'view-jobs'] },
infrastructure: 'foo',
metrics: true
}
const runtimeStore = useRuntimeStore()
runtimeStore.availableClusters = [cluster]
runtimeStore.currentCluster = cluster
})
test('should not display notification by default', () => {
const wrapper = mount(NotificationsPanel)
// check main div is fixed
expect(wrapper.find('div').classes('fixed')).toBeTruthy()
// empty by default
expect(wrapper.findComponent(Notification).exists()).toBe(false)
})
test('should display reported info/error notifications', async () => {
const runtimeStore = useRuntimeStore()
runtimeStore.reportInfo('test info')
runtimeStore.reportError('test error')
const wrapper = mount(NotificationsPanel)
// check presence of 2 notifications
expect(wrapper.findAllComponents(Notification).length).toBe(2)
})
})

0 comments on commit 7562336

Please sign in to comment.