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"
>
- {{ album.name }}
- {{ album.artist_name }}
+ {{ album.name }}
+ {{ album.artist_name }}
{{ album.artist_name }}
@@ -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"
>
- {{ artist.name }}
+ {{ artist.name }}
@@ -36,7 +36,7 @@ import { useRouter } from '@/composables/useRouter'
import BaseCard from '@/components/ui/album-artist/AlbumOrArtistCard.vue'
const props = withDefaults(defineProps<{ artist: Artist, layout?: ArtistAlbumCardLayout }>(), { layout: 'full' })
-const { go } = useRouter()
+const { go, url } = useRouter()
const { startDragging } = useDraggable('artist')
const { artist, layout } = toRefs(props)
@@ -48,7 +48,7 @@ const showing = computed(() => artistStore.isStandard(artist.value))
const shuffle = async () => {
playbackService.queueAndPlay(await songStore.fetchForArtist(artist.value), true /* shuffled */)
- go('queue')
+ go(url('queue'))
}
const download = () => downloadService.fromArtist(artist.value)
diff --git a/resources/assets/js/components/artist/ArtistContextMenu.spec.ts b/resources/assets/js/components/artist/ArtistContextMenu.spec.ts
index e31741b8..a9906b60 100644
--- a/resources/assets/js/components/artist/ArtistContextMenu.spec.ts
+++ b/resources/assets/js/components/artist/ArtistContextMenu.spec.ts
@@ -64,7 +64,7 @@ new class extends UnitTestCase {
await screen.getByText('Go to Artist').click()
- expect(mock).toHaveBeenCalledWith(`artist/${artist.id}`)
+ expect(mock).toHaveBeenCalledWith(`/#/artists/${artist.id}`)
})
it('does not have an option to download or go to Unknown Artist', async () => {
diff --git a/resources/assets/js/components/artist/ArtistContextMenu.vue b/resources/assets/js/components/artist/ArtistContextMenu.vue
index 26a1e4a9..791eee2b 100644
--- a/resources/assets/js/components/artist/ArtistContextMenu.vue
+++ b/resources/assets/js/components/artist/ArtistContextMenu.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 artist = ref()
@@ -39,15 +39,15 @@ const isStandardArtist = computed(() =>
const play = () => trigger(async () => {
playbackService.queueAndPlay(await songStore.fetchForArtist(artist.value!))
- go('queue')
+ go(url('queue'))
})
const shuffle = () => trigger(async () => {
playbackService.queueAndPlay(await songStore.fetchForArtist(artist.value!), true)
- go('queue')
+ go(url('queue'))
})
-const viewArtistDetails = () => trigger(() => go(`artist/${artist.value!.id}`))
+const viewArtistDetails = () => trigger(() => go(url('artists.show', { id: artist.value!.id })))
const download = () => trigger(() => downloadService.fromArtist(artist.value!))
eventBus.on('ARTIST_CONTEXT_MENU_REQUESTED', async ({ pageX, pageY }, _artist) => {
diff --git a/resources/assets/js/components/artist/__snapshots__/ArtistCard.spec.ts.snap b/resources/assets/js/components/artist/__snapshots__/ArtistCard.spec.ts.snap
index c6c1f297..4526a627 100644
--- a/resources/assets/js/components/artist/__snapshots__/ArtistCard.spec.ts.snap
+++ b/resources/assets/js/components/artist/__snapshots__/ArtistCard.spec.ts.snap
@@ -3,7 +3,7 @@
exports[`renders 1`] = `
diff --git a/resources/assets/js/components/layout/app-footer/FooterExtraControls.vue b/resources/assets/js/components/layout/app-footer/FooterExtraControls.vue
index 4b61d8fb..d4e403e2 100644
--- a/resources/assets/js/components/layout/app-footer/FooterExtraControls.vue
+++ b/resources/assets/js/components/layout/app-footer/FooterExtraControls.vue
@@ -46,11 +46,11 @@ import FooterQueueIcon from '@/components/layout/app-footer/FooterQueueButton.vu
const isFullscreen = ref(false)
const fullscreenButtonTitle = computed(() => (isFullscreen.value ? 'Exit fullscreen mode' : 'Enter fullscreen mode'))
-const { go, isCurrentScreen } = useRouter()
+const { go, isCurrentScreen, url } = useRouter()
const showEqualizer = () => eventBus.emit('MODAL_SHOW_EQUALIZER')
const toggleFullscreen = () => eventBus.emit('FULLSCREEN_TOGGLE')
-const toggleVisualizer = () => go(isCurrentScreen('Visualizer') ? -1 : 'visualizer')
+const toggleVisualizer = () => go(isCurrentScreen('Visualizer') ? -1 : url('visualizer'))
onMounted(() => {
document.addEventListener('fullscreenchange', () => {
diff --git a/resources/assets/js/components/layout/app-footer/FooterQueueButton.spec.ts b/resources/assets/js/components/layout/app-footer/FooterQueueButton.spec.ts
index af021170..0b208c88 100644
--- a/resources/assets/js/components/layout/app-footer/FooterQueueButton.spec.ts
+++ b/resources/assets/js/components/layout/app-footer/FooterQueueButton.spec.ts
@@ -11,7 +11,7 @@ new class extends UnitTestCase {
this.render(Component)
await this.user.click(screen.getByRole('button'))
- expect(goMock).toHaveBeenCalledWith('queue')
+ expect(goMock).toHaveBeenCalledWith('/#/queue')
})
it('goes back if current screen is Queue', async () => {
diff --git a/resources/assets/js/components/layout/app-footer/FooterQueueButton.vue b/resources/assets/js/components/layout/app-footer/FooterQueueButton.vue
index bef0ae93..982b4422 100644
--- a/resources/assets/js/components/layout/app-footer/FooterQueueButton.vue
+++ b/resources/assets/js/components/layout/app-footer/FooterQueueButton.vue
@@ -24,7 +24,7 @@ import { pluralize } from '@/utils/formatters'
import FooterButton from '@/components/layout/app-footer/FooterButton.vue'
-const { go, isCurrentScreen } = useRouter()
+const { go, isCurrentScreen, url } = useRouter()
const { toastWarning, toastSuccess } = useMessageToaster()
const { acceptsDrop, resolveDroppedItems } = useDroppable(
@@ -58,7 +58,7 @@ const onDrop = async (event: DragEvent) => {
return false
}
-const showQueue = () => go(isCurrentScreen('Queue') ? -1 : 'queue')
+const showQueue = () => go(isCurrentScreen('Queue') ? -1 : url('queue'))