Skip to content

Commit

Permalink
add tests for staging goerli and alfajores
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Aug 30, 2023
1 parent 444fdcc commit 1649ca4
Showing 1 changed file with 125 additions and 85 deletions.
210 changes: 125 additions & 85 deletions src/resolvers/projectResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ import {
} from '../services/projectViewsService';
import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository';
import { findPowerSnapshots } from '../repositories/powerSnapshotRepository';
import { logger } from '../utils/logger';

const ARGUMENT_VALIDATION_ERROR_MESSAGE = new ArgumentValidationError([
{ property: '' },
Expand Down Expand Up @@ -878,9 +877,13 @@ function allProjectsTestCases() {
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.MAIN_NET,
});

const gnosisAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.XDAI,
})) as ProjectAddress;
gnosisAddress.isRecipient = false;
await gnosisAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand Down Expand Up @@ -909,9 +912,13 @@ function allProjectsTestCases() {
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.CELO,
});

const celoAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.CELO,
})) as ProjectAddress;
celoAddress.isRecipient = true;
await celoAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand Down Expand Up @@ -940,8 +947,13 @@ function allProjectsTestCases() {
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.XDAI,
});
const celoAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.CELO,
})) as ProjectAddress;
celoAddress.isRecipient = false;
await celoAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand Down Expand Up @@ -970,9 +982,13 @@ function allProjectsTestCases() {
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.MAIN_NET,
});

const mainnetAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.MAIN_NET,
})) as ProjectAddress;
mainnetAddress.isRecipient = true;
await mainnetAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand Down Expand Up @@ -1001,9 +1017,13 @@ function allProjectsTestCases() {
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.XDAI,
});

const mainnetAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.MAIN_NET,
})) as ProjectAddress;
mainnetAddress.isRecipient = false;
await mainnetAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand Down Expand Up @@ -1032,9 +1052,13 @@ function allProjectsTestCases() {
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.POLYGON,
});

const polygonAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.POLYGON,
})) as ProjectAddress;
polygonAddress.isRecipient = true;
await polygonAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand Down Expand Up @@ -1063,9 +1087,13 @@ function allProjectsTestCases() {
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.XDAI,
});

const polygonAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.POLYGON,
})) as ProjectAddress;
polygonAddress.isRecipient = false;
await polygonAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand All @@ -1089,14 +1117,89 @@ function allProjectsTestCases() {
);
});

it('should return projects, filter by accept donation on optimism', async () => {
it('should return projects, filter by accept donation on GOERLI', async () => {
const savedProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.OPTIMISTIC,
});
const optimismAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.GOERLI,
})) as ProjectAddress;
optimismAddress.isRecipient = true;
await optimismAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
filters: ['AcceptFundOnMainnet'],
sortingBy: SortingField.Newest,
limit: 50,
},
});
result.data.data.allProjects.projects.forEach(project => {
assert.isOk(
project.addresses.find(
address =>
address.isRecipient === true &&
address.networkId === NETWORK_IDS.GOERLI,
),
);
});
assert.isOk(
result.data.data.allProjects.projects.find(
project => Number(project.id) === Number(savedProject.id),
),
);
});

it('should return projects, filter by accept donation on ALFAJORES', async () => {
const savedProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
});
const optimismAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.CELO_ALFAJORES,
})) as ProjectAddress;
optimismAddress.isRecipient = true;
await optimismAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
filters: ['AcceptFundOnCelo'],
sortingBy: SortingField.Newest,
},
});
result.data.data.allProjects.projects.forEach(project => {
assert.isOk(
project.addresses.find(
address =>
address.isRecipient === true &&
address.networkId === NETWORK_IDS.CELO_ALFAJORES,
),
);
});
assert.isOk(
result.data.data.allProjects.projects.find(
project => Number(project.id) === Number(savedProject.id),
),
);
});

it('should return projects, filter by accept donation on optimism', async () => {
const savedProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
});
const optimismAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.OPTIMISTIC,
})) as ProjectAddress;
optimismAddress.isRecipient = true;
await optimismAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand Down Expand Up @@ -1124,9 +1227,13 @@ function allProjectsTestCases() {
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.XDAI,
});

const optimismAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.OPTIMISTIC,
})) as ProjectAddress;
optimismAddress.isRecipient = false;
await optimismAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
Expand Down Expand Up @@ -1226,73 +1333,6 @@ function allProjectsTestCases() {
),
);
});

it('should return projects, return projects that matches with at least one of networks', async () => {
const mainnetProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.MAIN_NET,
});

const gnosisProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.XDAI,
});

const polygonProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.POLYGON,
});

const optimismProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.OPTIMISTIC,
});

const celoProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
networkId: NETWORK_IDS.CELO,
});

const projects = [
celoProject,
mainnetProject,
gnosisProject,
polygonProject,
optimismProject,
];

const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
filters: [
'AcceptFundOnMainnet',
'AcceptFundOnGnosis',
'AcceptFundOnPolygon',
'AcceptFundOnCelo',
'AcceptFundOnOptimism',
],
sortingBy: SortingField.Newest,
},
});
projects.forEach(p => {
assert.isOk(
result.data.data.allProjects.projects.find(
project => Number(project.id) === Number(p.id),
),
);
});
});

it('should return projects, filter by campaignSlug and limit, skip', async () => {
const project1 = await saveProjectDirectlyToDb({
...createProjectData(),
Expand Down

0 comments on commit 1649ca4

Please sign in to comment.