feat: thread QR/status callbacks through session pool; persist to DB in main
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,4 +89,21 @@ describe('WhatsAppSessionPool', () => {
|
||||
await capturedOnMessage(fakeMsg);
|
||||
expect(onMessage).toHaveBeenCalledWith(fakeMsg, 'acc_1');
|
||||
});
|
||||
|
||||
it('add() injects accountId into onQr callback', async () => {
|
||||
const onQr = jest.fn();
|
||||
const { createWhatsAppSession } = require('./session');
|
||||
|
||||
let capturedOnQr: any;
|
||||
(createWhatsAppSession as jest.Mock).mockImplementationOnce(
|
||||
(_id: string, _path: string, _onMsg: any, _onReaction: any, _onGroups: any, _onReconnect: any, qrCb: any) => {
|
||||
capturedOnQr = qrCb;
|
||||
return Promise.resolve({ sendMessage: jest.fn(), logout: jest.fn(), end: jest.fn() });
|
||||
},
|
||||
);
|
||||
|
||||
await pool.add('acc_1', './sessions/1', jest.fn(), jest.fn(), jest.fn(), onQr);
|
||||
await capturedOnQr('test-qr');
|
||||
expect(onQr).toHaveBeenCalledWith('test-qr', 'acc_1');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user