mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-28 00:42:08 +08:00
This reverts commit cb751052a4.
Remove the tray latency test and its dashboard URL persistence and cache
changes because the two entry points have diverging behavior.
Preserve the subsequent IPC binding migration and remove generated fields,
input projections, and locale entries that depended on the reverted feature.
62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
|
|
|
|
vi.mock('tauri-plugin-mihomo-api', () => ({
|
|
delayProxyByName: vi.fn(async () => ({ delay: 120 })),
|
|
healthcheckNodeInProvider: vi.fn(async () => ({ delay: 120 })),
|
|
}))
|
|
|
|
import type { ResolvedProxyMember } from '@/types/proxy-view'
|
|
|
|
import delayManager from './delay'
|
|
|
|
const node = (name: string) =>
|
|
({
|
|
kind: 'node',
|
|
ref: { kind: 'node', name, recordId: `r:${name}` },
|
|
node: {
|
|
recordId: `r:${name}`,
|
|
name,
|
|
history: [],
|
|
source: { kind: 'core', proxyName: name },
|
|
},
|
|
}) as unknown as ResolvedProxyMember
|
|
|
|
const flush = () => new Promise((resolve) => setTimeout(resolve, 0))
|
|
|
|
let settles = 0
|
|
let unsubscribe: () => void
|
|
|
|
beforeEach(() => {
|
|
settles = 0
|
|
unsubscribe = delayManager.addGroupListener('g', () => {
|
|
settles += 1
|
|
})
|
|
})
|
|
|
|
afterEach(() => unsubscribe())
|
|
|
|
describe('group delay completion', () => {
|
|
test('notifies once after a batch settles', async () => {
|
|
const proxies = Array.from({ length: 6 }, (_, index) => node(`n${index}`))
|
|
|
|
await delayManager.checkListDelay(proxies as never, 'g', 5000, 2)
|
|
await flush()
|
|
|
|
expect(settles).toBe(1)
|
|
})
|
|
|
|
test('notifies only listeners for the completed group', async () => {
|
|
let other = 0
|
|
const stop = delayManager.addGroupListener('other', () => {
|
|
other += 1
|
|
})
|
|
|
|
await delayManager.checkDelay(node('a') as never, 'g', 5000)
|
|
await flush()
|
|
|
|
expect(settles).toBe(1)
|
|
expect(other).toBe(0)
|
|
stop()
|
|
})
|
|
})
|