diff --git a/resources/assets/js/__tests__/UnitTestCase.ts b/resources/assets/js/__tests__/UnitTestCase.ts index 030bba8e..b550b356 100644 --- a/resources/assets/js/__tests__/UnitTestCase.ts +++ b/resources/assets/js/__tests__/UnitTestCase.ts @@ -13,7 +13,6 @@ import { commonStore } from '@/stores/commonStore' import { userStore } from '@/stores/userStore' import { http } from '@/services/http' import { DialogBoxKey, MessageToasterKey, OverlayKey, RouterKey } from '@/symbols' -import { routes } from '@/config/routes' import Router from '@/router' // A deep-merge function that @@ -47,7 +46,7 @@ export default abstract class UnitTestCase { private backupMethods = new Map() public constructor () { - this.router = new Router(routes) + this.router = new Router() this.mock(http, 'request') // prevent actual HTTP requests from being made this.user = userEvent.setup({ delay: null }) // @see https://github.com/testing-library/user-event/issues/833 @@ -82,11 +81,11 @@ export default abstract class UnitTestCase { }) } - protected auth (user?: User = null) { + protected auth (user?: User) { return this.be(user) } - protected be (user?: User = null) { + protected be (user?: User) { userStore.state.current = user || factory('user') return this } @@ -181,7 +180,7 @@ export default abstract class UnitTestCase { await this.user.type(element, value) } - protected async trigger (element: HTMLElement, key: EventType | string, options?: object = {}) { + protected async trigger (element: HTMLElement, key: EventType | string, options: object = {}) { await fireEvent(element, createEvent[key](element, options)) } diff --git a/resources/assets/js/app.ts b/resources/assets/js/app.ts index d2598503..cbf4f412 100644 --- a/resources/assets/js/app.ts +++ b/resources/assets/js/app.ts @@ -6,13 +6,12 @@ import { hideBrokenIcon } from '@/directives/hideBrokenIcon' import { overflowFade } from '@/directives/overflowFade' import { newTab } from '@/directives/newTab' import { RouterKey } from '@/symbols' -import { routes } from '@/config/routes' import Router from '@/router' import '@/../css/app.pcss' import App from './App.vue' createApp(App) - .provide(RouterKey, new Router(routes)) + .provide(RouterKey, new Router()) .component('Icon', FontAwesomeIcon) .component('IconLayers', FontAwesomeLayers) .directive('koel-focus', focus) diff --git a/resources/assets/js/components/album/AlbumCard.vue b/resources/assets/js/components/album/AlbumCard.vue index 4412ad11..032f69df 100644 --- a/resources/assets/js/components/album/AlbumCard.vue +++ b/resources/assets/js/components/album/AlbumCard.vue @@ -9,8 +9,8 @@ @dragstart="onDragStart" > @@ -45,7 +45,7 @@ import { useRouter } from '@/composables/useRouter' import BaseCard from '@/components/ui/album-artist/AlbumOrArtistCard.vue' const props = withDefaults(defineProps<{ album: Album, layout?: ArtistAlbumCardLayout }>(), { layout: 'full' }) -const { go } = useRouter() +const { go, url } = useRouter() const { startDragging } = useDraggable('album') const { album, layout } = toRefs(props) @@ -58,7 +58,7 @@ const showing = computed(() => !albumStore.isUnknown(album.value)) const shuffle = async () => { playbackService.queueAndPlay(await songStore.fetchForAlbum(album.value), true /* shuffled */) - go('queue') + go(url('queue')) } const download = () => downloadService.fromAlbum(album.value) diff --git a/resources/assets/js/components/album/AlbumContextMenu.spec.ts b/resources/assets/js/components/album/AlbumContextMenu.spec.ts index a743631a..f8bd88d1 100644 --- a/resources/assets/js/components/album/AlbumContextMenu.spec.ts +++ b/resources/assets/js/components/album/AlbumContextMenu.spec.ts @@ -64,7 +64,7 @@ new class extends UnitTestCase { await this.user.click(screen.getByText('Go to Album')) - expect(mock).toHaveBeenCalledWith(`album/${album.id}`) + expect(mock).toHaveBeenCalledWith(`/#/albums/${album.id}`) }) it('does not have an option to download or go to Unknown Album and Artist', async () => { @@ -81,7 +81,7 @@ new class extends UnitTestCase { await this.user.click(screen.getByText('Go to Artist')) - expect(mock).toHaveBeenCalledWith(`artist/${album.artist_id}`) + expect(mock).toHaveBeenCalledWith(`/#/artists/${album.artist_id}`) }) } diff --git a/resources/assets/js/components/album/AlbumContextMenu.vue b/resources/assets/js/components/album/AlbumContextMenu.vue index 572e86eb..dc164b81 100644 --- a/resources/assets/js/components/album/AlbumContextMenu.vue +++ b/resources/assets/js/components/album/AlbumContextMenu.vue @@ -26,7 +26,7 @@ import { useContextMenu } from '@/composables/useContextMenu' import { useRouter } from '@/composables/useRouter' import { eventBus } from '@/utils/eventBus' -const { go } = useRouter() +const { go, url } = useRouter() const { base, ContextMenu, open, trigger } = useContextMenu() const album = ref() @@ -40,16 +40,16 @@ const isStandardArtist = computed(() => { const play = () => trigger(async () => { playbackService.queueAndPlay(await songStore.fetchForAlbum(album.value!)) - go('queue') + go(url('queue')) }) const shuffle = () => trigger(async () => { playbackService.queueAndPlay(await songStore.fetchForAlbum(album.value!), true) - go('queue') + go(url('queue')) }) -const viewAlbumDetails = () => trigger(() => go(`album/${album.value!.id}`)) -const viewArtistDetails = () => trigger(() => go(`artist/${album.value!.artist_id}`)) +const viewAlbumDetails = () => trigger(() => go(url('albums.show', { id: album.value!.id }))) +const viewArtistDetails = () => trigger(() => go(url('artists.show', { id: album.value!.artist_id }))) const download = () => trigger(() => downloadService.fromAlbum(album.value!)) eventBus.on('ALBUM_CONTEXT_MENU_REQUESTED', async ({ pageX, pageY }, _album) => { diff --git a/resources/assets/js/components/album/__snapshots__/AlbumCard.spec.ts.snap b/resources/assets/js/components/album/__snapshots__/AlbumCard.spec.ts.snap index d69ef4f1..9b86ae7b 100644 --- a/resources/assets/js/components/album/__snapshots__/AlbumCard.spec.ts.snap +++ b/resources/assets/js/components/album/__snapshots__/AlbumCard.spec.ts.snap @@ -3,7 +3,7 @@ exports[`renders 1`] = `
diff --git a/resources/assets/js/components/artist/ArtistCard.vue b/resources/assets/js/components/artist/ArtistCard.vue index 21c58083..6766f27f 100644 --- a/resources/assets/js/components/artist/ArtistCard.vue +++ b/resources/assets/js/components/artist/ArtistCard.vue @@ -9,7 +9,7 @@ @dragstart="onDragStart" >