Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(desktop): r1-l3 add table tests for workspaceTabsRoute derivation

Diego Zacarias6175e2d61b91
diff --git a/desktop-app/ui/src/lib/__tests__/workspaceTabsRoute.test.ts b/desktop-app/ui/src/lib/__tests__/workspaceTabsRoute.test.ts
new file mode 100644
index 000000000..d24cc5d23
--- /dev/null
+++ b/desktop-app/ui/src/lib/__tests__/workspaceTabsRoute.test.ts
@@ -0,0 +1,60 @@
+import { describe, expect, it } from 'vitest'
+import { DESKTOP_ROUTES } from '@constants/navigation'
+import type { SettingsSection, WorkspaceTab } from '../workspaceTabs.types'
+import { mapKindToRoute, settingsSectionForRoute } from '../workspaceTabsRoute'
+
+const tab = (partial: Partial<WorkspaceTab> & Pick<WorkspaceTab, 'kind'>): WorkspaceTab => ({
+ id: 't1',
+ title: 'tab',
+ ...partial,
+})
+
+const SETTINGS_SECTIONS: SettingsSection[] = ['connectors', 'agents', 'plugins', 'settings']
+
+describe('workspaceTabsRoute', () => {
+ describe('mapKindToRoute', () => {
+ it('maps each non-settings kind to its route', () => {
+ expect(mapKindToRoute(tab({ kind: 'chat' }))).toBe(DESKTOP_ROUTES.chat)
+ expect(mapKindToRoute(tab({ kind: 'app' }))).toBe(DESKTOP_ROUTES.apps)
+ expect(mapKindToRoute(tab({ kind: 'files' }))).toBe(DESKTOP_ROUTES.files)
+ })
+
+ it('maps each settings section to its route', () => {
+ expect(mapKindToRoute(tab({ kind: 'settings', settings: { section: 'connectors' } }))).toBe(
+ DESKTOP_ROUTES.connectors
+ )
+ expect(mapKindToRoute(tab({ kind: 'settings', settings: { section: 'agents' } }))).toBe(
+ DESKTOP_ROUTES.agents
+ )
+ expect(mapKindToRoute(tab({ kind: 'settings', settings: { section: 'plugins' } }))).toBe(
+ DESKTOP_ROUTES.plugins
+ )
+ expect(mapKindToRoute(tab({ kind: 'settings', settings: { section: 'settings' } }))).toBe(
+ DESKTOP_ROUTES.settings
+ )
+ })
+
+ it('falls back to the settings route for a settings tab with no section payload', () => {
+ expect(mapKindToRoute(tab({ kind: 'settings' }))).toBe(DESKTOP_ROUTES.settings)
+ })
+
+ it('maps an empty workspace (undefined active tab) to chat', () => {
+ expect(mapKindToRoute(undefined)).toBe(DESKTOP_ROUTES.chat)
+ })
+ })
+
+ describe('settingsSectionForRoute', () => {
+ it('round-trips every settings section (section -> route -> section)', () => {
+ for (const section of SETTINGS_SECTIONS) {
+ const route = mapKindToRoute(tab({ kind: 'settings', settings: { section } }))
+ expect(settingsSectionForRoute(route)).toBe(section)
+ }
+ })
+
+ it('returns null for non-settings routes', () => {
+ expect(settingsSectionForRoute(DESKTOP_ROUTES.chat)).toBeNull()
+ expect(settingsSectionForRoute(DESKTOP_ROUTES.apps)).toBeNull()
+ expect(settingsSectionForRoute(DESKTOP_ROUTES.files)).toBeNull()
+ })
+ })
+})