diff --git a/src/components/QuickSearchForm/QuickSearchForm.vue b/src/components/QuickSearchForm/QuickSearchForm.vue index f6e0d7e..b4e8cfd 100644 --- a/src/components/QuickSearchForm/QuickSearchForm.vue +++ b/src/components/QuickSearchForm/QuickSearchForm.vue @@ -42,8 +42,8 @@ import { ref } from 'vue'; const router = useRouter(); -const props = withDefaults(defineProps<{ mode: 'dev' | 'prod' }>(), { - mode: 'prod', +const props = withDefaults(defineProps<{ baseUrlForRedirect: string }>(), { + baseUrlForRedirect: 'https://data-sources.pdap.io', }); const formSchema = [ @@ -85,13 +85,9 @@ function handleSubmit(values: { location: string; searchTerm: string }) { if (router.getRoutes().some((route) => route.path.includes('/search/'))) { router.push(`/search/${searchTerm}/${location}`); } else { - // Otherwise navigate via window - const baseUrl = - props.mode === 'prod' - ? 'https://data-sources.pdap.io' - : 'https://data-sources.pdap.dev'; - - window.location.assign(`${baseUrl}/search/${searchTerm}/${location}`); + window.location.assign( + `${props.baseUrlForRedirect}/search/${searchTerm}/${location}` + ); } } diff --git a/src/components/QuickSearchForm/__snapshots__/quick-search-form.spec.ts.snap b/src/components/QuickSearchForm/__snapshots__/quick-search-form.spec.ts.snap index c4eac1c..a5d7732 100644 --- a/src/components/QuickSearchForm/__snapshots__/quick-search-form.spec.ts.snap +++ b/src/components/QuickSearchForm/__snapshots__/quick-search-form.spec.ts.snap @@ -1,12 +1,12 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`QuickSearchForm component > Renders a QuickSearchForm 1`] = ` -
+

Search our database

-

If you have a question to answer, we may already know about helpful data in your area. Learn more about the data here. +

If you have a question to answer, we may already know about helpful data in your area. Learn more about the data here.

-
+
diff --git a/src/components/QuickSearchForm/quick-search-form.spec.ts b/src/components/QuickSearchForm/quick-search-form.spec.ts index 18294fd..48b071b 100644 --- a/src/components/QuickSearchForm/quick-search-form.spec.ts +++ b/src/components/QuickSearchForm/quick-search-form.spec.ts @@ -167,7 +167,8 @@ describe('QuickSearchForm component', () => { }); }); - test('Form triggers window navigation when rendered in app without /search/ route — dev mode', async () => { + test('Form triggers window navigation when rendered in app without /search/ route — custom baseUrlForRedirect', async () => { + const baseUrlForRedirect = 'https://data-sources.pdap.dev'; getRoutes.mockReturnValueOnce([ { path: '/' }, { path: '/foo' }, @@ -177,7 +178,7 @@ describe('QuickSearchForm component', () => { const wrapper = mount(QuickSearchForm, { ...base, props: { - mode: 'dev' as const, + baseUrlForRedirect, }, });