dify/cli/src/commands/help/environment/environment.test.ts
Yunlu Wen c0ee821d45
refactor: use absolute path for inter dir importing (#36822)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-01 01:32:16 +00:00

26 lines
925 B
TypeScript

import { describe, expect, it } from 'vitest'
import { ENV_REGISTRY } from '@/env/registry'
import { runHelpEnvironment } from './environment'
describe('runHelpEnvironment', () => {
it('starts with the ENVIRONMENT VARIABLES header', () => {
expect(runHelpEnvironment().startsWith('ENVIRONMENT VARIABLES\n\n')).toBe(true)
})
it('lists every var from ENV_REGISTRY with its description', () => {
const out = runHelpEnvironment()
for (const v of ENV_REGISTRY) {
expect(out).toContain(v.name)
expect(out).toContain(v.description)
}
})
it('marks sensitive vars with a never-echoed notice', () => {
const out = runHelpEnvironment()
expect(out).toContain('(treat as secret; never echoed)')
const sensitiveCount = ENV_REGISTRY.filter(v => v.sensitive).length
const noticeCount = (out.match(/treat as secret/g) ?? []).length
expect(noticeCount).toBe(sensitiveCount)
})
})