Files
SnowLuma/packages/onebot/tests/manager-config-apply.test.ts
T
DrSmoothl dc2ec1235a feat(onebot): backfill cloud history after login
Add an opt-in per-account login history backfill that waits for roster warmup and a 30-second grace period before silently filling local message history. The setting defaults to disabled and applies on the next account lifecycle.

Run one account at a time, prioritize known local gaps, and process at most three groups plus three friends with one 20-message page per session. Failures are logged and never retried during the same login.

Persist reconstructed history without dispatching OneBot events or changing QQ read state. Keep private metadata and event bodies atomic, honor recall tombstones, suppress live-only history side effects, avoid extra media requests, and stop queued, in-flight, or converting work when the account closes.

Share the persistence path with manual history actions and add lifecycle, cancellation, corruption, partial-failure, peer-identity, and storage-atomicity regression coverage. Refs #280.
2026-07-25 23:44:28 +08:00

38 lines
1.3 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest';
import { OneBotManager } from '../src/manager';
import type { OneBotConfig } from '../src/types';
function config(trigger: string): OneBotConfig {
return {
networks: { httpServers: [], httpClients: [], wsServers: [], wsClients: [] },
statusCommand: { enabled: true, swallow: false, cooldownSeconds: 5, trigger },
historySync: { enabled: false },
notifications: { channelIds: [] },
};
}
describe('OneBotManager config apply value ownership', () => {
it('passes each concurrent caller exact config value to the instance', async () => {
const manager = new OneBotManager();
const seen: OneBotConfig[] = [];
const instance = {
reloadConfig: vi.fn(async (value: OneBotConfig) => {
seen.push(value);
return { applied: true, errors: [], statuses: [] };
}),
};
(manager as unknown as { instances: Map<string, unknown> }).instances.set('10001', instance);
const a = config('#a');
const b = config('#b');
await Promise.all([
manager.reloadConfig('10001', a),
manager.reloadConfig('10001', b),
]);
expect(seen).toEqual([a, b]);
expect(instance.reloadConfig).toHaveBeenNthCalledWith(1, a);
expect(instance.reloadConfig).toHaveBeenNthCalledWith(2, b);
});
});