Skip to content

Commit

Permalink
Add isGivbackEligible filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz committed Sep 24, 2024
1 parent f1d60da commit 3ee817a
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/entities/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export enum SortingField {

export enum FilterField {
Verified = 'verified',
IsGivbackEligible = 'isGivbackEligible',
AcceptGiv = 'givingBlocksId',
AcceptFundOnGnosis = 'acceptFundOnGnosis',
AcceptFundOnMainnet = 'acceptFundOnMainnet',
Expand Down
95 changes: 93 additions & 2 deletions src/resolvers/projectResolver.allProject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ function allProjectsTestCases() {
);
assert.isTrue(firstProjectIsOlder);
});
it('should return projects, filter by verified, true', async () => {

it('should return projects, filter by verified, true #1', async () => {
// There is two verified projects so I just need to create a project with verified: false and listed:true
await saveProjectDirectlyToDb({
const unverifiedProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
Expand All @@ -239,7 +240,97 @@ function allProjectsTestCases() {
result.data.data.allProjects.projects.forEach(project =>
assert.isTrue(project.verified),
);

// should not include unverified project in the response
assert.notExists(
result.data.data.allProjects.projects.find(
project => Number(project.id) === unverifiedProject.id,
),
);
});
it('should return projects, filter by verified, true #2', async () => {
const verified = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
verified: true,
qualityScore: 0,
});
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
filters: ['Verified'],
sortingBy: SortingField.Newest,
},
});
assert.isNotEmpty(result.data.data.allProjects.projects);
result.data.data.allProjects.projects.forEach(project =>
assert.isTrue(project.verified),
);

// should not include unverified project in the response
assert.exists(
result.data.data.allProjects.projects.find(
project => Number(project.id) === verified.id,
),
);
});

it('should return projects, filter by isGivbackEligible, true #1', async () => {
// There is two isGivbackEligible projects so I just need to create a project with isGivbackEligible: false and listed:true
const notGivbackEligibleProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
isGivbackEligible: false,
qualityScore: 0,
});
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
filters: ['IsGivbackEligible'],
},
});
assert.isNotEmpty(result.data.data.allProjects.projects);
result.data.data.allProjects.projects.forEach(project =>
assert.isTrue(project.isGivbackEligible),
);

// should not include unisGivbackEligible project in the response
assert.notExists(
result.data.data.allProjects.projects.find(
project => Number(project.id) === notGivbackEligibleProject.id,
),
);
});
it('should return projects, filter by isGivbackEligible, true #2', async () => {
const givbackEligibleProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
isGivbackEligible: true,
qualityScore: 0,
});
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
filters: ['IsGivbackEligible'],
sortingBy: SortingField.Newest,
},
});
assert.isNotEmpty(result.data.data.allProjects.projects);
result.data.data.allProjects.projects.forEach(project =>
assert.isTrue(project.isGivbackEligible),
);

// should not include unisGivbackEligible project in the response
assert.exists(
result.data.data.allProjects.projects.find(
project => Number(project.id) === givbackEligibleProject.id,
),
);
});

it('should return projects, filter by acceptGiv, true', async () => {
await saveProjectDirectlyToDb({
...createProjectData(),
Expand Down

0 comments on commit 3ee817a

Please sign in to comment.