Files
X-Financial/web/tests/refresh-interval-controls.test.mjs
2026-05-29 13:17:39 +08:00

35 lines
1.7 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const refreshOptions = readFileSync(new URL('../src/utils/refreshIntervalOptions.js', import.meta.url), 'utf8')
const logsView = readFileSync(new URL('../src/views/LogsView.vue', import.meta.url), 'utf8')
const logsScript = readFileSync(new URL('../src/views/scripts/LogsView.js', import.meta.url), 'utf8')
const workRecords = readFileSync(
new URL('../src/components/audit/DigitalEmployeeWorkRecords.vue', import.meta.url),
'utf8'
)
test('shared refresh interval options default to 60 seconds', () => {
assert.match(refreshOptions, /DEFAULT_REFRESH_INTERVAL_MS\s*=\s*60000/)
for (const value of [1000, 3000, 5000, 10000, 30000, 60000, 180000]) {
assert.match(refreshOptions, new RegExp(`value:\\s*${value}`))
}
})
test('system logs list exposes refresh interval control', () => {
assert.match(logsScript, /refreshInterval\s*=\s*ref\(DEFAULT_REFRESH_INTERVAL_MS\)/)
assert.match(logsScript, /window\.setInterval\([\s\S]*refreshInterval\.value/)
assert.match(logsView, /刷新时间 \{\{ refreshIntervalLabel \}\}/)
assert.match(logsView, /v-for="option in refreshIntervalOptions"/)
assert.doesNotMatch(logsView, /刷新日志/)
})
test('digital employee work records expose refresh interval control', () => {
assert.match(workRecords, /refreshInterval\s*=\s*ref\(DEFAULT_REFRESH_INTERVAL_MS\)/)
assert.match(workRecords, /refreshIntervalPickerOptions\s*=\s*REFRESH_INTERVAL_OPTIONS/)
assert.match(workRecords, /window\.setInterval\([\s\S]*refreshInterval\.value/)
assert.match(workRecords, /刷新时间 \$\{refreshIntervalLabel\}/)
assert.doesNotMatch(workRecords, /AGENT_RUN_POLL_INTERVAL_MS/)
})