|  |  |  | @ -15,18 +15,22 @@ describe('GroupSyncService', () => { | 
		
	
		
			
				|  |  |  |  |     db.exec('DELETE FROM sqlite_sequence WHERE name="groups"'); | 
		
	
		
			
				|  |  |  |  |     GroupSyncService['lastSyncAttempt'] = 0; | 
		
	
		
			
				|  |  |  |  |      | 
		
	
		
			
				|  |  |  |  |     // Setup mock fetch
 | 
		
	
		
			
				|  |  |  |  |     fetchMock = mock(async () => ({ | 
		
	
		
			
				|  |  |  |  |       ok: true, | 
		
	
		
			
				|  |  |  |  |       json: async () => ({ | 
		
	
		
			
				|  |  |  |  |         status: 'success', | 
		
	
		
			
				|  |  |  |  |         response: [ | 
		
	
		
			
				|  |  |  |  |           { id: 'group1', subject: 'Group 1', linkedParent: 'test-community' }, | 
		
	
		
			
				|  |  |  |  |           { id: 'group2', subject: 'Group 2', linkedParent: 'other-community' }, | 
		
	
		
			
				|  |  |  |  |           { id: 'group3', subject: 'Group 3' } // No linkedParent
 | 
		
	
		
			
				|  |  |  |  |         ] | 
		
	
		
			
				|  |  |  |  |       }) | 
		
	
		
			
				|  |  |  |  |     })); | 
		
	
		
			
				|  |  |  |  |     // Setup mock fetch to return proper Response object
 | 
		
	
		
			
				|  |  |  |  |     fetchMock = mock(async () => { | 
		
	
		
			
				|  |  |  |  |       const groups = [ | 
		
	
		
			
				|  |  |  |  |         { id: 'group1', subject: 'Group 1', linkedParent: 'test-community' }, | 
		
	
		
			
				|  |  |  |  |         { id: 'group2', subject: 'Group 2', linkedParent: 'other-community' }, | 
		
	
		
			
				|  |  |  |  |         { id: 'group3', subject: 'Group 3' } // No linkedParent
 | 
		
	
		
			
				|  |  |  |  |       ]; | 
		
	
		
			
				|  |  |  |  |       return { | 
		
	
		
			
				|  |  |  |  |         ok: true, | 
		
	
		
			
				|  |  |  |  |         status: 200, | 
		
	
		
			
				|  |  |  |  |         statusText: 'OK', | 
		
	
		
			
				|  |  |  |  |         headers: new Headers({'Content-Type': 'application/json'}), | 
		
	
		
			
				|  |  |  |  |         text: async () => JSON.stringify(groups), | 
		
	
		
			
				|  |  |  |  |         json: async () => groups | 
		
	
		
			
				|  |  |  |  |       }; | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  |     globalThis.fetch = fetchMock; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     // Setup env vars
 | 
		
	
	
		
			
				
					|  |  |  | @ -139,7 +143,11 @@ describe('GroupSyncService', () => { | 
		
	
		
			
				|  |  |  |  |        | 
		
	
		
			
				|  |  |  |  |       globalThis.fetch = mock(async () => ({ | 
		
	
		
			
				|  |  |  |  |         ok: false, | 
		
	
		
			
				|  |  |  |  |         statusText: 'Not Found' | 
		
	
		
			
				|  |  |  |  |         status: 404, | 
		
	
		
			
				|  |  |  |  |         statusText: 'Not Found', | 
		
	
		
			
				|  |  |  |  |         headers: new Headers(), | 
		
	
		
			
				|  |  |  |  |         text: async () => 'Not Found', | 
		
	
		
			
				|  |  |  |  |         json: async () => ({ error: 'Not Found' }) | 
		
	
		
			
				|  |  |  |  |       })); | 
		
	
		
			
				|  |  |  |  |        | 
		
	
		
			
				|  |  |  |  |       await expect(GroupSyncService.syncGroups()).rejects.toThrow('API request failed: Not Found'); | 
		
	
	
		
			
				
					|  |  |  | 
 |