diff --git a/frontend/src/lib/test-utils.ts b/frontend/src/lib/test-utils.ts index 9aff9328..88f9cc1e 100644 --- a/frontend/src/lib/test-utils.ts +++ b/frontend/src/lib/test-utils.ts @@ -73,6 +73,7 @@ export const setupMountedComponents = ( routes: routes }) router.push = vi.fn() + router.replace = vi.fn() // Create a testing pinia with the initial data. const pinia = createTestingPinia({ diff --git a/frontend/src/views/GenesListView.vue b/frontend/src/views/GenesListView.vue index c64e5ee6..702caf8d 100644 --- a/frontend/src/views/GenesListView.vue +++ b/frontend/src/views/GenesListView.vue @@ -30,7 +30,7 @@ watch( () => genesListStore.storeState, (storeState) => { if (storeState == StoreState.Redirect) { - router.push({ + router.replace({ name: 'gene', params: { searchTerm: genesListStore.redirectHgncId, genomeRelease: genomeReleaseRef.value } }) diff --git a/frontend/src/views/__tests__/GenesListView.spec.ts b/frontend/src/views/__tests__/GenesListView.spec.ts index d7a3f21d..4a3955c7 100644 --- a/frontend/src/views/__tests__/GenesListView.spec.ts +++ b/frontend/src/views/__tests__/GenesListView.spec.ts @@ -220,8 +220,8 @@ describe.concurrent('GenesListView', async () => { ) await nextTick() - expect(router.push).toHaveBeenCalledOnce() - expect(router.push).toHaveBeenCalledWith({ + expect(router.replace).toHaveBeenCalledOnce() + expect(router.replace).toHaveBeenCalledWith({ name: 'gene', params: { searchTerm: 'HGNC:3333', genomeRelease: 'grch37' } })