dify/web/app/components/app-sidebar/app-info/__tests__/app-mode-labels.spec.ts
Stephen Zhou b9fde89781
refactor(web): migrate i18n to selector optimize mode (#38657)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-10 09:35:31 +00:00

36 lines
1.2 KiB
TypeScript

import type { TFunction } from 'i18next'
import { withSelectorKey } from '@/test/i18n-mock'
import { AppModeEnum } from '@/types/app'
import { getAppModeLabel } from '../app-mode-labels'
describe('getAppModeLabel', () => {
const t = withSelectorKey((key: string, options?: Record<string, unknown>) => {
const ns = (options?.ns as string | undefined) ?? ''
return ns ? `${ns}.${key}` : key
}, 'app') as unknown as TFunction
it('should return advanced chat label', () => {
expect(getAppModeLabel(AppModeEnum.ADVANCED_CHAT, t)).toBe('app.types.advanced')
})
it('should return agent chat label', () => {
expect(getAppModeLabel(AppModeEnum.AGENT_CHAT, t)).toBe('app.types.agent')
})
it('should return chatbot label', () => {
expect(getAppModeLabel(AppModeEnum.CHAT, t)).toBe('app.types.chatbot')
})
it('should return completion label', () => {
expect(getAppModeLabel(AppModeEnum.COMPLETION, t)).toBe('app.types.completion')
})
it('should return workflow label for unknown mode', () => {
expect(getAppModeLabel('unknown-mode', t)).toBe('app.types.workflow')
})
it('should return workflow label for workflow mode', () => {
expect(getAppModeLabel(AppModeEnum.WORKFLOW, t)).toBe('app.types.workflow')
})
})