Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(baileys): spend the queued group metadata before asserting

Yudhi Armyndharisdaa343183e8c
diff --git a/src/engine/adapters/baileys.adapter.spec.ts b/src/engine/adapters/baileys.adapter.spec.ts
index 0f5e16ae3..0d4db6b57 100644
--- a/src/engine/adapters/baileys.adapter.spec.ts
+++ b/src/engine/adapters/baileys.adapter.spec.ts
@@ -4622,9 +4622,12 @@ describe('BaileysAdapter group management', () => {
fakeSock.groupFetchAllParticipating.mockResolvedValue({ '[email protected]': lidMeta });
fakeSock.groupMetadata.mockResolvedValueOnce(lidMeta);
const adapter = await ready();
+ // Read the info first so the queued metadata is spent even when an assertion below fails;
+ // a leftover once-value would leak into the next getGroupInfo test.
+ const info = await adapter.getGroupInfo('[email protected]');
expect(await adapter.getGroups()).toEqual([expect.objectContaining({ id: '[email protected]', isAdmin: true })]);
// An admin of an announce-only group can still post there.
- expect(await adapter.getGroupInfo('[email protected]')).toMatchObject({ isAnnounce: true, isReadOnly: false });
+ expect(info).toMatchObject({ isAnnounce: true, isReadOnly: false });
});
it('getGroupInfo maps groupMetadata, and returns null only for a server refusal (401/403/404)', async () => {