Files
X-Financial/web/tests/settings-cache-management-section.test.mjs
caoxiaozhu 8417a9f542 feat(web): 设置中心缓存管理与文件预览资产工具
- 新增 documentPreviewAssets 工具,统一从 URL/Blob/File 推断预览类型(image/pdf/file/unsupported)
- SettingsView/SettingsView.js/settingsModelHelper 新增系统缓存管理区块,调用 /settings/cache/clear 并展示清理结果;useSettings/services 适配
- WorkbenchAiFilePreviewDialog/useWorkbenchAiFilePreview 接入预览资产工具,workbenchAiComposerModel 调整文件处理
- ReceiptFolder/LogDetailView/DigitalEmployeeWorkRecords/travelReimbursementAttachmentModel 配套适配
- 新增 settings-cache-management-section 测试,更新 settings-llm/rendering/receipt-folder-view/composer-components/attachment-association 测试
2026-06-24 12:35:59 +08:00

40 lines
2.2 KiB
JavaScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { readFileSync } from 'node:fs'
const settingsModel = readFileSync(new URL('../src/utils/settingsModelHelper.js', import.meta.url), 'utf8')
const settingsService = readFileSync(new URL('../src/services/settings.js', import.meta.url), 'utf8')
const settingsScript = readFileSync(new URL('../src/views/scripts/SettingsView.js', import.meta.url), 'utf8')
const settingsView = readFileSync(new URL('../src/views/SettingsView.vue', import.meta.url), 'utf8')
const useSettings = readFileSync(new URL('../src/composables/useSettings.js', import.meta.url), 'utf8')
test('system settings replace Agent Trace with cache management', () => {
assert.match(settingsModel, /id:\s*'cacheManagement'[\s\S]*label:\s*'缓存管理'/)
assert.doesNotMatch(settingsModel, /id:\s*'agentTraces'/)
assert.doesNotMatch(settingsScript, /AgentTraceCenterView/)
assert.match(settingsView, /activeSection === 'cacheManagement'/)
assert.match(settingsView, /一键清理缓存/)
})
test('cache management action calls the settings clear-cache endpoint', () => {
assert.match(settingsService, /export function clearSystemCaches/)
assert.match(settingsService, /\/settings\/cache\/clear/)
assert.match(useSettings, /clearSystemCaches/)
assert.match(settingsView, /@click="clearAllCaches"/)
})
test('cache management section uses an enterprise maintenance layout', () => {
assert.match(settingsView, /class="settings-card cache-management-card"/)
assert.match(settingsView, /class="card-title-with-icon"/)
assert.match(settingsView, /class="cache-management-hero-metrics"/)
assert.match(settingsView, /class="cache-scope-grid"/)
assert.match(settingsView, /OCR 识别结果/)
assert.match(settingsView, /模型失败冷却/)
assert.match(settingsView, /知识库本地索引/)
assert.match(settingsView, /不会删除源文件、业务单据和系统日志/)
assert.match(settingsView, /:class="\{ 'is-error': cacheClearFailed \}"/)
assert.match(useSettings, /const cacheClearFailed = ref\(false\)/)
assert.match(useSettings, /normalizeCacheClearErrorMessage/)
assert.doesNotMatch(settingsView, />\\s*Not Found\\s*</)
})