2024-04-04 22:20:42 +00:00
|
|
|
import { it } from 'vitest'
|
2022-12-07 13:31:38 +00:00
|
|
|
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 = [
|
|
|
|
'All Songs',
|
|
|
|
'Albums',
|
|
|
|
'Artists',
|
|
|
|
'Genres',
|
|
|
|
'Favorites',
|
|
|
|
'Recently Played'
|
|
|
|
]
|
|
|
|
|
|
|
|
const adminItems = [...standardItems, 'Users', 'Upload', 'Settings']
|
|
|
|
|
|
|
|
new class extends UnitTestCase {
|
2024-01-15 22:26:50 +00:00
|
|
|
protected test () {
|
2022-12-07 13:31:38 +00:00
|
|
|
it('shows the standard items', () => {
|
2024-01-15 22:26:50 +00:00
|
|
|
this.be().render(Sidebar)
|
2022-12-07 13:31:38 +00:00
|
|
|
standardItems.forEach(label => screen.getByText(label))
|
|
|
|
})
|
|
|
|
|
|
|
|
it('shows administrative items', () => {
|
2024-01-15 22:26:50 +00:00
|
|
|
this.beAdmin().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 () => {
|
2024-01-04 11:35:36 +00:00
|
|
|
commonStore.state.uses_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
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|