diff --git a/web/app/components/workflow-app/__tests__/search-params.spec.ts b/web/app/components/workflow-app/__tests__/search-params.spec.ts index 44e5d33458..bfce4054cb 100644 --- a/web/app/components/workflow-app/__tests__/search-params.spec.ts +++ b/web/app/components/workflow-app/__tests__/search-params.spec.ts @@ -2,16 +2,16 @@ import { ViewType } from '@/app/components/workflow/types' import { parseAsViewType } from '../search-params' describe('workflow-app search params', () => { - it('should parse the new file view value and keep serializing it as file', () => { + it('should parse valid view values and serialize them unchanged', () => { + expect(parseAsViewType.parse('graph')).toBe(ViewType.graph) + expect(parseAsViewType.serialize(ViewType.graph)).toBe('graph') + expect(parseAsViewType.parse('file')).toBe(ViewType.file) expect(parseAsViewType.serialize(ViewType.file)).toBe('file') }) - it('should keep supporting legacy skill view links by mapping them to file', () => { - expect(parseAsViewType.parse('skill')).toBe(ViewType.file) - }) - it('should reject unsupported view values', () => { + expect(parseAsViewType.parse('skill')).toBeNull() expect(parseAsViewType.parse('invalid-view')).toBeNull() }) }) diff --git a/web/app/components/workflow-app/search-params.ts b/web/app/components/workflow-app/search-params.ts index d5c9bbcda8..7bd0f8e2c7 100644 --- a/web/app/components/workflow-app/search-params.ts +++ b/web/app/components/workflow-app/search-params.ts @@ -1,17 +1,9 @@ -import { createParser } from 'nuqs' +import { parseAsStringLiteral } from 'nuqs' import { ViewType } from '@/app/components/workflow/types' -const VIEW_TYPES = Object.values(ViewType) as ViewType[] +const VIEW_TYPES = Object.values(ViewType) -export const parseAsViewType = createParser({ - parse: (value) => { - if (value === 'skill') - return ViewType.file - - return VIEW_TYPES.includes(value as ViewType) ? value as ViewType : null - }, - serialize: value => value, -}) +export const parseAsViewType = parseAsStringLiteral(VIEW_TYPES) .withDefault(ViewType.graph) .withOptions({ history: 'push',