From f6002f7a8c188b253cb88646d8cf96707da88d4d Mon Sep 17 00:00:00 2001 From: gromdimon Date: Tue, 29 Aug 2023 10:33:02 +0200 Subject: [PATCH] minor --- frontend/src/components/__tests__/SearchBar.spec.ts | 3 +++ frontend/src/views/GeneDetailView.vue | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/__tests__/SearchBar.spec.ts b/frontend/src/components/__tests__/SearchBar.spec.ts index 25abd2a8..201a42ed 100644 --- a/frontend/src/components/__tests__/SearchBar.spec.ts +++ b/frontend/src/components/__tests__/SearchBar.spec.ts @@ -71,5 +71,8 @@ describe('SearchBar.vue', () => { const searchButton = wrapper.find('#search') as any expect(searchButton.exists()).toBe(true) await searchButton.trigger('click') + await searchButton.trigger('click') + expect(wrapper.emitted()).toHaveProperty('click') + expect(wrapper.emitted('click')).toHaveLength(2) }) }) diff --git a/frontend/src/views/GeneDetailView.vue b/frontend/src/views/GeneDetailView.vue index 93488ccb..5331570c 100644 --- a/frontend/src/views/GeneDetailView.vue +++ b/frontend/src/views/GeneDetailView.vue @@ -34,12 +34,23 @@ const loadDataToStore = async () => { // When the component is mounted or the search term is changed through // the router then we need to fetch the gene information from the backend // through the store. - onMounted(loadDataToStore) watch(() => props.searchTerm, loadDataToStore) watch(() => route.hash, scrollToSection) +// If geneInfoStore.storeState is StoreState.Error then redirect to the +// home page. +watch( + () => geneInfoStore.storeState, + (storeState) => { + if (storeState == StoreState.Error) { + geneInfoStore.clearData() + router.push({ name: 'home' }) + } + } +) + const SECTIONS = [ { id: 'hgnc', title: 'HGNC' }, { id: 'constraints-scores', title: 'Constraints / Scores' },