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

Loading…
Cancel
Save