后端新增规则资产版本管理和规则文件 CRUD 接口,优化风险 规则生成模板执行和员工数据模型字段,知识库 RAG 增强本 地回退和文档提取能力,清理旧风险规则文件统一由生成引擎 管理,前端审计页面增加运行时调试面板和规则资产编辑交互, 补充单元测试覆盖。
164 lines
8.7 KiB
JavaScript
164 lines
8.7 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import test from 'node:test'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const documentsCenterView = readFileSync(
|
|
fileURLToPath(new URL('../src/views/DocumentsCenterView.vue', import.meta.url)),
|
|
'utf8'
|
|
)
|
|
|
|
const documentsCenterStyles = readFileSync(
|
|
fileURLToPath(new URL('../src/assets/styles/views/documents-center-view.css', import.meta.url)),
|
|
'utf8'
|
|
)
|
|
|
|
test('documents center keeps only the top scope tabs and renders status as a dropdown filter', () => {
|
|
assert.match(documentsCenterView, /<nav class="status-tabs document-scope-tabs"/)
|
|
assert.doesNotMatch(documentsCenterView, /<nav class="status-tabs document-state-tabs"/)
|
|
assert.match(documentsCenterView, /class="document-status-filter"[\s\S]*class="document-filter status-dropdown-filter"/)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/<div class="filter-set">[\s\S]*<div class="list-search">[\s\S]*<div class="document-status-filter"[\s\S]*<div v-if="showDocumentTypeFilter" class="document-filter">/
|
|
)
|
|
assert.match(documentsCenterView, /v-for="option in statusFilterOptions"/)
|
|
assert.match(documentsCenterView, /@click="selectStatusTab\(option\.value\)"/)
|
|
})
|
|
|
|
test('documents center top tabs start from application and show document category labels', () => {
|
|
assert.doesNotMatch(documentsCenterView, /const DOCUMENT_SCOPE_ALL = '全部'/)
|
|
assert.match(documentsCenterView, /const DOCUMENT_SCOPE_APPLICATION = '申请单'/)
|
|
assert.match(documentsCenterView, /const DOCUMENT_SCOPE_REIMBURSEMENT = '报销单'/)
|
|
assert.match(documentsCenterView, /const DOCUMENT_SCOPE_REVIEW = '审核单'/)
|
|
assert.match(documentsCenterView, /const DOCUMENT_SCOPE_ARCHIVE = '归档'/)
|
|
assert.match(documentsCenterView, /const activeScopeTab = ref\(DOCUMENT_SCOPE_APPLICATION\)/)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/const scopeTabs = \[[\s\S]*DOCUMENT_SCOPE_APPLICATION[\s\S]*DOCUMENT_SCOPE_REIMBURSEMENT[\s\S]*DOCUMENT_SCOPE_REVIEW[\s\S]*DOCUMENT_SCOPE_ARCHIVE[\s\S]*\]/
|
|
)
|
|
assert.doesNotMatch(documentsCenterView, /DOCUMENT_SCOPE_ALL/)
|
|
})
|
|
|
|
test('documents center category tabs map to the intended row sources', () => {
|
|
assert.match(
|
|
documentsCenterView,
|
|
/activeScopeTab\.value === DOCUMENT_SCOPE_APPLICATION[\s\S]*row\.documentTypeCode === DOCUMENT_TYPE_APPLICATION/
|
|
)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/activeScopeTab\.value === DOCUMENT_SCOPE_REIMBURSEMENT[\s\S]*ownedRows\.value\.filter/
|
|
)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/activeScopeTab\.value === DOCUMENT_SCOPE_REVIEW[\s\S]*return approvalRows\.value/
|
|
)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/activeScopeTab\.value === DOCUMENT_SCOPE_ARCHIVE[\s\S]*return archiveRows\.value/
|
|
)
|
|
assert.match(documentsCenterView, /return allSummaryRows\.value\.filter\(\(row\) => row\.documentTypeCode === DOCUMENT_TYPE_APPLICATION\)/)
|
|
})
|
|
|
|
test('documents center list shows created time and conditional stay time columns', () => {
|
|
assert.match(documentsCenterView, /import \{[\s\S]*formatDocumentListTime[\s\S]*resolveDocumentStayTimeDisplay[\s\S]*\} from '..\/utils\/documentCenterTime\.js'/)
|
|
assert.match(documentsCenterView, /<col class="col-created">/)
|
|
assert.match(documentsCenterView, /<col v-if="showStayTimeColumn" class="col-stay">/)
|
|
assert.match(documentsCenterView, /<th>单号<\/th>[\s\S]*<th>创建时间<\/th>[\s\S]*<th v-if="showStayTimeColumn">停留时间<\/th>/)
|
|
assert.match(documentsCenterView, /<td>\{\{ row\.createdAtDisplay \}\}<\/td>/)
|
|
assert.match(documentsCenterView, /<td v-if="showStayTimeColumn">\{\{ row\.stayTimeDisplay \}\}<\/td>/)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/const showStayTimeColumn = computed\(\(\) =>[\s\S]*DOCUMENT_SCOPE_APPLICATION[\s\S]*DOCUMENT_SCOPE_REVIEW/
|
|
)
|
|
assert.match(documentsCenterView, /createdAtDisplay: formatDocumentListTime\(createdAtSource\)/)
|
|
assert.match(documentsCenterView, /stayTimeDisplay: resolveDocumentStayTimeDisplay\(normalized\)/)
|
|
})
|
|
|
|
test('documents center action buttons are scoped to application and reimbursement tabs', () => {
|
|
assert.match(
|
|
documentsCenterView,
|
|
/v-if="\[DOCUMENT_SCOPE_APPLICATION, DOCUMENT_SCOPE_REIMBURSEMENT\]\.includes\(activeScopeTab\)"[\s\S]*class="document-actions"/
|
|
)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/v-if="activeScopeTab === DOCUMENT_SCOPE_APPLICATION"[\s\S]*@click="emit\('create-application'\)"[\s\S]*发起申请/
|
|
)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/v-if="activeScopeTab === DOCUMENT_SCOPE_REIMBURSEMENT"[\s\S]*@click="emit\('create-request'\)"[\s\S]*发起报销/
|
|
)
|
|
assert.doesNotMatch(documentsCenterView, /create-request-btn secondary/)
|
|
})
|
|
|
|
test('documents center category tabs render bubble counts for new documents', () => {
|
|
assert.match(documentsCenterView, /v-for="tab in scopeTabItems"/)
|
|
assert.match(documentsCenterView, /<span v-if="tab\.badgeCount > 0" class="scope-tab-badge"/)
|
|
assert.match(documentsCenterView, /tab\.badgeCount > 99 \? '99\+' : tab\.badgeCount/)
|
|
assert.match(documentsCenterView, /const scopeNewCountMap = computed\(\(\) => \(\{/)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/\[DOCUMENT_SCOPE_REIMBURSEMENT\]: ownedRows\.value\.filter\(\(row\) => row\.documentTypeCode === DOCUMENT_TYPE_REIMBURSEMENT\)\.length/
|
|
)
|
|
assert.match(documentsCenterView, /\[DOCUMENT_SCOPE_REVIEW\]: approvalRows\.value\.length/)
|
|
assert.match(documentsCenterView, /\[DOCUMENT_SCOPE_ARCHIVE\]: archiveRows\.value\.length/)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/const scopeTabItems = computed\(\(\) =>[\s\S]*badgeCount: scopeNewCountMap\.value\[tab\] \|\| 0/
|
|
)
|
|
})
|
|
|
|
test('documents center switches filter conditions by category tab', () => {
|
|
assert.match(documentsCenterView, /const FILTER_CONFIG_BY_SCOPE = \{/)
|
|
assert.doesNotMatch(documentsCenterView, /\[DOCUMENT_SCOPE_ALL\]: \{/)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/\[DOCUMENT_SCOPE_APPLICATION\]: \{[\s\S]*sceneFallbackLabel: '申请场景'[\s\S]*statusTitle: '申请状态'[\s\S]*showDocumentType: false/
|
|
)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/\[DOCUMENT_SCOPE_REIMBURSEMENT\]: \{[\s\S]*statusTitle: '报销状态'[\s\S]*showDocumentType: false/
|
|
)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/\[DOCUMENT_SCOPE_REVIEW\]: \{[\s\S]*sceneFallbackLabel: '审核场景'[\s\S]*statusTitle: '审核状态'[\s\S]*statusTabs: \['全部', '审批中', '待补充', '已完成'\]/
|
|
)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/\[DOCUMENT_SCOPE_ARCHIVE\]: \{[\s\S]*dateLabel: '归档时间'[\s\S]*statusTitle: '归档状态'[\s\S]*statusTabs: \['全部', '已完成'\]/
|
|
)
|
|
assert.match(documentsCenterView, /v-if="showDocumentTypeFilter" class="document-filter"/)
|
|
assert.match(documentsCenterView, /:placeholder="activeFilterConfig\.searchPlaceholder"/)
|
|
assert.match(documentsCenterView, /class="document-status-filter" :aria-label="activeFilterConfig\.statusTitle"/)
|
|
assert.doesNotMatch(documentsCenterView, /class="status-filter-label"/)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/watch\(activeFilterConfig, \(\) => \{[\s\S]*openFilterKey\.value = ''[\s\S]*datePopover\.value = false[\s\S]*pageSizeOpen\.value = false/
|
|
)
|
|
})
|
|
|
|
test('documents center status dropdown derives labels and closes after selection', () => {
|
|
assert.match(documentsCenterView, /const statusFilterOptions = computed\(\(\) =>/)
|
|
assert.match(documentsCenterView, /activeFilterConfig\.value\.statusTabs\.map/)
|
|
assert.match(documentsCenterView, /label: tab === '全部' \? '全部状态' : tab/)
|
|
assert.match(documentsCenterView, /const statusFilterLabel = computed\(\(\) =>/)
|
|
assert.match(
|
|
documentsCenterView,
|
|
/function selectStatusTab\(value\) \{[\s\S]*activeStatusTab\.value = value[\s\S]*openFilterKey\.value = ''[\s\S]*\}/
|
|
)
|
|
})
|
|
|
|
test('documents center status dropdown uses compact filter styling', () => {
|
|
assert.match(documentsCenterStyles, /\.documents-list\s*\{[\s\S]*grid-template-rows:\s*auto auto minmax\(0,\s*1fr\) auto;/)
|
|
assert.match(documentsCenterStyles, /\.status-tabs button\s*\{[\s\S]*display:\s*inline-flex;/)
|
|
assert.match(documentsCenterStyles, /\.scope-tab-badge\s*\{[\s\S]*border-radius:\s*999px;/)
|
|
assert.match(documentsCenterStyles, /min-width:\s*1320px;/)
|
|
assert.match(documentsCenterStyles, /\.col-created\s*\{\s*width:\s*10%;\s*\}/)
|
|
assert.match(documentsCenterStyles, /\.col-stay\s*\{\s*width:\s*9%;\s*\}/)
|
|
assert.match(documentsCenterStyles, /\.document-status-filter\s*\{[\s\S]*display:\s*inline-flex;/)
|
|
assert.match(documentsCenterStyles, /\.document-status-filter\s*\{[\s\S]*min-height:\s*38px;/)
|
|
assert.match(documentsCenterStyles, /\.status-filter-trigger\s*\{[\s\S]*min-width:\s*154px;/)
|
|
assert.match(documentsCenterStyles, /\.status-filter-menu\s*\{[\s\S]*min-width:\s*154px;/)
|
|
assert.doesNotMatch(documentsCenterStyles, /\.document-state-tabs\s*\{/)
|
|
assert.doesNotMatch(documentsCenterStyles, /\.document-status-filter\s*\{[^}]*margin-top:/)
|
|
})
|