Files
knowledge-governance/web/src/SourceManagement.test.tsx
T
姚章浩 7448d130ec
build / build (push) Successful in 1m13s
feat(settings): 汇总全部数据源配置操作审计
2026-10-27 10:42:30 +08:00

35 lines
1.6 KiB
TypeScript

import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it, vi } from 'vitest'
import { SourceSettingsCard, SourceRefreshPolicy, SourceSettingsAudit } from './SourceManagement'
import type { SourceConnectionListItem } from './sourceConnections'
const row = {
id: 's1',
name: '测试来源',
source_type: 'dingtalk',
enabled: false,
schedule_configured: true,
next_refresh_at: null,
} as SourceConnectionListItem
describe('source management separation', () => {
it('keeps schedule editors, authorization and audit out of source rows', () => {
const html = renderToStaticMarkup(<SourceSettingsCard connection={row} onSourcesChanged={vi.fn()} />)
expect(html).toContain('自动刷新已暂停')
for (const text of ['保存设置', '自动刷新周期', '扫码刷新会话', '修订历史']) expect(html).not.toContain(text)
})
it('has a single shared period selector without silently resuming sources', () => {
const html = renderToStaticMarkup(<SourceRefreshPolicy connections={[row]} onSourcesChanged={vi.fn()} />)
expect((html.match(/<select/g) ?? []).length).toBe(1)
expect(html).toContain('保留各来源的暂停状态')
expect(html).toContain('应用到现有来源')
})
it('provides a dedicated read-only audit section', () => {
const html = renderToStaticMarkup(<SourceSettingsAudit connections={[row]} />)
expect(html).toContain('数据源设置审计')
expect(html).not.toContain('保存')
expect(html).not.toContain('<select')
expect(html).toContain('全部数据源')
expect(html).toContain('操作记录')
})
})