| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import test from 'node:test'
- import assert from 'node:assert/strict'
- import {
- canBootstrapOrRevise,
- canPublish,
- canRun,
- evidenceSummary,
- formatPassRate,
- formatScore,
- policyStatusLabel,
- resultStatusLabel,
- ruleLabel,
- severityLabel
- } from '../src/views/dataGovernance/development/deviceQualityModel.js'
- test('separates policy editing, publishing and execution permissions', () => {
- assert.equal(canBootstrapOrRevise(['device-quality:edit']), true)
- assert.equal(canBootstrapOrRevise(['device-quality:execute']), false)
- assert.equal(canPublish(['device-quality:publish']), true)
- assert.equal(canPublish(['device-quality:edit']), false)
- assert.equal(canRun(['device-quality:execute']), true)
- assert.equal(canRun(['governance:read']), false)
- })
- test('presents governed policy and result labels', () => {
- assert.equal(policyStatusLabel('draft'), '草稿')
- assert.equal(policyStatusLabel('published'), '已发布')
- assert.equal(ruleLabel('maintenance_closed_loop'), '维修闭环完整性')
- assert.equal(severityLabel('critical'), '严重')
- assert.equal(resultStatusLabel('violated'), '存在违规')
- assert.equal(resultStatusLabel('not_applicable'), '不适用')
- })
- test('formats quality score and pass rate consistently', () => {
- assert.equal(formatScore(85), '85.0')
- assert.equal(formatScore(null), '—')
- assert.equal(formatPassRate(0.856), '85.6%')
- assert.equal(formatPassRate(undefined), '—')
- })
- test('summarizes bounded violation evidence without exposing raw attributes', () => {
- assert.deepEqual(evidenceSummary({
- asset_uid: 'asset-1',
- source_mapping_uid: 'mapping-1',
- missing_fields: ['location', 'organization'],
- password: 'must-not-be-shown'
- }), {
- assetUid: 'asset-1',
- sourceMappingUid: 'mapping-1',
- issueCount: 2
- })
- })
|