diff --git a/resources/assets/js/__tests__/UnitTestCase.ts b/resources/assets/js/__tests__/UnitTestCase.ts index 31febf10..33bb85fa 100644 --- a/resources/assets/js/__tests__/UnitTestCase.ts +++ b/resources/assets/js/__tests__/UnitTestCase.ts @@ -71,12 +71,13 @@ export default abstract class UnitTestCase { } protected be (user?: User) { - userStore.state.current = user || factory('user') + userStore.state.current = user || factory('user') return this } protected beAdmin () { - return this.be(factory.states('admin')('user')) + factory.states('admin')('user') + return this.be(factory.states('admin')('user')) } protected mock>> (obj: T, methodName: M, implementation?: any) { diff --git a/resources/assets/js/__tests__/factory/albumInfoFactory.ts b/resources/assets/js/__tests__/factory/albumInfoFactory.ts index 85745cbb..1f4c9d74 100644 --- a/resources/assets/js/__tests__/factory/albumInfoFactory.ts +++ b/resources/assets/js/__tests__/factory/albumInfoFactory.ts @@ -7,6 +7,6 @@ export default (faker: Faker): AlbumInfo => ({ summary: faker.lorem.sentence(), full: faker.lorem.sentences(4) }, - tracks: factory('album-track', 8), + tracks: factory('album-track', 8), url: faker.internet.url() }) diff --git a/resources/assets/js/__tests__/factory/episodeFactory.ts b/resources/assets/js/__tests__/factory/episodeFactory.ts new file mode 100644 index 00000000..0a29a5d8 --- /dev/null +++ b/resources/assets/js/__tests__/factory/episodeFactory.ts @@ -0,0 +1,20 @@ +import { Faker } from '@faker-js/faker' + +export default (faker: Faker): Episode => { + return { + type: 'episodes', + id: faker.datatype.uuid(), + title: faker.lorem.sentence(), + length: faker.datatype.number(), + created_at: faker.date.past().toISOString(), + playback_state: 'Stopped', + liked: false, + play_count: 0, + episode_link: faker.internet.url(), + episode_description: faker.lorem.paragraph(), + episode_image: faker.image.imageUrl(), + podcast_id: faker.datatype.uuid(), + podcast_title: faker.lorem.sentence(), + podcast_author: faker.name.findName() + } +} diff --git a/resources/assets/js/__tests__/factory/index.ts b/resources/assets/js/__tests__/factory/index.ts index 69aba2a6..ca71f790 100644 --- a/resources/assets/js/__tests__/factory/index.ts +++ b/resources/assets/js/__tests__/factory/index.ts @@ -1,4 +1,4 @@ -import factory from 'factoria' +import factoria, { Factoria } from 'factoria' import artistFactory, { states as artistStates } from '@/__tests__/factory/artistFactory' import songFactory, { states as songStates } from '@/__tests__/factory/songFactory' import albumFactory, { states as albumStates } from '@/__tests__/factory/albumFactory' @@ -14,20 +14,91 @@ import artistInfoFactory from '@/__tests__/factory/artistInfoFactory' import youTubeVideoFactory from '@/__tests__/factory/youTubeVideoFactory' import genreFactory from '@/__tests__/factory/genreFactory' import playlistCollaboratorFactory from '@/__tests__/factory/playlistCollaboratorFactory' +import episodeFactory from '@/__tests__/factory/episodeFactory' +import podcastFactory from '@/__tests__/factory/podcastFactory' +import { Faker } from '@faker-js/faker' -export default factory - .define('artist', faker => artistFactory(faker), artistStates) - .define('artist-info', faker => artistInfoFactory(faker)) - .define('album', faker => albumFactory(faker), albumStates) - .define('album-track', faker => albumTrackFactory(faker)) - .define('album-info', faker => albumInfoFactory(faker)) - .define('song', () => songFactory(), songStates) - .define('interaction', faker => interactionFactory(faker)) - .define('genre', faker => genreFactory(faker)) - .define('video', faker => youTubeVideoFactory(faker)) - .define('smart-playlist-rule', faker => smartPlaylistRuleFactory(faker)) - .define('smart-playlist-rule-group', faker => smartPlaylistRuleGroupFactory(faker)) - .define('playlist', faker => playlistFactory(faker), playlistStates) - .define('playlist-folder', faker => playlistFolderFactory(faker)) - .define('user', faker => userFactory(faker), userStates) - .define('playlist-collaborator', faker => playlistCollaboratorFactory(faker)) +type ModelToTypeMap = { + artist: Artist + 'artist-info': ArtistInfo + album: Album + 'album-track': AlbumTrack + 'album-info': AlbumInfo + song: Song + interaction: Interaction + genre: Genre + video: YouTubeVideo + 'smart-playlist-rule': SmartPlaylistRule + 'smart-playlist-rule-group': SmartPlaylistRuleGroup + playlist: Playlist + 'playlist-folder': PlaylistFolder + user: User + 'playlist-collaborator': PlaylistCollaborator + episode: Episode + podcast: Podcast +} + +type Model = keyof ModelToTypeMap +type Overrides = Factoria.Overrides + +const define = ( + model: M, + handle: (faker: Faker) => Overrides, + states?: Record +) => factoria.define(model, handle, states) + +function factory ( + model: M, + overrides?: Overrides +): ModelToTypeMap[M] + +function factory ( + model: M, + count: 1, + overrides?: Overrides +): ModelToTypeMap[M] + +function factory ( + model: M, + count: number, + overrides?: Overrides +): ModelToTypeMap[M][] + +function factory ( + model: M, + count: number|Overrides = 1, + overrides?: Overrides +) { + return typeof count === 'number' + ? count === 1 ? factoria(model, overrides) : factoria(model, count, overrides) + : factoria(model, count) +} + +const states = (...states: string[]): typeof factory => { + factoria.states(...states) + return factory +} + +factory.states = states + +export default factory as typeof factory & { + states: typeof states +} + +define('artist', artistFactory, artistStates) +define('artist-info', artistInfoFactory) +define('album', albumFactory, albumStates) +define('album-track', albumTrackFactory) +define('album-info', albumInfoFactory) +define('song', songFactory, songStates) +define('interaction', interactionFactory) +define('genre', genreFactory) +define('video', youTubeVideoFactory) +define('smart-playlist-rule', smartPlaylistRuleFactory) +define('smart-playlist-rule-group', smartPlaylistRuleGroupFactory) +define('playlist', playlistFactory, playlistStates) +define('playlist-folder', playlistFolderFactory) +define('user', userFactory, userStates) +define('playlist-collaborator', playlistCollaboratorFactory) +define('episode', episodeFactory) +define('podcast', podcastFactory) diff --git a/resources/assets/js/__tests__/factory/playlistFactory.ts b/resources/assets/js/__tests__/factory/playlistFactory.ts index 1c8376f8..073db751 100644 --- a/resources/assets/js/__tests__/factory/playlistFactory.ts +++ b/resources/assets/js/__tests__/factory/playlistFactory.ts @@ -18,7 +18,7 @@ export const states: Record Omit, 't smart: _ => ({ is_smart: true, rules: [ - factory('smart-playlist-rule-group') + factory('smart-playlist-rule-group') ] }), orphan: _ => ({ diff --git a/resources/assets/js/__tests__/factory/podcastFactory.ts b/resources/assets/js/__tests__/factory/podcastFactory.ts new file mode 100644 index 00000000..eb1f3ec1 --- /dev/null +++ b/resources/assets/js/__tests__/factory/podcastFactory.ts @@ -0,0 +1,19 @@ +import { Faker } from '@faker-js/faker' + +export default (faker: Faker): Podcast => { + return { + type: 'podcasts', + id: faker.datatype.uuid(), + title: faker.lorem.sentence(), + url: faker.internet.url(), + link: faker.internet.url(), + image: faker.image.imageUrl(), + description: faker.lorem.paragraph(), + author: faker.name.findName(), + subscribed_at: faker.date.past().toISOString(), + state: { + current_episode: null, + progresses: {} + } + } +} diff --git a/resources/assets/js/__tests__/factory/smartPlaylistRuleGroupFactory.ts b/resources/assets/js/__tests__/factory/smartPlaylistRuleGroupFactory.ts index e26717bc..4a47b6b8 100644 --- a/resources/assets/js/__tests__/factory/smartPlaylistRuleGroupFactory.ts +++ b/resources/assets/js/__tests__/factory/smartPlaylistRuleGroupFactory.ts @@ -3,5 +3,5 @@ import factory from 'factoria' export default (faker: Faker): SmartPlaylistRuleGroup => ({ id: faker.datatype.uuid(), - rules: factory('smart-playlist-rule', 3) + rules: factory('smart-playlist-rule', 3) }) diff --git a/resources/assets/js/components/album/AlbumCard.spec.ts b/resources/assets/js/components/album/AlbumCard.spec.ts index 0683b618..ce81a2ea 100644 --- a/resources/assets/js/components/album/AlbumCard.spec.ts +++ b/resources/assets/js/components/album/AlbumCard.spec.ts @@ -30,7 +30,7 @@ new class extends UnitTestCase { }) it('shuffles', async () => { - const songs = factory('song', 10) + const songs = factory('song', 10) const fetchMock = this.mock(songStore, 'fetchForAlbum').mockResolvedValue(songs) const shuffleMock = this.mock(playbackService, 'queueAndPlay').mockResolvedValue(void 0) this.renderComponent() @@ -52,7 +52,7 @@ new class extends UnitTestCase { } private renderComponent () { - album = factory('album', { + album = factory('album', { id: 42, name: 'IV', artist_id: 17, diff --git a/resources/assets/js/components/album/AlbumContextMenu.spec.ts b/resources/assets/js/components/album/AlbumContextMenu.spec.ts index 66d24cc3..4b5d9f9e 100644 --- a/resources/assets/js/components/album/AlbumContextMenu.spec.ts +++ b/resources/assets/js/components/album/AlbumContextMenu.spec.ts @@ -15,7 +15,7 @@ new class extends UnitTestCase { it('renders', async () => expect((await this.renderComponent()).html()).toMatchSnapshot()) it('plays all', async () => { - const songs = factory('song', 10) + const songs = factory('song', 10) const fetchMock = this.mock(songStore, 'fetchForAlbum').mockResolvedValue(songs) const playMock = this.mock(playbackService, 'queueAndPlay') @@ -28,7 +28,7 @@ new class extends UnitTestCase { }) it('shuffles all', async () => { - const songs = factory('song', 10) + const songs = factory('song', 10) const fetchMock = this.mock(songStore, 'fetchForAlbum').mockResolvedValue(songs) const playMock = this.mock(playbackService, 'queueAndPlay') @@ -66,7 +66,7 @@ new class extends UnitTestCase { }) it('does not have an option to download or go to Unknown Album and Artist', async () => { - await this.renderComponent(factory.states('unknown')('album')) + await this.renderComponent(factory.states('unknown')('album')) expect(screen.queryByText('Go to Album')).toBeNull() expect(screen.queryByText('Go to Artist')).toBeNull() @@ -84,7 +84,7 @@ new class extends UnitTestCase { } private async renderComponent (_album?: Album) { - album = _album || factory('album', { + album = _album || factory('album', { name: 'IV' }) diff --git a/resources/assets/js/components/album/AlbumInfo.spec.ts b/resources/assets/js/components/album/AlbumInfo.spec.ts index de773bd2..914e2d30 100644 --- a/resources/assets/js/components/album/AlbumInfo.spec.ts +++ b/resources/assets/js/components/album/AlbumInfo.spec.ts @@ -29,10 +29,10 @@ new class extends UnitTestCase { commonStore.state.uses_last_fm = true if (info === undefined) { - info = factory('album-info') + info = factory('album-info') } - album = factory('album', { name: 'IV' }) + album = factory('album', { name: 'IV' }) const fetchMock = this.mock(mediaInfoService, 'fetchForAlbum').mockResolvedValue(info) const rendered = this.render(AlbumInfoComponent, { diff --git a/resources/assets/js/components/album/AlbumTrackList.spec.ts b/resources/assets/js/components/album/AlbumTrackList.spec.ts index c391d38a..db893abf 100644 --- a/resources/assets/js/components/album/AlbumTrackList.spec.ts +++ b/resources/assets/js/components/album/AlbumTrackList.spec.ts @@ -8,13 +8,13 @@ import { songStore } from '@/stores' new class extends UnitTestCase { protected test () { it('displays the tracks', async () => { - const album = factory('album') - const fetchMock = this.mock(songStore, 'fetchForAlbum').mockResolvedValue(factory('song', 5)) + const album = factory('album') + const fetchMock = this.mock(songStore, 'fetchForAlbum').mockResolvedValue(factory('song', 5)) this.render(AlbumTrackList, { props: { album, - tracks: factory('album-track', 3) + tracks: factory('album-track', 3) } }) diff --git a/resources/assets/js/components/album/AlbumTrackListItem.spec.ts b/resources/assets/js/components/album/AlbumTrackListItem.spec.ts index 82d7e832..108631ca 100644 --- a/resources/assets/js/components/album/AlbumTrackListItem.spec.ts +++ b/resources/assets/js/components/album/AlbumTrackListItem.spec.ts @@ -13,7 +13,7 @@ new class extends UnitTestCase { it('renders', () => expect(this.renderComponent().html()).toMatchSnapshot()) it('plays', async () => { - const matchedSong = factory('song') + const matchedSong = factory('song') const queueMock = this.mock(queueStore, 'queueIfNotQueued') const playMock = this.mock(playbackService, 'play') @@ -27,10 +27,10 @@ new class extends UnitTestCase { } private renderComponent (matchedSong?: Song) { - const songsToMatchAgainst = factory('song', 10) - const album = factory('album') + const songsToMatchAgainst = factory('song', 10) + const album = factory('album') - const track = factory('album-track', { + const track = factory('album-track', { title: 'Fahrstuhl to Heaven', length: 280 }) diff --git a/resources/assets/js/components/artist/ArtistCard.spec.ts b/resources/assets/js/components/artist/ArtistCard.spec.ts index fd064654..555d2a98 100644 --- a/resources/assets/js/components/artist/ArtistCard.spec.ts +++ b/resources/assets/js/components/artist/ArtistCard.spec.ts @@ -12,7 +12,7 @@ let artist: Artist new class extends UnitTestCase { protected beforeEach () { super.beforeEach(() => { - artist = factory('artist', { + artist = factory('artist', { id: 42, name: 'Led Zeppelin' }) @@ -38,7 +38,7 @@ new class extends UnitTestCase { }) it('shuffles', async () => { - const songs = factory('song', 16) + const songs = factory('song', 16) const fetchMock = this.mock(songStore, 'fetchForArtist').mockResolvedValue(songs) const playMock = this.mock(playbackService, 'queueAndPlay') diff --git a/resources/assets/js/components/artist/ArtistContextMenu.spec.ts b/resources/assets/js/components/artist/ArtistContextMenu.spec.ts index f106b79d..90963064 100644 --- a/resources/assets/js/components/artist/ArtistContextMenu.spec.ts +++ b/resources/assets/js/components/artist/ArtistContextMenu.spec.ts @@ -15,7 +15,7 @@ new class extends UnitTestCase { it('renders', async () => expect((await this.renderComponent()).html()).toMatchSnapshot()) it('plays all', async () => { - const songs = factory('song', 10) + const songs = factory('song', 10) const fetchMock = this.mock(songStore, 'fetchForArtist').mockResolvedValue(songs) const playMock = this.mock(playbackService, 'queueAndPlay') @@ -28,7 +28,7 @@ new class extends UnitTestCase { }) it('shuffles all', async () => { - const songs = factory('song', 10) + const songs = factory('song', 10) const fetchMock = this.mock(songStore, 'fetchForArtist').mockResolvedValue(songs) const playMock = this.mock(playbackService, 'queueAndPlay') @@ -66,14 +66,14 @@ new class extends UnitTestCase { }) it('does not have an option to download or go to Unknown Artist', async () => { - await this.renderComponent(factory.states('unknown')('artist')) + await this.renderComponent(factory.states('unknown')('artist')) expect(screen.queryByText('Go to Artist')).toBeNull() expect(screen.queryByText('Download')).toBeNull() }) it('does not have an option to download or go to Various Artist', async () => { - await this.renderComponent(factory.states('various')('artist')) + await this.renderComponent(factory.states('various')('artist')) expect(screen.queryByText('Go to Artist')).toBeNull() expect(screen.queryByText('Download')).toBeNull() @@ -81,7 +81,7 @@ new class extends UnitTestCase { } private async renderComponent (_artist?: Artist) { - artist = _artist || factory('artist', { + artist = _artist || factory('artist', { name: 'Accept' }) diff --git a/resources/assets/js/components/artist/ArtistInfo.spec.ts b/resources/assets/js/components/artist/ArtistInfo.spec.ts index fec4783d..98d79af7 100644 --- a/resources/assets/js/components/artist/ArtistInfo.spec.ts +++ b/resources/assets/js/components/artist/ArtistInfo.spec.ts @@ -25,8 +25,8 @@ new class extends UnitTestCase { private async renderComponent (mode: MediaInfoDisplayMode = 'aside', info?: ArtistInfo) { commonStore.state.uses_last_fm = true - info = info ?? factory('artist-info') - artist = factory('artist', { name: 'Led Zeppelin' }) + info = info ?? factory('artist-info') + artist = factory('artist', { name: 'Led Zeppelin' }) const fetchMock = this.mock(mediaInfoService, 'fetchForArtist').mockResolvedValue(info) diff --git a/resources/assets/js/components/invitation/AcceptInvivation.spec.ts b/resources/assets/js/components/invitation/AcceptInvivation.spec.ts index a1971a6c..e74910eb 100644 --- a/resources/assets/js/components/invitation/AcceptInvivation.spec.ts +++ b/resources/assets/js/components/invitation/AcceptInvivation.spec.ts @@ -9,7 +9,7 @@ new class extends UnitTestCase { protected test () { it('accepts invitation', async () => { const getProspectMock = this.mock(invitationService, 'getUserProspect') - .mockResolvedValue(factory.states('prospect')('user')) + .mockResolvedValue(factory.states('prospect')('user')) const acceptMock = this.mock(invitationService, 'accept').mockResolvedValue({ token: 'my-api-token', diff --git a/resources/assets/js/components/layout/ModalWrapper.spec.ts b/resources/assets/js/components/layout/ModalWrapper.spec.ts index f0d7913b..87398c66 100644 --- a/resources/assets/js/components/layout/ModalWrapper.spec.ts +++ b/resources/assets/js/components/layout/ModalWrapper.spec.ts @@ -11,30 +11,38 @@ new class extends UnitTestCase { it.each<[string, keyof Events, User | Song[] | Playlist | PlaylistFolder | undefined]>([ ['add-user-form', 'MODAL_SHOW_ADD_USER_FORM', undefined], ['invite-user-form', 'MODAL_SHOW_INVITE_USER_FORM', undefined], - ['edit-user-form', 'MODAL_SHOW_EDIT_USER_FORM', factory('user')], - ['edit-song-form', 'MODAL_SHOW_EDIT_SONG_FORM', [factory('song')]], - ['create-playlist-form', 'MODAL_SHOW_CREATE_PLAYLIST_FORM', factory('playlist-folder')], + ['edit-user-form', 'MODAL_SHOW_EDIT_USER_FORM', factory('user')], + ['edit-song-form', 'MODAL_SHOW_EDIT_SONG_FORM', [factory('song')]], + ['create-playlist-form', 'MODAL_SHOW_CREATE_PLAYLIST_FORM', factory('playlist-folder')], ['create-playlist-folder-form', 'MODAL_SHOW_CREATE_PLAYLIST_FOLDER_FORM', undefined], - ['edit-playlist-folder-form', 'MODAL_SHOW_EDIT_PLAYLIST_FOLDER_FORM', factory('playlist-folder')], - ['create-smart-playlist-form', 'MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM', factory('playlist-folder')], - ['edit-playlist-form', 'MODAL_SHOW_EDIT_PLAYLIST_FORM', factory('playlist')], - ['edit-smart-playlist-form', 'MODAL_SHOW_EDIT_PLAYLIST_FORM', factory('playlist', { is_smart: true })], - ['about-koel', 'MODAL_SHOW_ABOUT_KOEL', undefined] + ['edit-playlist-folder-form', 'MODAL_SHOW_EDIT_PLAYLIST_FOLDER_FORM', factory('playlist-folder')], + ['playlist-collaboration', 'MODAL_SHOW_PLAYLIST_COLLABORATION', factory('playlist')], + ['create-smart-playlist-form', 'MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM', factory('playlist-folder')], + ['edit-playlist-form', 'MODAL_SHOW_EDIT_PLAYLIST_FORM', factory('playlist')], + ['edit-smart-playlist-form', 'MODAL_SHOW_EDIT_PLAYLIST_FORM', factory('playlist', { is_smart: true })], + ['about-koel', 'MODAL_SHOW_ABOUT_KOEL', undefined], + ['koel-plus', 'MODAL_SHOW_KOEL_PLUS', undefined], + ['equalizer', 'MODAL_SHOW_EQUALIZER', undefined], + ['add-podcast-form', 'MODAL_SHOW_ADD_PODCAST_FORM', undefined] ])('shows %s modal', async (modalName, eventName, eventParams?: any) => { this.render(ModalWrapper, { global: { stubs: { + AboutKoelModal: this.stub('about-koel'), + AddPodcastForm: this.stub('add-podcast-form'), AddUserForm: this.stub('add-user-form'), - EditUserForm: this.stub('edit-user-form'), - InviteUserForm: this.stub('invite-user-form'), - EditSongForm: this.stub('edit-song-form'), - CreatePlaylistForm: this.stub('create-playlist-form'), CreatePlaylistFolderForm: this.stub('create-playlist-folder-form'), - EditPlaylistFolderForm: this.stub('edit-playlist-folder-form'), + CreatePlaylistForm: this.stub('create-playlist-form'), CreateSmartPlaylistForm: this.stub('create-smart-playlist-form'), + EditPlaylistFolderForm: this.stub('edit-playlist-folder-form'), EditPlaylistForm: this.stub('edit-playlist-form'), EditSmartPlaylistForm: this.stub('edit-smart-playlist-form'), - AboutKoelModal: this.stub('about-koel') + EditSongForm: this.stub('edit-song-form'), + EditUserForm: this.stub('edit-user-form'), + Equalizer: this.stub('equalizer'), + InviteUserForm: this.stub('invite-user-form'), + KoelPlus: this.stub('koel-plus'), + PlaylistCollaborationModal: this.stub('playlist-collaboration') } } }) diff --git a/resources/assets/js/components/layout/ModalWrapper.vue b/resources/assets/js/components/layout/ModalWrapper.vue index 6f4f3e8c..475fc77a 100644 --- a/resources/assets/js/components/layout/ModalWrapper.vue +++ b/resources/assets/js/components/layout/ModalWrapper.vue @@ -14,21 +14,21 @@ import { arrayify, eventBus, provideReadonly } from '@/utils' import { ModalContextKey } from '@/symbols' const modalNameToComponentMap = { - 'create-playlist-form': defineAsyncComponent(() => import('@/components/playlist/CreatePlaylistForm.vue')), - 'edit-playlist-form': defineAsyncComponent(() => import('@/components/playlist/EditPlaylistForm.vue')), - 'create-smart-playlist-form': defineAsyncComponent(() => import('@/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue')), - 'edit-smart-playlist-form': defineAsyncComponent(() => import('@/components/playlist/smart-playlist/EditSmartPlaylistForm.vue')), - 'add-user-form': defineAsyncComponent(() => import('@/components/user/AddUserForm.vue')), - 'edit-user-form': defineAsyncComponent(() => import('@/components/user/EditUserForm.vue')), - 'invite-user-form': defineAsyncComponent(() => import('@/components/user/InviteUserForm.vue')), - 'edit-song-form': defineAsyncComponent(() => import('@/components/song/EditSongForm.vue')), - 'create-playlist-folder-form': defineAsyncComponent(() => import('@/components/playlist/CreatePlaylistFolderForm.vue')), - 'edit-playlist-folder-form': defineAsyncComponent(() => import('@/components/playlist/EditPlaylistFolderForm.vue')), - 'playlist-collaboration': defineAsyncComponent(() => import('@/components/playlist/PlaylistCollaborationModal.vue')), - 'add-podcast-form': defineAsyncComponent(() => import('@/components/podcast/AddPodcastForm.vue')), 'about-koel': defineAsyncComponent(() => import('@/components/meta/AboutKoelModal.vue')), + 'add-podcast-form': defineAsyncComponent(() => import('@/components/podcast/AddPodcastForm.vue')), + 'add-user-form': defineAsyncComponent(() => import('@/components/user/AddUserForm.vue')), + 'create-playlist-folder-form': defineAsyncComponent(() => import('@/components/playlist/CreatePlaylistFolderForm.vue')), + 'create-playlist-form': defineAsyncComponent(() => import('@/components/playlist/CreatePlaylistForm.vue')), + 'create-smart-playlist-form': defineAsyncComponent(() => import('@/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue')), + 'edit-playlist-folder-form': defineAsyncComponent(() => import('@/components/playlist/EditPlaylistFolderForm.vue')), + 'edit-playlist-form': defineAsyncComponent(() => import('@/components/playlist/EditPlaylistForm.vue')), + 'edit-smart-playlist-form': defineAsyncComponent(() => import('@/components/playlist/smart-playlist/EditSmartPlaylistForm.vue')), + 'edit-song-form': defineAsyncComponent(() => import('@/components/song/EditSongForm.vue')), + 'edit-user-form': defineAsyncComponent(() => import('@/components/user/EditUserForm.vue')), + 'equalizer': defineAsyncComponent(() => import('@/components/ui/equalizer/Equalizer.vue')), + 'invite-user-form': defineAsyncComponent(() => import('@/components/user/InviteUserForm.vue')), 'koel-plus': defineAsyncComponent(() => import('@/components/koel-plus/KoelPlusModal.vue')), - 'equalizer': defineAsyncComponent(() => import('@/components/ui/equalizer/Equalizer.vue')) + 'playlist-collaboration': defineAsyncComponent(() => import('@/components/playlist/PlaylistCollaborationModal.vue')) } type ModalName = keyof typeof modalNameToComponentMap diff --git a/resources/assets/js/components/layout/app-footer/FooterPlaybackControls.spec.ts b/resources/assets/js/components/layout/app-footer/FooterPlaybackControls.spec.ts index a8ac19a5..4cc5d70d 100644 --- a/resources/assets/js/components/layout/app-footer/FooterPlaybackControls.spec.ts +++ b/resources/assets/js/components/layout/app-footer/FooterPlaybackControls.spec.ts @@ -33,7 +33,7 @@ new class extends UnitTestCase { private renderComponent (song?: Song | null) { if (song === undefined) { - song = factory('song', { + song = factory('song', { id: '00000000-0000-0000-0000-000000000000', title: 'Fahrstuhl to Heaven', artist_name: 'Led Zeppelin', diff --git a/resources/assets/js/components/layout/app-footer/FooterSongInfo.spec.ts b/resources/assets/js/components/layout/app-footer/FooterSongInfo.spec.ts index 533f0ed2..ec60545d 100644 --- a/resources/assets/js/components/layout/app-footer/FooterSongInfo.spec.ts +++ b/resources/assets/js/components/layout/app-footer/FooterSongInfo.spec.ts @@ -10,7 +10,7 @@ new class extends UnitTestCase { it('renders with no current song', () => expect(this.render(FooterSongInfo).html()).toMatchSnapshot()) it('renders with current song', () => { - const song = factory('song', { + const song = factory('song', { title: 'Fahrstuhl zum Mond', album_cover: 'https://via.placeholder.com/150', playback_state: 'Playing', diff --git a/resources/assets/js/components/layout/main-wrapper/MainContent.spec.ts b/resources/assets/js/components/layout/main-wrapper/MainContent.spec.ts index f652eca3..4e0cd345 100644 --- a/resources/assets/js/components/layout/main-wrapper/MainContent.spec.ts +++ b/resources/assets/js/components/layout/main-wrapper/MainContent.spec.ts @@ -31,7 +31,7 @@ new class extends UnitTestCase { return this.render(MainContent, { global: { provide: { - [CurrentPlayableKey]: ref(factory('song')) + [CurrentPlayableKey]: ref(factory('song')) }, stubs: { AlbumArtOverlay, diff --git a/resources/assets/js/components/layout/main-wrapper/extra-drawer/ExtraDrawer.spec.ts b/resources/assets/js/components/layout/main-wrapper/extra-drawer/ExtraDrawer.spec.ts index 5d8ccaac..f52b8fd6 100644 --- a/resources/assets/js/components/layout/main-wrapper/extra-drawer/ExtraDrawer.spec.ts +++ b/resources/assets/js/components/layout/main-wrapper/extra-drawer/ExtraDrawer.spec.ts @@ -14,7 +14,7 @@ new class extends UnitTestCase { it('sets the active tab to the preference', async () => { preferenceStore.active_extra_panel_tab = 'YouTube' - this.renderComponent(ref(factory('song'))) + this.renderComponent(ref(factory('song'))) const tab = screen.getByTestId('extra-drawer-youtube') expect(tab.style.display).toBe('none') @@ -25,7 +25,7 @@ new class extends UnitTestCase { it('fetches info for the current song', async () => { commonStore.state.uses_you_tube = true - const song = factory('song') + const song = factory('song') const songRef = ref(null) const [, resolveArtistMock, resolveAlbumMock] = this.renderComponent(songRef) @@ -66,10 +66,10 @@ new class extends UnitTestCase { } private renderComponent (songRef: Ref = ref(null)): [RenderResult, Mock, Mock] { - const artist = factory('artist') + const artist = factory('artist') const resolveArtistMock = this.mock(artistStore, 'resolve').mockResolvedValue(artist) - const album = factory('album') + const album = factory('album') const resolveAlbumMock = this.mock(albumStore, 'resolve').mockResolvedValue(album) const rendered = this.render(ExtraDrawer, { diff --git a/resources/assets/js/components/layout/main-wrapper/sidebar/PlaylistSidebarItem.spec.ts b/resources/assets/js/components/layout/main-wrapper/sidebar/PlaylistSidebarItem.spec.ts index f1e26d1c..66b92102 100644 --- a/resources/assets/js/components/layout/main-wrapper/sidebar/PlaylistSidebarItem.spec.ts +++ b/resources/assets/js/components/layout/main-wrapper/sidebar/PlaylistSidebarItem.spec.ts @@ -17,7 +17,7 @@ new class extends UnitTestCase { protected test () { it('requests context menu if is playlist', async () => { const emitMock = this.mock(eventBus, 'emit') - const playlist = factory('playlist') + const playlist = factory('playlist') this.renderComponent(playlist) await fireEvent.contextMenu(screen.getByRole('listitem')) diff --git a/resources/assets/js/components/layout/main-wrapper/sidebar/SidebarPlaylistsSection.spec.ts b/resources/assets/js/components/layout/main-wrapper/sidebar/SidebarPlaylistsSection.spec.ts index c606e8dd..04374ea7 100644 --- a/resources/assets/js/components/layout/main-wrapper/sidebar/SidebarPlaylistsSection.spec.ts +++ b/resources/assets/js/components/layout/main-wrapper/sidebar/SidebarPlaylistsSection.spec.ts @@ -11,9 +11,9 @@ new class extends UnitTestCase { protected test () { it('displays orphan playlists', () => { playlistStore.state.playlists = [ - factory.states('orphan')('playlist', { name: 'Foo Playlist' }), - factory.states('orphan')('playlist', { name: 'Bar Playlist' }), - factory.states('smart', 'orphan')('playlist', { name: 'Smart Playlist' }) + factory.states('orphan')('playlist', { name: 'Foo Playlist' }), + factory.states('orphan')('playlist', { name: 'Bar Playlist' }), + factory.states('smart', 'orphan')('playlist', { name: 'Smart Playlist' }) ] this.renderComponent() @@ -25,8 +25,8 @@ new class extends UnitTestCase { it('displays playlist folders', () => { playlistFolderStore.state.folders = [ - factory('playlist-folder', { name: 'Foo Folder' }), - factory('playlist-folder', { name: 'Bar Folder' }) + factory('playlist-folder', { name: 'Foo Folder' }), + factory('playlist-folder', { name: 'Bar Folder' }) ] this.renderComponent() diff --git a/resources/assets/js/components/playlist/CreatePlaylistFolderForm.spec.ts b/resources/assets/js/components/playlist/CreatePlaylistFolderForm.spec.ts index 05e12085..335c8e04 100644 --- a/resources/assets/js/components/playlist/CreatePlaylistFolderForm.spec.ts +++ b/resources/assets/js/components/playlist/CreatePlaylistFolderForm.spec.ts @@ -9,7 +9,7 @@ new class extends UnitTestCase { protected test () { it('submits', async () => { const storeMock = this.mock(playlistFolderStore, 'store') - .mockResolvedValue(factory('playlist-folder')) + .mockResolvedValue(factory('playlist-folder')) this.render(CreatePlaylistFolderForm) diff --git a/resources/assets/js/components/playlist/CreatePlaylistForm.spec.ts b/resources/assets/js/components/playlist/CreatePlaylistForm.spec.ts index 971e6742..c792058d 100644 --- a/resources/assets/js/components/playlist/CreatePlaylistForm.spec.ts +++ b/resources/assets/js/components/playlist/CreatePlaylistForm.spec.ts @@ -10,8 +10,8 @@ import CreatePlaylistForm from './CreatePlaylistForm.vue' new class extends UnitTestCase { protected test () { it('creates playlist with no songs', async () => { - const folder = factory('playlist-folder') - const storeMock = this.mock(playlistStore, 'store').mockResolvedValue(factory('playlist')) + const folder = factory('playlist-folder') + const storeMock = this.mock(playlistStore, 'store').mockResolvedValue(factory('playlist')) this.render(CreatePlaylistForm, { global: { @@ -32,9 +32,9 @@ new class extends UnitTestCase { }) it('creates playlist with songs', async () => { - const songs = factory('song', 3) - const folder = factory('playlist-folder') - const storeMock = this.mock(playlistStore, 'store').mockResolvedValue(factory('playlist')) + const songs = factory('song', 3) + const folder = factory('playlist-folder') + const storeMock = this.mock(playlistStore, 'store').mockResolvedValue(factory('playlist')) this.render(CreatePlaylistForm, { global: { diff --git a/resources/assets/js/components/playlist/EditPlaylistFolderForm.spec.ts b/resources/assets/js/components/playlist/EditPlaylistFolderForm.spec.ts index e8383f3b..80e97b25 100644 --- a/resources/assets/js/components/playlist/EditPlaylistFolderForm.spec.ts +++ b/resources/assets/js/components/playlist/EditPlaylistFolderForm.spec.ts @@ -10,7 +10,7 @@ import EditPlaylistFolderForm from './EditPlaylistFolderForm.vue' new class extends UnitTestCase { protected test () { it('submits', async () => { - const folder = factory('playlist-folder', { name: 'My folder' }) + const folder = factory('playlist-folder', { name: 'My folder' }) const renameMock = this.mock(playlistFolderStore, 'rename') this.render(EditPlaylistFolderForm, { global: { diff --git a/resources/assets/js/components/playlist/EditPlaylistForm.spec.ts b/resources/assets/js/components/playlist/EditPlaylistForm.spec.ts index 79b5409d..0d30581d 100644 --- a/resources/assets/js/components/playlist/EditPlaylistForm.spec.ts +++ b/resources/assets/js/components/playlist/EditPlaylistForm.spec.ts @@ -10,9 +10,9 @@ import EditPlaylistForm from './EditPlaylistForm.vue' new class extends UnitTestCase { protected test () { it('submits', async () => { - playlistFolderStore.state.folders = factory('playlist-folder', 3) + playlistFolderStore.state.folders = factory('playlist-folder', 3) - const playlist = factory('playlist', { + const playlist = factory('playlist', { name: 'My playlist', folder_id: playlistFolderStore.state.folders[0].id }) diff --git a/resources/assets/js/components/playlist/InvitePlaylistContributors.spec.ts b/resources/assets/js/components/playlist/InvitePlaylistContributors.spec.ts index e64f2941..7a25848a 100644 --- a/resources/assets/js/components/playlist/InvitePlaylistContributors.spec.ts +++ b/resources/assets/js/components/playlist/InvitePlaylistContributors.spec.ts @@ -10,7 +10,7 @@ new class extends UnitTestCase { it('works', async () => { this.mock(playlistCollaborationService, 'createInviteLink').mockResolvedValue('http://localhost:3000/invite/1234') const writeTextMock = this.mock(navigator.clipboard, 'writeText') - const playlist = factory('playlist') + const playlist = factory('playlist') this.render(Component, { props: { diff --git a/resources/assets/js/components/playlist/PlaylistCollaborationModal.spec.ts b/resources/assets/js/components/playlist/PlaylistCollaborationModal.spec.ts index 0a3a210b..3f4e02d7 100644 --- a/resources/assets/js/components/playlist/PlaylistCollaborationModal.spec.ts +++ b/resources/assets/js/components/playlist/PlaylistCollaborationModal.spec.ts @@ -11,7 +11,7 @@ new class extends UnitTestCase { const { html } = this.render(Modal, { global: { provide: { - [ModalContextKey]: [ref({ playlist: factory('playlist') })] + [ModalContextKey]: [ref({ playlist: factory('playlist') })] }, stubs: { InviteCollaborators: this.stub('InviteCollaborators'), diff --git a/resources/assets/js/components/playlist/PlaylistCollaborationModal.vue b/resources/assets/js/components/playlist/PlaylistCollaborationModal.vue index b5958d5b..8d98c979 100644 --- a/resources/assets/js/components/playlist/PlaylistCollaborationModal.vue +++ b/resources/assets/js/components/playlist/PlaylistCollaborationModal.vue @@ -1,5 +1,10 @@