diff --git a/src/store/__test__/bountyCard.spec.ts b/src/store/__test__/bountyCard.spec.ts index 9aef21a1..4a61be40 100644 --- a/src/store/__test__/bountyCard.spec.ts +++ b/src/store/__test__/bountyCard.spec.ts @@ -34,20 +34,15 @@ describe('BountyCardStore', () => { describe('loadWorkspaceBounties', () => { it('should handle successful bounty cards fetch', async () => { - const mockBounties = [{ id: 1, title: 'Test Bounty', pow: 0 }]; + const mockBounties = [{ id: 1, title: 'Test Bounty', status: 'TODO' }]; - fetchStub.onFirstCall().resolves({ + fetchStub.resolves({ ok: true, json: async () => mockBounties } as Response); - fetchStub.onSecondCall().resolves({ - ok: true, - json: async () => [] - } as Response); - store = new BountyCardStore(mockWorkspaceId); - await waitFor(() => expect(store.bountyCards).toEqual([{ ...mockBounties[0] }])); + await waitFor(() => expect(store.bountyCards).toEqual(mockBounties)); expect(store.loading).toBe(false); expect(store.error).toBeNull(); @@ -70,23 +65,18 @@ describe('BountyCardStore', () => { describe('switchWorkspace', () => { it('should switch workspace and reload bounties', async () => { const newWorkspaceId = 'new-workspace-456'; - const mockBounties = [{ id: 2, title: 'New Bounty', pow: 0 }]; + const mockBounties = [{ id: 2, title: 'New Bounty', status: 'TODO' }]; - fetchStub.onFirstCall().resolves({ + fetchStub.resolves({ ok: true, json: async () => mockBounties } as Response); - fetchStub.onSecondCall().resolves({ - ok: true, - json: async () => [] - } as Response); - store = new BountyCardStore(mockWorkspaceId); await waitFor(() => store.switchWorkspace(newWorkspaceId)); expect(store.currentWorkspaceId).toBe(newWorkspaceId); - expect(store.bountyCards).toEqual([{ ...mockBounties[0] }]); + expect(store.bountyCards).toEqual(mockBounties); }); it('should not reload if workspace id is the same', async () => { diff --git a/src/store/bountyCard.ts b/src/store/bountyCard.ts index 43f5dc2f..cd2fe828 100644 --- a/src/store/bountyCard.ts +++ b/src/store/bountyCard.ts @@ -70,39 +70,8 @@ export class BountyCardStore { const data = (await response.json()) as BountyCard[] | null; - // Fetch proof counts for each bounty - const bountyCardsWithProofs = await Promise.all( - (data || []).map(async (bounty: BountyCard) => { - try { - const proofsUrl = `${TribesURL}/gobounties/${bounty.id}/proofs`; - const proofsResponse = await fetch(proofsUrl, { - method: 'GET', - headers: { - 'x-jwt': jwt, - 'Content-Type': 'application/json' - } - }); - - if (!proofsResponse.ok) { - return { ...bounty, pow: 0 }; - } - - const proofs = await proofsResponse.json(); - return { - ...bounty, - pow: Array.isArray(proofs) ? proofs.length : 0 - }; - } catch (error) { - console.error(`Error fetching proofs for bounty ${bounty.id}:`, error); - return { ...bounty, pow: 0 }; - } - }) - ); - runInAction(() => { - this.bountyCards = bountyCardsWithProofs.map((bounty: BountyCard) => ({ - ...bounty - })); + this.bountyCards = data || []; }); } catch (error) { console.error('Error loading bounties:', error);