2022-12-07 13:31:38 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
|
|
import { screen } from '@testing-library/vue'
|
|
|
|
import { commonStore } from '@/stores'
|
|
|
|
import { eventBus } from '@/utils'
|
|
|
|
import Sidebar from './Sidebar.vue'
|
|
|
|
|
|
|
|
const standardItems = [
|
|
|
|
'Home',
|
|
|
|
'Current Queue',
|
|
|
|
'All Songs',
|
|
|
|
'Albums',
|
|
|
|
'Artists',
|
|
|
|
'Genres',
|
|
|
|
'Favorites',
|
|
|
|
'Recently Played'
|
|
|
|
]
|
|
|
|
|
|
|
|
const adminItems = [...standardItems, 'Users', 'Upload', 'Settings']
|
|
|
|
|
|
|
|
new class extends UnitTestCase {
|
|
|
|
protected test() {
|
|
|
|
it('shows the standard items', () => {
|
2022-12-07 13:37:08 +00:00
|
|
|
this.actingAs().render(Sidebar)
|
2022-12-07 13:31:38 +00:00
|
|
|
standardItems.forEach(label => screen.getByText(label))
|
|
|
|
})
|
|
|
|
|
|
|
|
it('shows administrative items', () => {
|
2022-12-07 13:37:08 +00:00
|
|
|
this.actingAsAdmin().render(Sidebar)
|
2022-12-07 13:31:38 +00:00
|
|
|
adminItems.forEach(label => screen.getByText(label))
|
|
|
|
})
|
|
|
|
|
|
|
|
it('shows the YouTube sidebar item on demand', async () => {
|
|
|
|
commonStore.state.use_you_tube = true
|
2022-12-07 13:37:08 +00:00
|
|
|
this.render(Sidebar)
|
2022-12-07 13:31:38 +00:00
|
|
|
|
|
|
|
eventBus.emit('PLAY_YOUTUBE_VIDEO', { id: '123', title: 'A Random Video' })
|
|
|
|
await this.tick()
|
|
|
|
|
2022-12-07 13:37:08 +00:00
|
|
|
screen.getByText('A Random Video')
|
2022-12-07 13:31:38 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|