58 lines
2.2 KiB
JavaScript
58 lines
2.2 KiB
JavaScript
|
|
/* eslint-env node */
|
||
|
|
import fs from 'node:fs'
|
||
|
|
import path from 'node:path'
|
||
|
|
import { fileURLToPath } from 'node:url'
|
||
|
|
|
||
|
|
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
||
|
|
const chartPanelFile = path.resolve(currentDir, '../components/SteadyTrendChartPanel.vue')
|
||
|
|
const trendOptionsFile = path.resolve(currentDir, '../utils/trendOptions.ts')
|
||
|
|
|
||
|
|
const chartPanelSource = fs.readFileSync(chartPanelFile, 'utf8')
|
||
|
|
const trendOptionsSource = fs.readFileSync(trendOptionsFile, 'utf8')
|
||
|
|
|
||
|
|
const checks = [
|
||
|
|
['chart panel defines missing data tool action', /'missing-data'/, chartPanelSource],
|
||
|
|
['chart panel labels missing data action', /action:\s*'missing-data'[\s\S]*label:/, chartPanelSource],
|
||
|
|
[
|
||
|
|
'chart panel defaults missing data enabled for every query',
|
||
|
|
/const\s+missingDataEnabled\s*=\s*ref\(true\)/,
|
||
|
|
chartPanelSource
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'chart panel marks missing data action active only when enabled',
|
||
|
|
/action\s*===\s*'missing-data'[\s\S]*return\s+missingDataEnabled\.value/,
|
||
|
|
chartPanelSource
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'chart panel passes missing data state into chart options',
|
||
|
|
/buildSteadyTrendChartGroups\([^)]*trendXZoomRange\.value[\s\S]*showMissingData:\s*missingDataEnabled\.value/,
|
||
|
|
chartPanelSource
|
||
|
|
],
|
||
|
|
['chart options accept missing data option', /showMissingData\?:\s*boolean/, trendOptionsSource],
|
||
|
|
[
|
||
|
|
'chart options only fills missing data when enabled',
|
||
|
|
/chartOptions\.showMissingData\s*===\s*true\s*\?\s*fillSteadyTrendMissingPoints\(/,
|
||
|
|
trendOptionsSource
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'missing data filler inserts null values',
|
||
|
|
/fillSteadyTrendMissingPoints[\s\S]*value:[\s\S]*:\s*null/,
|
||
|
|
trendOptionsSource
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'missing data filler infers interval from existing time gaps',
|
||
|
|
/resolveSteadyTrendPointIntervalMs[\s\S]*gaps[\s\S]*Math\.min/,
|
||
|
|
trendOptionsSource
|
||
|
|
]
|
||
|
|
]
|
||
|
|
|
||
|
|
const failed = checks.filter(([, pattern, source]) => !pattern.test(source)).map(([message]) => message)
|
||
|
|
|
||
|
|
if (failed.length) {
|
||
|
|
console.error('steadyDataView missing data contract failed:')
|
||
|
|
failed.forEach(message => console.error(`- ${message}`))
|
||
|
|
process.exit(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
console.log('steadyDataView missing data contract passed')
|