forked from koel/koel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for playlist folder functionalities
- Loading branch information
Showing
58 changed files
with
779 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
resources/assets/js/__tests__/factory/playlistFolderFactory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Faker } from '@faker-js/faker' | ||
|
||
export default (faker: Faker): PlaylistFolder => ({ | ||
type: 'playlist-folders', | ||
id: faker.datatype.uuid(), | ||
name: faker.random.word() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
resources/assets/js/components/album/__snapshots__/AlbumContextMenu.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
resources/assets/js/components/artist/__snapshots__/ArtistContextMenu.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 27 additions & 7 deletions
34
resources/assets/js/components/layout/ModalWrapper.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,45 @@ | ||
import { it } from 'vitest' | ||
import { waitFor } from '@testing-library/vue' | ||
import factory from '@/__tests__/factory' | ||
import { eventBus } from '@/utils' | ||
import { it } from 'vitest' | ||
import { EventName } from '@/config' | ||
import UnitTestCase from '@/__tests__/UnitTestCase' | ||
import ModalWrapper from './ModalWrapper.vue' | ||
|
||
new class extends UnitTestCase { | ||
protected test () { | ||
it.each<[string, EventName, User | Song | Playlist | any]>([ | ||
it.each<[string, EventName, User | Song[] | Playlist | PlaylistFolder | undefined]>([ | ||
['add-user-form', 'MODAL_SHOW_ADD_USER_FORM', undefined], | ||
['edit-user-form', 'MODAL_SHOW_EDIT_USER_FORM', factory('user')], | ||
['edit-song-form', 'MODAL_SHOW_EDIT_SONG_FORM', [factory('song')]], | ||
['edit-user-form', 'MODAL_SHOW_EDIT_USER_FORM', factory<User>('user')], | ||
['edit-song-form', 'MODAL_SHOW_EDIT_SONG_FORM', [factory<Song>('song')]], | ||
['create-playlist-form', 'MODAL_SHOW_CREATE_PLAYLIST_FORM', undefined], | ||
['create-playlist-folder-form', 'MODAL_SHOW_CREATE_PLAYLIST_FOLDER_FORM', undefined], | ||
['edit-playlist-folder-form', 'MODAL_SHOW_EDIT_PLAYLIST_FOLDER_FORM', factory<PlaylistFolder>('playlist-folder')], | ||
['create-smart-playlist-form', 'MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM', undefined], | ||
['edit-smart-playlist-form', 'MODAL_SHOW_EDIT_SMART_PLAYLIST_FORM', factory('playlist')], | ||
['edit-playlist-form', 'MODAL_SHOW_EDIT_PLAYLIST_FORM', factory<Playlist>('playlist')], | ||
['edit-smart-playlist-form', 'MODAL_SHOW_EDIT_PLAYLIST_FORM', factory<Playlist>('playlist', { is_smart: true })], | ||
['about-koel', 'MODAL_SHOW_ABOUT_KOEL', undefined] | ||
])('shows %s modal', async (modalName: string, eventName: EventName, eventParams?: any) => { | ||
const { findByTestId } = this.render(ModalWrapper) | ||
const { getByTestId } = this.render(ModalWrapper, { | ||
global: { | ||
stubs: { | ||
AddUserForm: this.stub('add-user-form'), | ||
EditUserForm: this.stub('edit-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'), | ||
CreateSmartPlaylistForm: this.stub('create-smart-playlist-form'), | ||
EditPlaylistForm: this.stub('edit-playlist-form'), | ||
EditSmartPlaylistForm: this.stub('edit-smart-playlist-form'), | ||
AboutKoel: this.stub('about-koel') | ||
} | ||
} | ||
}) | ||
|
||
eventBus.emit(eventName, eventParams) | ||
|
||
findByTestId(modalName) | ||
await waitFor(() => getByTestId(modalName)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
resources/assets/js/components/layout/app-footer/__snapshots__/FooterMiddlePane.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`renders with a song 1`] = ` | ||
<div class="middle-pane" data-testid="footer-middle-pane"> | ||
<div id="progressPane" class="progress"> | ||
<h3 class="title">Fahrstuhl to Heaven</h3> | ||
<p class="meta"><a href="/#!/artist/3" class="artist">Led Zeppelin</a> – <a href="/#!/album/4" class="album">Led Zeppelin IV</a></p> | ||
<div class="plyr"><audio controls="" crossorigin="anonymous"></audio></div> | ||
<div class="middle-pane" data-testid="footer-middle-pane" data-v-2ff4ca72=""> | ||
<div id="progressPane" class="progress" data-v-2ff4ca72=""> | ||
<h3 class="title" data-v-2ff4ca72="">Fahrstuhl to Heaven</h3> | ||
<p class="meta" data-v-2ff4ca72=""><a href="/#!/artist/3" class="artist" data-v-2ff4ca72="">Led Zeppelin</a> – <a href="/#!/album/4" class="album" data-v-2ff4ca72="">Led Zeppelin IV</a></p> | ||
<div class="plyr" data-v-2ff4ca72=""><audio controls="" crossorigin="anonymous" data-v-2ff4ca72=""></audio></div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`renders without a song 1`] = ` | ||
<div class="middle-pane" data-testid="footer-middle-pane"> | ||
<div id="progressPane" class="progress"> | ||
<div class="middle-pane" data-testid="footer-middle-pane" data-v-2ff4ca72=""> | ||
<div id="progressPane" class="progress" data-v-2ff4ca72=""> | ||
<!--v-if--> | ||
<div class="plyr"><audio controls="" crossorigin="anonymous"></audio></div> | ||
<div class="plyr" data-v-2ff4ca72=""><audio controls="" crossorigin="anonymous" data-v-2ff4ca72=""></audio></div> | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.