87 lines
3.9 KiB
JavaScript
87 lines
3.9 KiB
JavaScript
|
|
import fs from 'node:fs'
|
||
|
|
import path from 'node:path'
|
||
|
|
import process from 'node:process'
|
||
|
|
|
||
|
|
const rootDir = process.cwd()
|
||
|
|
const pageDir = path.resolve(rootDir, 'frontend/src/views/tools/mmsMapping')
|
||
|
|
const resultPanelPath = path.join(pageDir, 'components/MappingResultPanel.vue')
|
||
|
|
const checkDialogPath = path.join(pageDir, 'components/IcdPathCheckDialog.vue')
|
||
|
|
const flowPath = path.join(pageDir, 'utils/useMmsMappingFlow.ts')
|
||
|
|
|
||
|
|
const resultPanelSource = fs.readFileSync(resultPanelPath, 'utf8')
|
||
|
|
const checkDialogSource = fs.readFileSync(checkDialogPath, 'utf8')
|
||
|
|
const flowSource = fs.readFileSync(flowPath, 'utf8')
|
||
|
|
|
||
|
|
const checks = [
|
||
|
|
[
|
||
|
|
'ICD consistency issue dialog reviews the current issue list without clearing it on confirm',
|
||
|
|
() =>
|
||
|
|
!/reviewingIcdConsistencyProblemList/.test(resultPanelSource) &&
|
||
|
|
/v-for="\([^"]+in\s+icdConsistencyProblemList"/.test(resultPanelSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'ICD consistency issue confirm emits an acknowledgement only',
|
||
|
|
() =>
|
||
|
|
/confirmIcdConsistencyProblems/.test(resultPanelSource) &&
|
||
|
|
/emit\('confirm-icd-consistency-problems'\)/.test(resultPanelSource) &&
|
||
|
|
!/emit\('confirm-icd-consistency-problems',/.test(resultPanelSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'ICD consistency issue dialog has explicit confirm action',
|
||
|
|
() => /confirmIcdConsistencyProblems/.test(resultPanelSource) && /event: 'confirm-icd-consistency-problems'/.test(resultPanelSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'ICD consistency indicator shows remaining issue count on the warning icon',
|
||
|
|
() => /el-badge[\s\S]*icdConsistencyProblemCount/.test(resultPanelSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'ICD consistency issue dialog supports removing a single reviewed issue',
|
||
|
|
() =>
|
||
|
|
/@click="emit\('remove-icd-consistency-problem',\s*index\)"/.test(resultPanelSource) &&
|
||
|
|
/event:\s*'remove-icd-consistency-problem',\s*index:\s*number/.test(resultPanelSource) &&
|
||
|
|
/handleRemoveIcdConsistencyProblem/.test(flowSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'ICD consistency issue removal is wired from dialog host to flow state',
|
||
|
|
() =>
|
||
|
|
/@remove-icd-consistency-problem="handleRemoveIcdConsistencyProblemEvent"/.test(checkDialogSource) &&
|
||
|
|
/handleRemoveIcdConsistencyProblemEvent/.test(checkDialogSource) &&
|
||
|
|
/handleRemoveIcdConsistencyProblem/.test(flowSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'ICD consistency check opens the issue dialog when failed',
|
||
|
|
() =>
|
||
|
|
/shouldOpenIcdConsistencyProblems/.test(resultPanelSource) &&
|
||
|
|
/shouldOpenIcdConsistencyProblems\.value \+= 1/.test(flowSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'save is gated until failed ICD consistency issues are confirmed',
|
||
|
|
() => /hasConfirmedIcdConsistencyProblems/.test(flowSource) && /!hasConfirmedIcdConsistencyProblems\.value/.test(flowSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'reviewed ICD consistency result follows the remaining reviewed issue list',
|
||
|
|
() =>
|
||
|
|
/reviewedIcdConsistencyResult/.test(flowSource) &&
|
||
|
|
/if\s*\(!lastIcdConsistencyCheckResult\.value\)\s*return\s+1/.test(flowSource) &&
|
||
|
|
/return\s+reviewedIcdConsistencyProblemList\.value\.length\s*\?\s*0\s*:\s*1/.test(flowSource)
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'save payload preserves the remaining reviewed issue list after manual removal',
|
||
|
|
() =>
|
||
|
|
/buildReviewedIcdCheckMsg/.test(flowSource) &&
|
||
|
|
/const\s+reviewedIssues\s*=\s*reviewedIcdConsistencyProblemList\.value/.test(flowSource) &&
|
||
|
|
/details:\s*reviewedIssues/.test(flowSource) &&
|
||
|
|
/issuesJson:\s*reviewedIssues\.length/.test(flowSource)
|
||
|
|
]
|
||
|
|
]
|
||
|
|
|
||
|
|
const failedChecks = checks.filter(([, check]) => !check()).map(([name]) => name)
|
||
|
|
|
||
|
|
if (failedChecks.length) {
|
||
|
|
console.error('ICD consistency issue review contract failed:')
|
||
|
|
failedChecks.forEach(name => console.error(`- ${name}`))
|
||
|
|
process.exit(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
console.log('ICD consistency issue review contract passed.')
|