锁定缴费校验失败时整单回滚,避免样本半成功落库;前端禁止删除锁定缴费样本,改码走更正编码。同步落地样本更正、采集微信通知、OA提及未读、细胞产品套餐与相关迁移文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { describe, it, beforeEach, afterEach } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { register } from 'node:module'
|
|
import { pathToFileURL } from 'node:url'
|
|
|
|
// 隔离 refresh* 的 Pinia/HTTP/静态资源导入链,避免 node --import tsx --test 加载失败。
|
|
const stubUrl =
|
|
'data:text/javascript,' +
|
|
[
|
|
'export async function refreshOaMenuBadges() {}',
|
|
'export async function refreshQcMenuBadges() {}',
|
|
'export async function refreshProductionMenuBadges() {}'
|
|
].join('\n')
|
|
|
|
const hookSource = `
|
|
const stubUrl = ${JSON.stringify(stubUrl)}
|
|
const names = ['oa-menu-badge', 'qc-menu-badge', 'production-menu-badge']
|
|
export async function resolve(specifier, context, nextResolve) {
|
|
const base = String(specifier).split('?')[0]
|
|
if (names.some((name) => base === './' + name || base.endsWith('/' + name))) {
|
|
return { shortCircuit: true, url: stubUrl }
|
|
}
|
|
return nextResolve(specifier, context)
|
|
}
|
|
`
|
|
|
|
register('data:text/javascript,' + encodeURIComponent(hookSource), pathToFileURL('./'))
|
|
|
|
const {
|
|
startMenuBadgePolling,
|
|
stopMenuBadgePolling,
|
|
isMenuBadgePollingActive,
|
|
MENU_BADGE_POLL_INTERVAL_MS
|
|
} = await import('./menu-badge-polling')
|
|
|
|
describe('menu-badge-polling', () => {
|
|
beforeEach(() => {
|
|
stopMenuBadgePolling()
|
|
})
|
|
afterEach(() => {
|
|
stopMenuBadgePolling()
|
|
})
|
|
|
|
it('exports 60s interval', () => {
|
|
assert.equal(MENU_BADGE_POLL_INTERVAL_MS, 60_000)
|
|
})
|
|
|
|
it('start is idempotent (single active flag)', () => {
|
|
startMenuBadgePolling()
|
|
startMenuBadgePolling()
|
|
assert.equal(isMenuBadgePollingActive(), true)
|
|
stopMenuBadgePolling()
|
|
assert.equal(isMenuBadgePollingActive(), false)
|
|
})
|
|
|
|
it('stop is safe when not started', () => {
|
|
stopMenuBadgePolling()
|
|
assert.equal(isMenuBadgePollingActive(), false)
|
|
})
|
|
})
|