Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(engine): pin the Baileys plugin's lid and chat-state store wiring

Yudhi Armyndharis1e78628b0780
diff --git a/src/engine/builtin/baileys/index.spec.ts b/src/engine/builtin/baileys/index.spec.ts
index ffa728ef7..dd7099a40 100644
--- a/src/engine/builtin/baileys/index.spec.ts
+++ b/src/engine/builtin/baileys/index.spec.ts
@@ -6,6 +6,8 @@ jest.mock('../../adapters/baileys.adapter', () => ({
import { BaileysPlugin } from './index';
import { BaileysAdapter } from '../../adapters/baileys.adapter';
+import type { LidMappingStore } from '../../identity/lid-mapping-store.service';
+import type { ChatStateStore } from '../../adapters/baileys-chat-state-store.service';
describe('BaileysPlugin.createEngine (opaque config)', () => {
beforeEach(() => jest.clearAllMocks());
@@ -74,6 +76,15 @@ describe('BaileysPlugin.createEngine (opaque config)', () => {
expect(BaileysAdapter).toHaveBeenCalledWith(expect.objectContaining({ sessionId: 'sess-1', messageStore: store }));
});
+ // Both stores are optional in the adapter, so a dropped hop would silently stop persisting learned
+ // lid pairs and chat state across restarts instead of failing anything.
+ it('passes the lid-mapping and chat-state stores to the adapter', () => {
+ const lidMappingStore = {} as LidMappingStore;
+ const chatStateStore = {} as ChatStateStore;
+ new BaileysPlugin(undefined, undefined, lidMappingStore, chatStateStore).createEngine({ sessionId: 'sess-1' });
+ expect(BaileysAdapter).toHaveBeenCalledWith(expect.objectContaining({ lidMappingStore, chatStateStore }));
+ });
+
it('Uses the constructor-supplied engine config when onLoad never ran (enable-failure path)', () => {
const plugin = new BaileysPlugin(undefined, { baileys: { authDir: '/op/baileys' } });
plugin.createEngine({ sessionId: 'sess-3' });