| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import test from 'node:test'
- import assert from 'node:assert/strict'
- import {
- canEditDeviceEntities,
- canReviewDeviceEntities,
- candidateStatusLabel,
- confidenceLabel,
- canonicalOptions,
- matchedSignalSummary,
- suggestionSourceLabel
- } from '../src/views/dataGovernance/development/deviceEntityResolutionModel.js'
- test('separates candidate editing from accountable review and rollback', () => {
- assert.equal(canEditDeviceEntities(['device-entities:edit']), true)
- assert.equal(canEditDeviceEntities(['governance:read']), false)
- assert.equal(canReviewDeviceEntities(['device-entities:review']), true)
- assert.equal(canReviewDeviceEntities(['device-entities:edit']), false)
- })
- test('presents governed lifecycle labels and confidence', () => {
- assert.equal(candidateStatusLabel('pending'), '待审核')
- assert.equal(candidateStatusLabel('merged'), '已合并')
- assert.equal(candidateStatusLabel('rolled_back'), '已回滚')
- assert.equal(suggestionSourceLabel('rule'), '确定性规则')
- assert.equal(suggestionSourceLabel('ai'), 'AI 建议')
- assert.equal(confidenceLabel(0.986), '98.6%')
- assert.equal(confidenceLabel(null), '—')
- })
- test('summarizes matched signals from literal explanation data', () => {
- const summary = matchedSignalSummary([
- { signal: 'name', matched: true, weight: 0.5 },
- { signal: 'location', matched: true, weight: 0.15 },
- { signal: 'model', matched: false, weight: 0.15 }
- ])
- assert.deepEqual(summary, {
- matched: 2,
- total: 3,
- weight: 0.65
- })
- })
- test('offers only the two candidate assets as canonical choices', () => {
- const options = canonicalOptions({
- left_asset_uid: 'asset-left',
- right_asset_uid: 'asset-right'
- })
- assert.deepEqual(options, [
- { text: '左侧资产 · asset-left', value: 'asset-left' },
- { text: '右侧资产 · asset-right', value: 'asset-right' }
- ])
- })
|