import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import test from 'node:test'; const read = (path) => readFile(new URL(path, import.meta.url), 'utf8'); const centeredButtonRule = (source, selector) => { const rule = source.match(new RegExp(`\\.${selector}\\s*\\{([^}]*)\\}`))?.[1] || ''; assert.ok(rule, `missing .${selector} style rule`); assert.match(rule, /display:\s*flex/); assert.match(rule, /align-items:\s*center/); assert.match(rule, /justify-content:\s*center/); assert.match(rule, /padding:\s*0(?:;|\s)/); assert.match(rule, /line-height:\s*1(?:;|\s)/); }; test('帮道大喇叭仅使用认证后的真实广播接口', async () => { const service = await read('../src/services/broadcast.ts'); assert.match(service, /\/api\/aihr\/broadcast\/unread-count/); assert.match(service, /\/api\/aihr\/broadcast\/messages\?pageNum=/); assert.match(service, /\/api\/aihr\/broadcast\/messages\/\$\{id\}/); assert.match(service, /\/read`/); assert.doesNotMatch(service, /auth:\s*false/); }); test('首页喇叭只在确认有未读消息时显示红点,未登录保留回跳', async () => { const page = await read('../src/pages/user/today/index.vue'); assert.match(page, /v-if="hasUnreadBroadcast" class="bell-dot(?:\s+[^\"]*)?"/); assert.match(page, /getBroadcastUnreadCount/); assert.match(page, /const unreadBroadcastCount = ref\(null\)/); assert.match(page, /const hasUnreadBroadcast = computed\(\(\) => typeof unreadBroadcastCount\.value === 'number'/); assert.match(page, /const request = requests\.begin\('broadcast-unread'\);\s*unreadBroadcastCount\.value = null;/); assert.match(page, /visibleAccountKey !== nextAccountKey[\s\S]*unreadBroadcastCount\.value = null;/); assert.match(page, /