This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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('保存')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user