test: fix group sync test by resetting lastSyncAttempt and improving assertions

main
borja (aider) 3 months ago
parent 89c4b27897
commit df6d9926af

@ -65,22 +65,30 @@ describe('GroupSyncService', () => {
});
it('should filter groups by community ID', async () => {
// Reset last sync attempt to force a sync
GroupSyncService['lastSyncAttempt'] = 0;
const result = await GroupSyncService.syncGroups();
// Verify the correct groups were processed
expect(result).toEqual({
added: 1,
updated: 0
added: 1, // group1 should be added
updated: 0 // no existing groups to update
});
// Verify database state
const groups = db.query('SELECT * FROM groups').all();
expect(groups).toEqual([
{
id: 'group1',
community_id: 'test-community',
name: 'Group 1',
active: 1,
last_verified: expect.any(String)
}
]);
expect(groups).toHaveLength(1);
const group = groups[0];
expect(group.id).toBe('group1');
expect(group.community_id).toBe('test-community');
expect(group.name).toBe('Group 1');
expect(group.active).toBe(1);
expect(group.last_verified).toBeTruthy();
// Verify only the matching group was processed
expect(fetchMock).toHaveBeenCalledTimes(1);
});
it('should update existing groups', async () => {

Loading…
Cancel
Save