Skip to content

Commit

Permalink
Merge pull request stakwork#714 from aliraza556/fix-bounties-search-q…
Browse files Browse the repository at this point in the history
…uery-param

Fix: Bounties Search Functionality Not Working
  • Loading branch information
humansinstitute authored Dec 5, 2024
2 parents c5543c1 + 8610f1c commit 429341a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/store/__test__/main.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { toJS } from 'mobx';
import sinon from 'sinon';
import moment from 'moment';
import { waitFor } from '@testing-library/react';
import { people } from '../../__test__/__mockData__/persons';
import { user } from '../../__test__/__mockData__/user';
import { MeInfo, emptyMeInfo, uiStore } from '../ui';
Expand Down Expand Up @@ -1146,6 +1147,7 @@ describe('Main store', () => {
);
expect(res).toBeTruthy();
});

it('should accept search query and return results based on query ', async () => {
const store = new MainStore();

Expand Down Expand Up @@ -1178,10 +1180,12 @@ describe('Main store', () => {

await store.getPeopleBounties(searchCriteria);

sinon.assert.calledWithMatch(fetchStub, bountiesUrl);
expect(fetchStub.calledOnce).toBe(true);
expect(store.peopleBounties).toHaveLength(1);
expect(store.peopleBounties[0].body.title).toEqual(searchCriteria.search);
waitFor(() => {
sinon.assert.calledWithMatch(fetchStub, bountiesUrl);
expect(fetchStub.calledOnce).toBe(true);
expect(store.peopleBounties).toHaveLength(1);
expect(store.peopleBounties[0].body.title).toEqual(searchCriteria.search);
});
});

it('should return filter by languages, status response', async () => {
Expand Down
11 changes: 7 additions & 4 deletions src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,16 +650,19 @@ export class MainStore {
Pending: false,
Failed: false,
languageString: '',
direction: 'desc'
direction: 'desc',
search: uiStore.searchText ?? ''
};
}
}

queryParams =
(params.Pending === 'true' || params.Pending === true) &&
queryParams = {
...((params.Pending === 'true' || params.Pending === true) &&
(params.Paid === 'false' || params.Paid === false)
? newParams
: params;
: params),
search: uiStore.searchText ?? ''
};

const query2 = this.appendQueryParams(
'gobounties/all',
Expand Down

0 comments on commit 429341a

Please sign in to comment.