2022-10-13 15:18:47 +00:00
|
|
|
import { ref } from 'vue'
|
2022-11-29 10:18:58 +00:00
|
|
|
import { screen, waitFor } from '@testing-library/vue'
|
2022-05-09 09:59:31 +00:00
|
|
|
import { expect, it } from 'vitest'
|
2022-05-06 15:52:37 +00:00
|
|
|
import factory from '@/__tests__/factory'
|
|
|
|
import { albumStore, preferenceStore } from '@/stores'
|
2022-05-13 17:58:38 +00:00
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
2022-10-13 15:18:47 +00:00
|
|
|
import { CurrentSongKey } from '@/symbols'
|
2022-05-06 15:52:37 +00:00
|
|
|
import AlbumArtOverlay from '@/components/ui/AlbumArtOverlay.vue'
|
2022-09-12 15:33:41 +00:00
|
|
|
import MainContent from './MainContent.vue'
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-13 17:58:38 +00:00
|
|
|
new class extends UnitTestCase {
|
2022-11-06 17:09:06 +00:00
|
|
|
private renderComponent () {
|
2022-10-22 09:27:03 +00:00
|
|
|
return this.render(MainContent, {
|
|
|
|
global: {
|
|
|
|
provide: {
|
2022-11-06 17:09:06 +00:00
|
|
|
[<symbol>CurrentSongKey]: ref(factory<Song>('song'))
|
2022-10-22 09:27:03 +00:00
|
|
|
},
|
|
|
|
stubs: {
|
|
|
|
AlbumArtOverlay,
|
2024-03-18 22:04:01 +00:00
|
|
|
AllSongsScreen: this.stub('all-songs-screen'),
|
|
|
|
AlbumListScreen: this.stub('album-list-screen'),
|
|
|
|
ArtistListScreen: this.stub('artist-list-screen'),
|
|
|
|
PlaylistScreen: this.stub('playlist-screen'),
|
|
|
|
FavoritesScreen: this.stub('favorites-screen'),
|
|
|
|
RecentlyPlayedScreen: this.stub('recently-played-screen'),
|
|
|
|
UploadScreen: this.stub('upload-screen'),
|
|
|
|
SearchExcerptsScreen: this.stub('search-excerpts-screen'),
|
|
|
|
GenreScreen: this.stub('genre-screen'),
|
2022-10-22 09:27:03 +00:00
|
|
|
HomeScreen: this.stub(), // so that home overview requests are not made
|
2022-11-06 17:09:06 +00:00
|
|
|
Visualizer: this.stub('visualizer')
|
|
|
|
}
|
2022-10-22 09:27:03 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
protected test () {
|
|
|
|
it('has a translucent overlay per album', async () => {
|
2022-10-09 10:53:10 +00:00
|
|
|
this.mock(albumStore, 'fetchThumbnail').mockResolvedValue('http://test/foo.jpg')
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
this.renderComponent()
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
await waitFor(() => screen.getByTestId('album-art-overlay'))
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
it('does not have a translucent over if configured not so', async () => {
|
2024-01-23 22:50:50 +00:00
|
|
|
preferenceStore.state.show_album_art_overlay = false
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
this.renderComponent()
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
await waitFor(() => expect(screen.queryByTestId('album-art-overlay')).toBeNull())
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|