38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
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('home screen is a simadmin card wall and device detail owns interactions', async () => {
|
|
const html = await text('public/index.html')
|
|
const app = await text('public/app.js')
|
|
|
|
assert.match(html, /id="homeView"/)
|
|
assert.match(html, /id="homeDeviceGrid"/)
|
|
assert.match(html, /设备卡片|设备卡片墙|SimAdmin 卡片/)
|
|
assert.match(html, /id="detailView"/)
|
|
assert.match(html, /id="backToFleetBtn"/)
|
|
assert.match(html, /id="detailActions"/)
|
|
assert.match(html, /id="detailDeviceGrid"/)
|
|
|
|
assert.match(app, /function renderHomeCards/)
|
|
assert.match(app, /function openDeviceDetail/)
|
|
assert.match(app, /function renderDeviceDetails/)
|
|
assert.match(app, /data-open-detail/)
|
|
assert.match(app, /\['home', 'detail', 'rawpage', 'api'\]/)
|
|
assert.match(app, /温度/)
|
|
assert.match(app, /流量|速率/)
|
|
assert.match(app, /内存|磁盘/)
|
|
assert.match(app, /SIM|ICCID/)
|
|
assert.match(app, /短信/)
|
|
|
|
const homeBlock = html.match(/<section id="homeView"[\s\S]*?<\/section>\s*<section id="detailView"/)
|
|
assert.ok(homeBlock, 'homeView should exist before detailView')
|
|
assert.doesNotMatch(homeBlock[0], /API 地图|endpointList|接口路径|rawOutput/)
|
|
})
|