Refocus dashboard on device monitoring
This commit is contained in:
@@ -41,21 +41,47 @@ test('client stores simadmin_session from login and sends it on later proxied re
|
||||
assert.match(calls.at(-1).options.headers.cookie, /simadmin_session=abc123/)
|
||||
})
|
||||
|
||||
test('snapshot summary merges status from device, sim, network, sms and system endpoints', () => {
|
||||
test('snapshot summary exposes device-monitoring fields from stats, sms, data and hardware endpoints', () => {
|
||||
const snapshot = summarizeInstanceSnapshot({
|
||||
device: { data: { model: 'CPE X', imei: '123' } },
|
||||
sim: { data: { iccid: '8986', operator: 'CMCC' } },
|
||||
network: { data: { accessTechnology: 'LTE', registration: 'registered' } },
|
||||
smsStats: { data: { total: 12, unread: 2 } },
|
||||
data: { data: { enabled: true, connected: true } },
|
||||
ota: { data: { current_version: '1.2.3' } },
|
||||
device: { data: { model: 'CPE X', imei: '123', manufacturer: 'Quectel', powered: true, revision: 'RG500QEAAAR13A01' } },
|
||||
sim: { data: { iccid: '8986', imsi: '460001234', phone_numbers: ['13800138000'], operator: 'CMCC', present: true } },
|
||||
network: { data: { operator_name: '中国移动', signal_strength: -73, registration_status: 'registered', technology_preference: 'LTE' } },
|
||||
smsStats: { data: { total: 12, incoming: 9, outgoing: 3, pushed: 8 } },
|
||||
data: { data: { active: true } },
|
||||
ota: { data: { current_version: '1.2.3', current_commit: 'abc123', pending_update: false } },
|
||||
stats: { data: {
|
||||
cpu_load: [0.2, 0.4, 0.6],
|
||||
memory: { total: 1024, used: 512, free: 512 },
|
||||
disk: { total: 2048, used: 1024, free: 1024 },
|
||||
network_speed: { rx: 1024, tx: 2048 },
|
||||
system_info: { os: 'OpenWrt', kernel: '6.6.1' },
|
||||
temperature: { cpu: 47.5, modem: 41 },
|
||||
uptime: 3600,
|
||||
} },
|
||||
})
|
||||
assert.equal(snapshot.device.model, 'CPE X')
|
||||
assert.equal(snapshot.device.manufacturer, 'Quectel')
|
||||
assert.equal(snapshot.device.powered, true)
|
||||
assert.equal(snapshot.sim.iccid, '8986')
|
||||
assert.equal(snapshot.sim.present, true)
|
||||
assert.equal(snapshot.sim.phoneNumber, '13800138000')
|
||||
assert.equal(snapshot.network.operator, '中国移动')
|
||||
assert.equal(snapshot.network.signal, -73)
|
||||
assert.equal(snapshot.network.accessTechnology, 'LTE')
|
||||
assert.equal(snapshot.sms.total, 12)
|
||||
assert.equal(snapshot.data.connected, true)
|
||||
assert.equal(snapshot.sms.incoming, 9)
|
||||
assert.equal(snapshot.sms.outgoing, 3)
|
||||
assert.equal(snapshot.sms.pushed, 8)
|
||||
assert.equal(snapshot.data.active, true)
|
||||
assert.equal(snapshot.ota.currentVersion, '1.2.3')
|
||||
assert.equal(snapshot.ota.currentCommit, 'abc123')
|
||||
assert.equal(snapshot.ota.pendingUpdate, false)
|
||||
assert.deepEqual(snapshot.system.temperature, { cpu: 47.5, modem: 41 })
|
||||
assert.deepEqual(snapshot.system.networkSpeed, { rx: 1024, tx: 2048 })
|
||||
assert.equal(snapshot.system.memory.used, 512)
|
||||
assert.equal(snapshot.system.disk.free, 1024)
|
||||
assert.equal(snapshot.system.info.os, 'OpenWrt')
|
||||
assert.equal(snapshot.system.uptime, 3600)
|
||||
})
|
||||
|
||||
test('config store can add update and delete instances while persisting json', async () => {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
|
||||
const root = new URL('../', import.meta.url)
|
||||
|
||||
async function text(path) {
|
||||
return readFile(new URL(path, root), 'utf8')
|
||||
}
|
||||
|
||||
test('dashboard primary surface is a device monitoring board, not an API catalog', async () => {
|
||||
const html = await text('public/index.html')
|
||||
const app = await text('public/app.js')
|
||||
|
||||
assert.match(html, /设备监控|设备详情|实时状态/)
|
||||
assert.match(app, /renderDeviceDetails/)
|
||||
assert.match(app, /温度/)
|
||||
assert.match(app, /流量|速率/)
|
||||
assert.match(app, /内存|磁盘/)
|
||||
assert.match(app, /SIM|ICCID/)
|
||||
assert.match(app, /短信/)
|
||||
|
||||
const dashboardBlock = html.match(/<section id="dashboardView"[\s\S]*?<\/section>\s*<section id="apiView"/)
|
||||
assert.ok(dashboardBlock, 'dashboardView block should exist before apiView')
|
||||
assert.doesNotMatch(dashboardBlock[0], /API 地图|endpointList|接口路径/)
|
||||
})
|
||||
Reference in New Issue
Block a user