feat(worker): WhatsAppSessionPool + group-sync accepts accountId
This commit is contained in:
@@ -48,7 +48,7 @@ describe('syncGroups', () => {
|
||||
.mockResolvedValueOnce({ id: 'db-group-1' })
|
||||
.mockResolvedValueOnce({ id: 'db-group-2' });
|
||||
|
||||
const result = await syncGroups(mockGroups, mockPrisma as any);
|
||||
const result = await syncGroups(mockGroups, 'account-1', mockPrisma as any);
|
||||
|
||||
expect(mockPrisma.group.upsert).toHaveBeenCalledTimes(2);
|
||||
expect(result.get('120363043312345678@g.us')).toBe('db-group-1');
|
||||
@@ -60,6 +60,7 @@ describe('syncGroups', () => {
|
||||
|
||||
await syncGroups(
|
||||
{ '120363043312345678@g.us': mockGroups['120363043312345678@g.us'] },
|
||||
'account-1',
|
||||
mockPrisma as any,
|
||||
);
|
||||
|
||||
@@ -71,8 +72,13 @@ describe('syncGroups', () => {
|
||||
name: 'UP Parivar Dallas',
|
||||
description: 'Main community group',
|
||||
isActive: true,
|
||||
accountId: 'account-1',
|
||||
},
|
||||
update: {
|
||||
name: 'UP Parivar Dallas',
|
||||
description: 'Main community group',
|
||||
accountId: 'account-1',
|
||||
},
|
||||
update: { name: 'UP Parivar Dallas', description: 'Main community group' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,18 +87,19 @@ describe('syncGroups', () => {
|
||||
|
||||
await syncGroups(
|
||||
{ '999999999@g.us': mockGroups['999999999@g.us'] },
|
||||
'account-1',
|
||||
mockPrisma as any,
|
||||
);
|
||||
|
||||
expect(mockPrisma.group.upsert).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
create: expect.objectContaining({ description: undefined }),
|
||||
create: expect.objectContaining({ description: undefined, accountId: 'account-1' }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('returns an empty map when given empty groups', async () => {
|
||||
const result = await syncGroups({}, mockPrisma as any);
|
||||
const result = await syncGroups({}, 'account-1', mockPrisma as any);
|
||||
expect(result.size).toBe(0);
|
||||
expect(mockPrisma.group.upsert).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user