Files
CN_Tool_client/frontend/src/views/steady/steadyDataView/contracts/check-chunked-query-contract.mjs
yexb 055e69fff7 feat(steady): 完善稳态数据视图功能
- 更新纵坐标刻度算法,优化小数趋势图范围显示
- 添加稳态趋势图全屏模式和共享工具组件
- 实现多图联动的鼠标悬停竖线同步功能
- 调整主线线宽分档策略,降低最大线宽限制
- 重构稳态趋势工具栏,优化谐波次数选择逻辑
- 添加周时间周期搜索支持和自定义时间范围选择
- 完善稳态数据表格和指示器浮动面板功能
- 优化稳态趋势图性能,添加LTB采样和动画控制
- 修复数据表格打开前的趋势数据验证问题
- 统一时间轴标签格式化和网格对齐处理
2026-05-27 08:06:12 +08:00

83 lines
3.5 KiB
JavaScript

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const currentDir = path.dirname(fileURLToPath(import.meta.url))
const pageFile = path.resolve(currentDir, '../index.vue')
const chartPanelFile = path.resolve(currentDir, '../components/SteadyTrendChartPanel.vue')
const trendOptionsFile = path.resolve(currentDir, '../utils/trendOptions.ts')
const payloadFile = path.resolve(currentDir, '../utils/trendPayload.ts')
const interfaceFile = path.resolve(currentDir, '../../../../api/steady/steadyDataView/interface/index.ts')
const read = file => fs.readFileSync(file, 'utf8')
const pageSource = read(pageFile)
const chartPanelSource = read(chartPanelFile)
const trendOptionsSource = read(trendOptionsFile)
const payloadSource = read(payloadFile)
const interfaceSource = read(interfaceFile)
const checks = [
[
'steadyDataView imports the day query endpoint for chunked loading',
/import\s*\{[^}]*querySteadyTrendDay[^}]*\}\s*from\s*'@\/api\/steady\/steadyDataView'/,
pageSource
],
[
'steadyDataView routes long ranges through chunked trend loading',
/isSteadyTrendRangeOverChunkLimit\(payload\.timeStart,\s*payload\.timeEnd\)[\s\S]*querySteadyTrendInChunks/,
pageSource
],
[
'steadyDataView prevents stale chunk responses from overwriting newer queries',
/trendQuerySerial[\s\S]*currentQuerySerial[\s\S]*currentQuerySerial\s*!==\s*trendQuerySerial/,
pageSource
],
['chunk helper uses a three day maximum window', /STEADY_TREND_CHUNK_DAYS\s*=\s*3/, payloadSource],
[
'long range chunk query initializes a full time range result before data arrives',
/buildEmptySteadyTrendQueryResult\(payload\.timeStart,\s*payload\.timeEnd\)/,
pageSource
],
[
'long range chunk query avoids trend loading overlay',
/loading\.trend\s*=\s*!isSteadyTrendRangeOverChunkLimit\(payload\.timeStart,\s*payload\.timeEnd\)/,
pageSource
],
['chunk helper exports a long range predicate', /export\s+const\s+isSteadyTrendRangeOverChunkLimit/, payloadSource],
['chunk helper exports query chunk builder', /export\s+const\s+buildSteadyTrendQueryChunks/, payloadSource],
['chunk helper exports incremental result merger', /export\s+const\s+mergeSteadyTrendQueryResult/, payloadSource],
[
'chunk helper exports empty range result builder',
/export\s+const\s+buildEmptySteadyTrendQueryResult/,
payloadSource
],
['chunk helper exports no data predicate', /export\s+const\s+hasSteadyTrendResultData/, payloadSource],
[
'trend result carries full query time range metadata',
/queryTimeStart\?:\s*string[\s\S]*queryTimeEnd\?:\s*string/,
interfaceSource
],
['chart panel enables missing data by default', /const\s+missingDataEnabled\s*=\s*ref\(true\)/, chartPanelSource],
[
'chart panel shows no data state after completed empty query',
/hasQueriedWithoutData[\s\S]*description="暂无数据"/,
chartPanelSource
],
[
'chart options use full query time range for x axis min and max',
/queryTimeStart[\s\S]*queryTimeEnd[\s\S]*xAxis[\s\S]*min:[\s\S]*max:/,
trendOptionsSource
]
]
const failures = checks.filter(([_name, pattern, source]) => !pattern.test(source))
if (failures.length) {
console.error('steadyDataView chunked query contract failed:')
failures.forEach(([name]) => console.error(`- ${name}`))
process.exit(1)
}
console.log('steadyDataView chunked query contract passed')