cc-haha/adapters/common/__tests__/pairing.test.ts
程序员阿江(Relakkes) ddcfa5faae feat(adapters): add WhatsApp linked-device support (#573)
Add a WhatsApp adapter backed by Baileys linked-device auth, plus desktop QR binding UI, server config endpoints, sidecar startup wiring, tests, and documentation.

Constraint: Uses WhatsApp Web linked-device auth, not Meta WhatsApp Business Cloud API.

Tested:
- cd adapters && bun run check:adapters
- bun test src/server/__tests__/adapters.test.ts
- cd desktop && bun run check:desktop
- bun run check:native
- bun run check:persistence-upgrade
- bun run check:docs

Not-tested:
- Live WhatsApp QR pairing, because no WhatsApp account/device was exercised here.
- bun run check:server, because the existing src/server/__tests__/conversations.test.ts timeout still fails independently.

Confidence: medium
Scope-risk: moderate
2026-06-09 21:31:46 +08:00

32 lines
998 B
TypeScript

import { describe, expect, it } from 'bun:test'
import { isPaired } from '../pairing.js'
describe('pairing platform support', () => {
it('checks DingTalk paired users with the same shared access rule', () => {
expect(isPaired('dingtalk', 'staff-1', {
dingtalk: {
pairedUsers: [{ userId: 'staff-1', displayName: 'DingTalk User', pairedAt: Date.now() }],
allowedUsers: [],
},
})).toBe(true)
})
it('keeps empty DingTalk allow and pair lists closed by default', () => {
expect(isPaired('dingtalk', 'staff-1', {
dingtalk: {
pairedUsers: [],
allowedUsers: [],
},
})).toBe(false)
})
it('checks WhatsApp paired users with the same shared access rule', () => {
expect(isPaired('whatsapp', '15551234567@s.whatsapp.net', {
whatsapp: {
pairedUsers: [{ userId: '15551234567@s.whatsapp.net', displayName: 'WhatsApp User', pairedAt: Date.now() }],
allowedUsers: [],
},
})).toBe(true)
})
})