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(/
\s*
{ const css = await text('public/styles.css') assert.match(css, /\.sim-device-card/) assert.match(css, /\.home-device-grid/) const forbiddenSelectors = [ '.sim-card-kpis b', '.sim-card-foot', '.sim-card-model', '.instance-url', ] for (const selector of forbiddenSelectors) { const block = css.match(new RegExp(selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '[^{]*\\{([^}]*)\\}', 's')) assert.ok(block, `missing CSS block for ${selector}`) assert.doesNotMatch(block[1], /text-overflow\s*:\s*ellipsis|white-space\s*:\s*nowrap|overflow\s*:\s*hidden/, `${selector} must not truncate content`) } })