import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
/**
* 客户端右上角代理余量常驻警告(2026-10-21 需求):
* 「如果欠费了就一直在客户端右上角有个弹窗警告」。
*
* 分两层钉:
* ① 行为层:warning 判定必须只认「用户自己的套餐 + low」,平台套餐/查询失败一律不弹;
* ② 源码层:只查用户套餐、定时轮询、无关闭件、挂在 App.vue——缺一条就是静默不弹或误报。
*/
const COMPONENT = 'src/shared/components/ProxyBalanceAlert.vue'
const APP = 'src/App.vue'
function read(rel: string): string {
return readFileSync(join(process.cwd(), rel), 'utf8')
}
function occurrences(text: string, token: string): number {
if (!token) return 0
let count = 0
let index = text.indexOf(token)
while (index !== -1) {
count += 1
index = text.indexOf(token, index + token.length)
}
return count
}
const source = read(COMPONENT)
const template = source.slice(source.indexOf(''), source.lastIndexOf(''))
const script = source.slice(source.indexOf('